2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-09-02 15:25:38 +00:00

Delete unused SENSORS_ERR_ACCESS.

Rename SENSORS_ERR_PROC to the more neutral SENSORS_ERR_KERNEL.
Introduce SENSORS_ERR_NO_DEVS for finer-grained error reporting.
Use SENSORS_ERR_KERNEL and SENSORS_ERR_NO_DEVS where appropriate.
No error message for invalid error codes.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4854 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2007-09-23 13:53:11 +00:00
parent 4b6f9ee727
commit ab36c5b0f8
5 changed files with 20 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
/* /*
error.c - Part of libsensors, a Linux library for reading sensor data. error.c - Part of libsensors, a Linux library for reading sensor data.
Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
Copyright (C) 2007 Jean Delvare <khali@linux-fr.org>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -31,11 +32,11 @@ void (*sensors_fatal_error) (const char *proc, const char *err) =
sensors_default_fatal_error; sensors_default_fatal_error;
static const char *errorlist[] = { static const char *errorlist[] = {
/* Unknown error */ "sensors_strerror: Unknown error!", /* Invalid error code */ NULL,
/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name", /* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name",
/* SENSORS_ERR_NO_ENTRY */ "No such subfeature known", /* SENSORS_ERR_NO_ENTRY */ "No such subfeature known",
/* SENSORS_ERR_ACCESS */ "Can't read or write", /* SENSORS_ERR_NO_DEVS */ "No devices found",
/* SENSORS_ERR_PROC */ "Can't access sysfs file", /* SENSORS_ERR_KERNEL */ "Kernel interface error",
/* SENSORS_ERR_DIV_ZERO */ "Divide by zero", /* SENSORS_ERR_DIV_ZERO */ "Divide by zero",
/* SENSORS_ERR_CHIP_NAME */ "Can't parse chip name", /* SENSORS_ERR_CHIP_NAME */ "Can't parse chip name",
/* SENSORS_ERR_BUS_NAME */ "Can't parse bus name", /* SENSORS_ERR_BUS_NAME */ "Can't parse bus name",

View File

@@ -1,6 +1,7 @@
/* /*
error.h - Part of libsensors, a Linux library for reading sensor data. error.h - Part of libsensors, a Linux library for reading sensor data.
Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
Copyright (C) 2007 Jean Delvare <khali@linux-fr.org>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -22,8 +23,8 @@
#define SENSORS_ERR_WILDCARDS 1 /* Wildcard found in chip name */ #define SENSORS_ERR_WILDCARDS 1 /* Wildcard found in chip name */
#define SENSORS_ERR_NO_ENTRY 2 /* No such subfeature known */ #define SENSORS_ERR_NO_ENTRY 2 /* No such subfeature known */
#define SENSORS_ERR_ACCESS 3 /* Can't read or write */ #define SENSORS_ERR_NO_DEVS 3 /* No devices found */
#define SENSORS_ERR_PROC 4 /* Can't access /proc file */ #define SENSORS_ERR_KERNEL 4 /* Kernel interface error */
#define SENSORS_ERR_DIV_ZERO 5 /* Divide by zero */ #define SENSORS_ERR_DIV_ZERO 5 /* Divide by zero */
#define SENSORS_ERR_CHIP_NAME 6 /* Can't parse chip name */ #define SENSORS_ERR_CHIP_NAME 6 /* Can't parse chip name */
#define SENSORS_ERR_BUS_NAME 7 /* Can't parse bus name */ #define SENSORS_ERR_BUS_NAME 7 /* Can't parse bus name */

View File

@@ -33,7 +33,7 @@ int sensors_init(FILE *input)
int res; int res;
if (!sensors_init_sysfs()) if (!sensors_init_sysfs())
return -SENSORS_ERR_PROC; return -SENSORS_ERR_KERNEL;
if ((res = sensors_read_sysfs_bus()) || if ((res = sensors_read_sysfs_bus()) ||
(res = sensors_read_sysfs_chips())) (res = sensors_read_sysfs_chips()))
return res; return res;

View File

@@ -344,7 +344,7 @@ int sensors_init_sysfs(void)
static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) static int sensors_read_one_sysfs_chip(struct sysfs_device *dev)
{ {
int domain, bus, slot, fn; int domain, bus, slot, fn;
int err = -SENSORS_ERR_PARSE; int err = -SENSORS_ERR_KERNEL;
struct sysfs_attribute *attr, *bus_attr; struct sysfs_attribute *attr, *bus_attr;
char bus_path[SYSFS_PATH_MAX]; char bus_path[SYSFS_PATH_MAX];
sensors_chip_features entry; sensors_chip_features entry;
@@ -430,13 +430,13 @@ static int sensors_read_sysfs_chips_compat(void)
if (!(bus = sysfs_open_bus("i2c"))) { if (!(bus = sysfs_open_bus("i2c"))) {
if (errno && errno != ENOENT) if (errno && errno != ENOENT)
ret = -SENSORS_ERR_PROC; ret = -SENSORS_ERR_NO_DEVS;
goto exit0; goto exit0;
} }
if (!(devs = sysfs_get_bus_devices(bus))) { if (!(devs = sysfs_get_bus_devices(bus))) {
if (errno && errno != ENOENT) if (errno && errno != ENOENT)
ret = -SENSORS_ERR_PROC; ret = -SENSORS_ERR_NO_DEVS;
goto exit1; goto exit1;
} }
@@ -467,14 +467,14 @@ int sensors_read_sysfs_chips(void)
if (!(clsdevs = sysfs_get_class_devices(cls))) { if (!(clsdevs = sysfs_get_class_devices(cls))) {
if (errno && errno != ENOENT) if (errno && errno != ENOENT)
ret = -SENSORS_ERR_PROC; ret = -SENSORS_ERR_NO_DEVS;
goto exit; goto exit;
} }
dlist_for_each_data(clsdevs, clsdev, struct sysfs_class_device) { dlist_for_each_data(clsdevs, clsdev, struct sysfs_class_device) {
struct sysfs_device *dev; struct sysfs_device *dev;
if (!(dev = sysfs_get_classdev_device(clsdev))) { if (!(dev = sysfs_get_classdev_device(clsdev))) {
ret = -SENSORS_ERR_PROC; ret = -SENSORS_ERR_NO_DEVS;
goto exit; goto exit;
} }
if ((ret = sensors_read_one_sysfs_chip(dev))) if ((ret = sensors_read_one_sysfs_chip(dev)))
@@ -498,13 +498,13 @@ int sensors_read_sysfs_bus(void)
if (!(cls = sysfs_open_class("i2c-adapter"))) { if (!(cls = sysfs_open_class("i2c-adapter"))) {
if (errno && errno != ENOENT) if (errno && errno != ENOENT)
ret = -SENSORS_ERR_PROC; ret = -SENSORS_ERR_KERNEL;
goto exit0; goto exit0;
} }
if (!(clsdevs = sysfs_get_class_devices(cls))) { if (!(clsdevs = sysfs_get_class_devices(cls))) {
if (errno && errno != ENOENT) if (errno && errno != ENOENT)
ret = -SENSORS_ERR_PROC; ret = -SENSORS_ERR_KERNEL;
goto exit1; goto exit1;
} }
@@ -553,10 +553,10 @@ int sensors_read_sysfs_attr(const sensors_chip_name *name,
int res = fscanf(f, "%lf", value); int res = fscanf(f, "%lf", value);
fclose(f); fclose(f);
if (res != 1) if (res != 1)
return -SENSORS_ERR_PROC; return -SENSORS_ERR_KERNEL;
*value /= get_type_scaling(subfeature->type); *value /= get_type_scaling(subfeature->type);
} else } else
return -SENSORS_ERR_PROC; return -SENSORS_ERR_KERNEL;
return 0; return 0;
} }
@@ -574,7 +574,7 @@ int sensors_write_sysfs_attr(const sensors_chip_name *name,
fprintf(f, "%d", (int) value); fprintf(f, "%d", (int) value);
fclose(f); fclose(f);
} else } else
return -SENSORS_ERR_PROC; return -SENSORS_ERR_KERNEL;
return 0; return 0;
} }

View File

@@ -171,8 +171,8 @@ static int do_a_set(const sensors_chip_name *name)
int res; int res;
if ((res = sensors_do_chip_sets(name))) { if ((res = sensors_do_chip_sets(name))) {
if (res == -SENSORS_ERR_PROC) { if (res == -SENSORS_ERR_KERNEL) {
fprintf(stderr, "%s: %s for writing;\n", fprintf(stderr, "%s: %s;\n",
sprintf_chip_name(name), sprintf_chip_name(name),
sensors_strerror(res)); sensors_strerror(res));
fprintf(stderr, "Run as root?\n"); fprintf(stderr, "Run as root?\n");