diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-09-19 10:52:59 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-09-23 13:51:14 +0200 |
commit | bdf4c60411344473334fede743fbe524d162331a (patch) | |
tree | 59e476cdb16e52e4c64bc5c1a43c6e3562ad7be9 /src/client.c | |
parent | 5d97a721d0d475ea86e9d503a2e413e22f53492b (diff) |
client: remove redundant refresh validation
json parser already validates attributes must be set on.
Diffstat (limited to 'src/client.c')
-rw-r--r-- | src/client.c | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/src/client.c b/src/client.c index 50d3373..cfc375e 100644 --- a/src/client.c +++ b/src/client.c @@ -384,7 +384,8 @@ static int og_resp_software(json_t *data, struct og_client *cli) OG_PARAM_PART_USED_SIZE) static int og_json_parse_partition_array(json_t *value, - struct og_partition *partitions) + struct og_partition *partitions, + uint32_t *num_partitions) { json_t *element; int i, err; @@ -400,6 +401,7 @@ static int og_json_parse_partition_array(json_t *value, if (err < 0) return err; } + *num_partitions = i; return 0; } @@ -795,7 +797,6 @@ static int og_resp_refresh(json_t *data, struct og_client *cli) struct og_dbi *dbi; uint32_t link = 0; const char *key; - unsigned int i; int err = 0; bool res; @@ -804,9 +805,11 @@ static int og_resp_refresh(json_t *data, struct og_client *cli) json_object_foreach(data, key, value) { if (!strcmp(key, "disk_setup")) { - err = og_json_parse_partition_array(value, disks); + err = og_json_parse_partition_array(value, disks, + &num_disks); } else if (!strcmp(key, "partition_setup")) { - err = og_json_parse_partition_array(value, partitions); + err = og_json_parse_partition_array(value, partitions, + &num_partitions); } else if (!strcmp(key, "serial_number")) { err = og_json_parse_string(value, &serial_number); } else if (!strcmp(key, "status")) { @@ -840,26 +843,6 @@ static int og_resp_refresh(json_t *data, struct og_client *cli) return 0; } - for (i = 0; i < OG_DISK_MAX; i++) { - if (!disks[i].disk || !disks[i].number || - !disks[i].code || !disks[i].filesystem || - !disks[i].os || !disks[i].size || - !disks[i].used_size) - continue; - - num_disks++; - } - - for (i = 0; i < OG_PARTITION_MAX; i++) { - if (!partitions[i].disk || !partitions[i].number || - !partitions[i].code || !partitions[i].filesystem || - !partitions[i].os || !partitions[i].size || - !partitions[i].used_size) - continue; - - num_partitions++; - } - dbi = og_dbi_open(&ogconfig.db); if (!dbi) { syslog(LOG_ERR, "cannot open connection database (%s:%d)\n", |