mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-30 13:57:41 +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:
@@ -101,12 +101,13 @@ void print_chip_json(const sensors_chip_name *name)
|
|||||||
if (subCnt > 0)
|
if (subCnt > 0)
|
||||||
printf(",\n");
|
printf(",\n");
|
||||||
printf(" \"%s\": %.3f", sub->name, val);
|
printf(" \"%s\": %.3f", sub->name, val);
|
||||||
|
subCnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("(%s)", label);
|
printf("(%s)", label);
|
||||||
|
subCnt++;
|
||||||
}
|
}
|
||||||
subCnt++;
|
|
||||||
}
|
}
|
||||||
free(label);
|
free(label);
|
||||||
printf("\n }");
|
printf("\n }");
|
||||||
|
Reference in New Issue
Block a user