mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-30 05:48:07 +00:00
sensors: json: Do not print a stray comma
Previously, if an error happened when reading the value of a subfeature, subCnt would get incremented and a stray comma would get printed in the following iteration, even though nothing was printed in the previous iteration. This would produce a syntactically incorrect JSON. This is based on a patch from the su8 user on GitHub. Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
This commit is contained in:
parent
50f227dafe
commit
2c8cca3d6c
@ -101,13 +101,14 @@ void print_chip_json(const sensors_chip_name *name)
|
||||
if (subCnt > 0)
|
||||
printf(",\n");
|
||||
printf(" \"%s\": %.3f", sub->name, val);
|
||||
subCnt++;
|
||||
}
|
||||
|
||||
} else {
|
||||
printf("(%s)", label);
|
||||
}
|
||||
subCnt++;
|
||||
}
|
||||
}
|
||||
free(label);
|
||||
printf("\n }");
|
||||
cnt++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user