Fail if no sensors found. - energy - measure system energy usage DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit 33cf70dcdbb4ed08ba53d121d06a3c6904db9af7 DIR parent b7668ab38ae59f6202ea72674b738ec0b676e227 HTML Author: Troels Henriksen <athas@sigkill.dk> Date: Wed, 23 Aug 2023 12:25:44 +0200 Fail if no sensors found. Diffstat: M energy.c | 5 +++++ 1 file changed, 5 insertions(+), 0 deletions(-) --- DIR diff --git a/energy.c b/energy.c @@ -143,6 +143,11 @@ int main(int argc, char** argv) { sensor_rapl(); sensor_battery(); + if (num_sensors == 0) { + fprintf(stderr, "%s: no sensors found; not running command.\n", argv[0]); + exit(1); + } + for (int i = 0; i < num_sensors; i++) { sensors[i].start(sensors[i].data); }