Changeset 5649
- Timestamp:
- 02/15/09 18:26:57 (4 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 9 modified
-
CHANGES (modified) (1 diff)
-
doc/libsensors-API.txt (modified) (1 diff)
-
lib/access.c (modified) (4 diffs)
-
lib/conf-parse.y (modified) (1 diff)
-
lib/conf.h (modified) (1 diff)
-
lib/data.c (modified) (4 diffs)
-
lib/error.c (modified) (3 diffs)
-
lib/error.h (modified) (2 diffs)
-
lib/init.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/CHANGES
r5647 r5649 13 13 Exit the configuration file parser sooner 14 14 Free bus statements from the configuration file sooner 15 Read extra configuration files from /etc/sensors.d 15 Read extra configuration files from /etc/sensors.d (#2174) 16 Report the configuration file name on parse errors 16 17 lm_sensors.init: Support new format of /etc/sysconfig/lm_sensors (#2246) 17 18 Drop support for kernels 2.4 and earlier -
lm-sensors/trunk/doc/libsensors-API.txt
r5593 r5649 25 25 * Added error value for excessive recursion depth 26 26 #define SENSORS_ERR_RECURSION 11 27 * Added parse error reporting function including the configuration file 28 name 29 extern void (*sensors_parse_error_wfn) (const char *err, 30 const char *filename, int lineno); 27 31 28 32 0x401 lm-sensors 3.0.2 to 3.0.3 -
lm-sensors/trunk/lib/access.c
r5648 r5649 2 2 access.c - Part of libsensors, a Linux library for reading sensor data. 3 3 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> 4 Copyright (C) 2007 , 2008Jean Delvare <khali@linux-fr.org>4 Copyright (C) 2007-2009 Jean Delvare <khali@linux-fr.org> 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 512 512 chip->sets[i].name); 513 513 if (!subfeature) { 514 sensors_parse_error("Unknown feature name", 514 sensors_parse_error_wfn("Unknown feature name", 515 chip->sets[i].line.filename, 515 516 chip->sets[i].line.lineno); 516 517 err = -SENSORS_ERR_NO_ENTRY; … … 522 523 0, &value); 523 524 if (res) { 524 sensors_parse_error("Error parsing expression", 525 sensors_parse_error_wfn("Error parsing expression", 526 chip->sets[i].line.filename, 525 527 chip->sets[i].line.lineno); 526 528 err = res; … … 529 531 if ((res = sensors_set_value(name, subfeature->number, 530 532 value))) { 531 sensors_parse_error("Failed to set value", 533 sensors_parse_error_wfn("Failed to set value", 534 chip->sets[i].line.filename, 532 535 chip->sets[i].line.lineno); 533 536 err = res; -
lm-sensors/trunk/lib/conf-parse.y
r5648 r5649 333 333 { 334 334 if (sensors_lex_error[0]) { 335 sensors_parse_error (sensors_lex_error,sensors_yylineno);335 sensors_parse_error_wfn(sensors_lex_error, sensors_yyfilename, sensors_yylineno); 336 336 sensors_lex_error[0] = '\0'; 337 337 } else 338 sensors_parse_error (err,sensors_yylineno);338 sensors_parse_error_wfn(err, sensors_yyfilename, sensors_yylineno); 339 339 } 340 340 -
lm-sensors/trunk/lib/conf.h
r5163 r5649 25 25 int sensors_yylex(void); 26 26 extern char sensors_lex_error[]; 27 extern const char *sensors_yyfilename; 27 28 extern int sensors_yylineno; 28 29 extern FILE *sensors_yyin; -
lm-sensors/trunk/lib/data.c
r5648 r5649 203 203 } 204 204 205 static int sensors_substitute_chip(sensors_chip_name *name, int lineno) 205 static int sensors_substitute_chip(sensors_chip_name *name, 206 const char *filename, int lineno) 206 207 { 207 208 int i, j; … … 212 213 213 214 if (i == sensors_config_busses_count) { 214 sensors_parse_error("Undeclared bus id referenced", lineno); 215 sensors_parse_error_wfn("Undeclared bus id referenced", 216 filename, lineno); 215 217 name->bus.nr = SENSORS_BUS_NR_IGNORE; 216 218 return -SENSORS_ERR_BUS_NAME; … … 239 241 int err, i, j, lineno; 240 242 sensors_chip_name_list *chips; 243 const char *filename; 241 244 int res = 0; 242 245 243 246 for (i = sensors_config_chips_subst; 244 247 i < sensors_config_chips_count; i++) { 248 filename = sensors_config_chips[i].line.filename; 245 249 lineno = sensors_config_chips[i].line.lineno; 246 250 chips = &sensors_config_chips[i].chips; … … 251 255 continue; 252 256 253 err = sensors_substitute_chip(&chips->fits[j], lineno); 257 err = sensors_substitute_chip(&chips->fits[j], 258 filename, lineno); 254 259 if (err) 255 260 res = err; -
lm-sensors/trunk/lib/error.c
r5638 r5649 2 2 error.c - Part of libsensors, a Linux library for reading sensor data. 3 3 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> 4 Copyright (C) 2007 , 2008Jean Delvare <khali@linux-fr.org>4 Copyright (C) 2007-2009 Jean Delvare <khali@linux-fr.org> 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 26 26 27 27 static void sensors_default_parse_error(const char *err, int lineno); 28 static void sensors_default_parse_error_wfn(const char *err, 29 const char *filename, int lineno); 28 30 static void sensors_default_fatal_error(const char *proc, const char *err); 29 31 30 32 void (*sensors_parse_error) (const char *err, int lineno) = 31 33 sensors_default_parse_error; 34 void (*sensors_parse_error_wfn) (const char *err, const char *filename, 35 int lineno) = sensors_default_parse_error_wfn; 32 36 void (*sensors_fatal_error) (const char *proc, const char *err) = 33 37 sensors_default_fatal_error; … … 65 69 } 66 70 71 void sensors_default_parse_error_wfn(const char *err, 72 const char *filename, int lineno) 73 { 74 /* If application provided a custom parse error reporting function 75 but not the variant with the filename, fall back to the original 76 variant without the filename, for backwards compatibility. */ 77 if (sensors_parse_error != sensors_default_parse_error || 78 !filename) 79 return sensors_parse_error(err, lineno); 80 81 if (lineno) 82 fprintf(stderr, "Error: File %s, line %d: %s\n", filename, 83 lineno, err); 84 else 85 fprintf(stderr, "Error: File %s: %s\n", filename, err); 86 } 87 67 88 void sensors_default_fatal_error(const char *proc, const char *err) 68 89 { -
lm-sensors/trunk/lib/error.h
r5582 r5649 2 2 error.h - Part of libsensors, a Linux library for reading sensor data. 3 3 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> 4 Copyright (C) 2007 , 2008Jean Delvare <khali@linux-fr.org>4 Copyright (C) 2007-2009 Jean Delvare <khali@linux-fr.org> 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 45 45 const char *sensors_strerror(int errnum); 46 46 47 /* This function is called when a parse error is detected. Give it a new 48 value, and your own function is called instead of the default (which 49 prints to stderr). This function may terminate the program, but it 50 usually outputs an error and returns. */ 47 /* These functions are called when a parse error is detected. Give them new 48 values, and your own functions are called instead of the default (which 49 print to stderr). These functions may terminate the program, but they 50 usually output an error and return. The first function is the original 51 one, the second one was added later when support for multiple 52 configuration files was added. 53 The library code now only calls the second function. However, for 54 backwards compatibility, if an application provides a custom handling 55 function for the first function but not the second, then all parse 56 errors will be reported using the first function (that is, the filename 57 is never reported.) 58 Note that filename can be NULL (if filename isn't known) and lineno 59 can be 0 (if the error occurs before the actual parsing starts.) */ 51 60 extern void (*sensors_parse_error) (const char *err, int lineno); 61 extern void (*sensors_parse_error_wfn) (const char *err, 62 const char *filename, int lineno); 52 63 53 64 /* This function is called when an immediately fatal error (like no -
lm-sensors/trunk/lib/init.c
r5648 r5649 126 126 count = scandir(dir, &namelist, config_file_filter, alphasort); 127 127 if (count < 0) { 128 sensors_parse_error (strerror(errno), 0);128 sensors_parse_error_wfn(strerror(errno), NULL, 0); 129 129 return -SENSORS_ERR_PARSE; 130 130 } … … 148 148 } else { 149 149 res = -SENSORS_ERR_PARSE; 150 sensors_parse_error (strerror(errno), 0);150 sensors_parse_error_wfn(strerror(errno), path, 0); 151 151 } 152 152 } … … 188 188 189 189 } else if (errno != ENOENT) { 190 sensors_parse_error (strerror(errno), 0);190 sensors_parse_error_wfn(strerror(errno), name, 0); 191 191 res = -SENSORS_ERR_PARSE; 192 192 goto exit_cleanup;
