Changeset 4899
- Timestamp:
- 09/29/07 20:48:20 (6 years ago)
- Location:
- lm-sensors/branches/lm-sensors-3.0.0
- Files:
-
- 4 modified
-
CHANGES (modified) (1 diff)
-
lib/error.c (modified) (1 diff)
-
lib/error.h (modified) (1 diff)
-
lib/sysfs.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/CHANGES
r4898 r4899 6 6 libsensors: Notify the caller when writing a value fails 7 7 Differentiate between different read error types 8 Report I/O errors as such 8 9 sensord: Log the error code on failure 9 10 sensors: Fix spurious critical temperature alarm -
lm-sensors/branches/lm-sensors-3.0.0/lib/error.c
r4879 r4899 43 43 /* SENSORS_ERR_PARSE */ "General parse error", 44 44 /* SENSORS_ERR_ACCESS_W */ "Can't write", 45 /* SENSORS_ERR_IO */ "I/O error", 45 46 }; 46 47 -
lm-sensors/branches/lm-sensors-3.0.0/lib/error.h
r4879 r4899 31 31 #define SENSORS_ERR_PARSE 8 /* General parse error */ 32 32 #define SENSORS_ERR_ACCESS_W 9 /* Can't write */ 33 #define SENSORS_ERR_IO 10 /* I/O error */ 33 34 34 35 #ifdef __cplusplus -
lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c
r4896 r4899 558 558 snprintf(n, NAME_MAX, "%s/%s", name->path, subfeature->name); 559 559 if ((f = fopen(n, "r"))) { 560 int res = fscanf(f, "%lf", value); 561 if (fclose(f) || res != 1) 562 return -SENSORS_ERR_ACCESS_R; 560 int res, err = 0; 561 562 errno = 0; 563 res = fscanf(f, "%lf", value); 564 if (res == EOF && errno == EIO) 565 err = -SENSORS_ERR_IO; 566 else if (res != 1) 567 err = -SENSORS_ERR_ACCESS_R; 568 res = fclose(f); 569 if (err) 570 return err; 571 572 if (res == EOF) { 573 if (errno == EIO) 574 return -SENSORS_ERR_IO; 575 else 576 return -SENSORS_ERR_ACCESS_R; 577 } 563 578 *value /= get_type_scaling(subfeature->type); 564 579 } else … … 577 592 snprintf(n, NAME_MAX, "%s/%s", name->path, subfeature->name); 578 593 if ((f = fopen(n, "w"))) { 579 int res; 594 int res, err = 0; 595 580 596 value *= get_type_scaling(subfeature->type); 581 597 res = fprintf(f, "%d", (int) value); 582 if (fclose(f) || res < 0) 583 return -SENSORS_ERR_ACCESS_W; 598 if (res == -EIO) 599 err = -SENSORS_ERR_IO; 600 else if (res < 0) 601 err = -SENSORS_ERR_ACCESS_W; 602 res = fclose(f); 603 if (err) 604 return err; 605 606 if (res == EOF) { 607 if (errno == EIO) 608 return -SENSORS_ERR_IO; 609 else 610 return -SENSORS_ERR_ACCESS_W; 611 } 584 612 } else 585 613 return -SENSORS_ERR_KERNEL;
