Skip to content

Commit

Permalink
system: Use size_t when iterating over ConfArray
Browse files Browse the repository at this point in the history
Also get users config only once.
  • Loading branch information
MattiasTF committed Oct 17, 2024
1 parent 8750bc4 commit a7738e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions software/src/modules/system/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ void System::register_urls()
#endif

#if MODULE_USERS_AVAILABLE() && MODULE_CHARGE_TRACKER_AVAILABLE()
for(int i = 0; i < users.config.get("users")->count(); ++i) {
uint8_t id = users.config.get("users")->get(i)->get("id")->asUint();
Config *config_users = static_cast<Config *>(users.config.get("users"));
for (size_t i = 0; i < config_users->count(); ++i) {
uint8_t id = config_users->get(i)->get("id")->asUint();
if (id == 0) // skip anonymous user
continue;
if (!charge_tracker.is_user_tracked(id)) {
Expand Down

0 comments on commit a7738e5

Please sign in to comment.