2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-09-01 06:45:24 +00:00

(mds) print message if no sensors are found rather than just silently returning.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@945 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Mark D. Studebaker
2000-12-14 01:20:52 +00:00
parent d4cf6b4a6f
commit 33d1607299
2 changed files with 17 additions and 5 deletions

View File

@@ -36,7 +36,8 @@ ask CVS about it:
Program mkpatch.pl: more fixes Program mkpatch.pl: more fixes
Program sensors: Add ds1621, mtp008 support; add -f (Fahrenheit) option; Program sensors: Add ds1621, mtp008 support; add -f (Fahrenheit) option;
add adm1025 temp2; report temp limits correctly as add adm1025 temp2; report temp limits correctly as
min/max or limit/hysteresis min/max or limit/hysteresis; print message if no
sensors are found.
Program sensors-detect: Add ds1621, mtp008 detection; Program sensors-detect: Add ds1621, mtp008 detection;
add ServerWorks detection (no driver yet) add ServerWorks detection (no driver yet)

View File

@@ -45,7 +45,7 @@ static void open_config_file(void);
static int open_this_config_file(char *filename); static int open_this_config_file(char *filename);
static void do_a_print(sensors_chip_name name); static void do_a_print(sensors_chip_name name);
static void do_a_set(sensors_chip_name name); static void do_a_set(sensors_chip_name name);
static void do_the_real_work(void); static int do_the_real_work(void);
static const char *sprintf_chip_name(sensors_chip_name name); static const char *sprintf_chip_name(sensors_chip_name name);
#define CHIPS_MAX 20 #define CHIPS_MAX 20
@@ -206,14 +206,23 @@ int main (int argc, char *argv[])
exit(1); exit(1);
} }
do_the_real_work(); if(do_the_real_work()) {
exit(0); exit(0);
} else {
if(chips[0].prefix == SENSORS_CHIP_NAME_PREFIX_ANY)
fprintf(stderr,"No sensors found!\n");
else
fprintf(stderr,"Specified sensor(s) not found!\n");
exit(1);
}
} }
void do_the_real_work(void) /* returns number of chips found */
int do_the_real_work(void)
{ {
const sensors_chip_name *chip; const sensors_chip_name *chip;
int chip_nr,i; int chip_nr,i;
int cnt = 0;
for (chip_nr = 0; (chip = sensors_get_detected_chips(&chip_nr));) for (chip_nr = 0; (chip = sensors_get_detected_chips(&chip_nr));)
for(i = 0; i < chips_count; i++) for(i = 0; i < chips_count; i++)
@@ -223,7 +232,9 @@ void do_the_real_work(void)
else else
do_a_print(*chip); do_a_print(*chip);
i = chips_count; i = chips_count;
cnt++;
} }
return(cnt);
} }
void do_a_set(sensors_chip_name name) void do_a_set(sensors_chip_name name)