Changeset 5582
- Timestamp:
- 01/11/09 13:19:32 (4 years ago)
- Location:
- lm-sensors/branches/lm-sensors-3.0.0
- Files:
-
- 5 modified
-
CHANGES (modified) (1 diff)
-
doc/libsensors-API.txt (modified) (1 diff)
-
lib/access.c (modified) (9 diffs)
-
lib/error.c (modified) (2 diffs)
-
lib/error.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/CHANGES
r5581 r5582 6 6 Add support for current sensors 7 7 Fix error propagation during expression evaluation 8 Detect excessive recursion depth during expression evaluation 8 9 maxilife scripts: Delete (driver never ported to Linux 2.6) 9 10 sensord: Accept negative temperatures in RRD database -
lm-sensors/branches/lm-sensors-3.0.0/doc/libsensors-API.txt
r5379 r5582 21 21 enum sensors_subfeature_type SENSORS_SUBFEATURE_CURR_MAX_ALARM 22 22 enum sensors_subfeature_type SENSORS_SUBFEATURE_CURR_BEEP 23 * Added error value for excessive recursion depth 24 #define SENSORS_ERR_RECURSION 11 23 25 24 26 0x401 lm-sensors 3.0.2 to 3.0.3 -
lm-sensors/branches/lm-sensors-3.0.0/lib/access.c
r5581 r5582 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 Jean Delvare <khali@linux-fr.org>4 Copyright (C) 2007, 2008 Jean Delvare <khali@linux-fr.org> 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 30 30 #include "general.h" 31 31 32 /* We watch the recursion depth for variables only, as an easy way to 33 detect cycles. */ 34 #define DEPTH_MAX 8 35 32 36 static int sensors_eval_expr(const sensors_chip_features *chip_features, 33 37 const sensors_expr *expr, 34 double val, double *result);38 double val, int depth, double *result); 35 39 36 40 /* Compare two chips name descriptions, to see whether they could match. … … 222 226 contain wildcard values! This function will return 0 on success, and <0 223 227 on failure. */ 224 intsensors_get_value(const sensors_chip_name *name, int subfeat_nr,225 double *result)228 static int __sensors_get_value(const sensors_chip_name *name, int subfeat_nr, 229 int depth, double *result) 226 230 { 227 231 const sensors_chip_features *chip_features; … … 231 235 int res, i; 232 236 237 if (depth >= DEPTH_MAX) 238 return -SENSORS_ERR_RECURSION; 233 239 if (sensors_chip_name_has_wildcards(name)) 234 240 return -SENSORS_ERR_WILDCARDS; … … 266 272 if (!expr) 267 273 *result = val; 268 else if ((res = sensors_eval_expr(chip_features, expr, val, result))) 274 else if ((res = sensors_eval_expr(chip_features, expr, val, depth, 275 result))) 269 276 return res; 270 277 return 0; 278 } 279 280 int sensors_get_value(const sensors_chip_name *name, int subfeat_nr, 281 double *result) 282 { 283 return __sensors_get_value(name, subfeat_nr, 0, result); 271 284 } 272 285 … … 316 329 if (expr) 317 330 if ((res = sensors_eval_expr(chip_features, expr, 318 value, &to_write)))331 value, 0, &to_write))) 319 332 return res; 320 333 return sensors_write_sysfs_attr(name, subfeature, to_write); … … 420 433 int sensors_eval_expr(const sensors_chip_features *chip_features, 421 434 const sensors_expr *expr, 422 double val, double *result)435 double val, int depth, double *result) 423 436 { 424 437 double res1, res2; … … 438 451 expr->data.var))) 439 452 return -SENSORS_ERR_NO_ENTRY; 440 return sensors_get_value(&chip_features->chip, 441 subfeature->number, result); 453 return __sensors_get_value(&chip_features->chip, 454 subfeature->number, depth + 1, 455 result); 442 456 } 443 457 if ((res = sensors_eval_expr(chip_features, expr->data.subexpr.sub1, 444 val, &res1)))458 val, depth, &res1))) 445 459 return res; 446 460 if (expr->data.subexpr.sub2 && 447 461 (res = sensors_eval_expr(chip_features, expr->data.subexpr.sub2, 448 val, &res2)))462 val, depth, &res2))) 449 463 return res; 450 464 switch (expr->data.subexpr.op) { … … 505 519 res = sensors_eval_expr(chip_features, 506 520 chip->sets[i].value, 0, 507 &value);521 0, &value); 508 522 if (res) { 509 523 sensors_parse_error("Error parsing expression", -
lm-sensors/branches/lm-sensors-3.0.0/lib/error.c
r5163 r5582 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 Jean Delvare <khali@linux-fr.org>4 Copyright (C) 2007, 2008 Jean Delvare <khali@linux-fr.org> 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 45 45 /* SENSORS_ERR_ACCESS_W */ "Can't write", 46 46 /* SENSORS_ERR_IO */ "I/O error", 47 /* SENSORS_ERR_RECURSION */ "Evaluation recurses too deep", 47 48 }; 48 49 -
lm-sensors/branches/lm-sensors-3.0.0/lib/error.h
r5163 r5582 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 Jean Delvare <khali@linux-fr.org>4 Copyright (C) 2007, 2008 Jean Delvare <khali@linux-fr.org> 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 33 33 #define SENSORS_ERR_ACCESS_W 9 /* Can't write */ 34 34 #define SENSORS_ERR_IO 10 /* I/O error */ 35 #define SENSORS_ERR_RECURSION 11 /* Evaluation recurses too deep */ 35 36 36 37 #ifdef __cplusplus
