mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-02 07:15:39 +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:
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
error.c - Part of libsensors, a Linux library for reading sensor data.
|
||||
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
|
||||
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;
|
||||
|
||||
static const char *errorlist[] = {
|
||||
/* Unknown error */ "sensors_strerror: Unknown error!",
|
||||
/* Invalid error code */ NULL,
|
||||
/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name",
|
||||
/* SENSORS_ERR_NO_ENTRY */ "No such subfeature known",
|
||||
/* SENSORS_ERR_ACCESS */ "Can't read or write",
|
||||
/* SENSORS_ERR_PROC */ "Can't access sysfs file",
|
||||
/* SENSORS_ERR_NO_DEVS */ "No devices found",
|
||||
/* SENSORS_ERR_KERNEL */ "Kernel interface error",
|
||||
/* SENSORS_ERR_DIV_ZERO */ "Divide by zero",
|
||||
/* SENSORS_ERR_CHIP_NAME */ "Can't parse chip name",
|
||||
/* SENSORS_ERR_BUS_NAME */ "Can't parse bus name",
|
||||
|
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
error.h - Part of libsensors, a Linux library for reading sensor data.
|
||||
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
|
||||
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_NO_ENTRY 2 /* No such subfeature known */
|
||||
#define SENSORS_ERR_ACCESS 3 /* Can't read or write */
|
||||
#define SENSORS_ERR_PROC 4 /* Can't access /proc file */
|
||||
#define SENSORS_ERR_NO_DEVS 3 /* No devices found */
|
||||
#define SENSORS_ERR_KERNEL 4 /* Kernel interface error */
|
||||
#define SENSORS_ERR_DIV_ZERO 5 /* Divide by zero */
|
||||
#define SENSORS_ERR_CHIP_NAME 6 /* Can't parse chip name */
|
||||
#define SENSORS_ERR_BUS_NAME 7 /* Can't parse bus name */
|
||||
|
@@ -33,7 +33,7 @@ int sensors_init(FILE *input)
|
||||
int res;
|
||||
|
||||
if (!sensors_init_sysfs())
|
||||
return -SENSORS_ERR_PROC;
|
||||
return -SENSORS_ERR_KERNEL;
|
||||
if ((res = sensors_read_sysfs_bus()) ||
|
||||
(res = sensors_read_sysfs_chips()))
|
||||
return res;
|
||||
|
20
lib/sysfs.c
20
lib/sysfs.c
@@ -344,7 +344,7 @@ int sensors_init_sysfs(void)
|
||||
static int sensors_read_one_sysfs_chip(struct sysfs_device *dev)
|
||||
{
|
||||
int domain, bus, slot, fn;
|
||||
int err = -SENSORS_ERR_PARSE;
|
||||
int err = -SENSORS_ERR_KERNEL;
|
||||
struct sysfs_attribute *attr, *bus_attr;
|
||||
char bus_path[SYSFS_PATH_MAX];
|
||||
sensors_chip_features entry;
|
||||
@@ -430,13 +430,13 @@ static int sensors_read_sysfs_chips_compat(void)
|
||||
|
||||
if (!(bus = sysfs_open_bus("i2c"))) {
|
||||
if (errno && errno != ENOENT)
|
||||
ret = -SENSORS_ERR_PROC;
|
||||
ret = -SENSORS_ERR_NO_DEVS;
|
||||
goto exit0;
|
||||
}
|
||||
|
||||
if (!(devs = sysfs_get_bus_devices(bus))) {
|
||||
if (errno && errno != ENOENT)
|
||||
ret = -SENSORS_ERR_PROC;
|
||||
ret = -SENSORS_ERR_NO_DEVS;
|
||||
goto exit1;
|
||||
}
|
||||
|
||||
@@ -467,14 +467,14 @@ int sensors_read_sysfs_chips(void)
|
||||
|
||||
if (!(clsdevs = sysfs_get_class_devices(cls))) {
|
||||
if (errno && errno != ENOENT)
|
||||
ret = -SENSORS_ERR_PROC;
|
||||
ret = -SENSORS_ERR_NO_DEVS;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
dlist_for_each_data(clsdevs, clsdev, struct sysfs_class_device) {
|
||||
struct sysfs_device *dev;
|
||||
if (!(dev = sysfs_get_classdev_device(clsdev))) {
|
||||
ret = -SENSORS_ERR_PROC;
|
||||
ret = -SENSORS_ERR_NO_DEVS;
|
||||
goto exit;
|
||||
}
|
||||
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 (errno && errno != ENOENT)
|
||||
ret = -SENSORS_ERR_PROC;
|
||||
ret = -SENSORS_ERR_KERNEL;
|
||||
goto exit0;
|
||||
}
|
||||
|
||||
if (!(clsdevs = sysfs_get_class_devices(cls))) {
|
||||
if (errno && errno != ENOENT)
|
||||
ret = -SENSORS_ERR_PROC;
|
||||
ret = -SENSORS_ERR_KERNEL;
|
||||
goto exit1;
|
||||
}
|
||||
|
||||
@@ -553,10 +553,10 @@ int sensors_read_sysfs_attr(const sensors_chip_name *name,
|
||||
int res = fscanf(f, "%lf", value);
|
||||
fclose(f);
|
||||
if (res != 1)
|
||||
return -SENSORS_ERR_PROC;
|
||||
return -SENSORS_ERR_KERNEL;
|
||||
*value /= get_type_scaling(subfeature->type);
|
||||
} else
|
||||
return -SENSORS_ERR_PROC;
|
||||
return -SENSORS_ERR_KERNEL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -574,7 +574,7 @@ int sensors_write_sysfs_attr(const sensors_chip_name *name,
|
||||
fprintf(f, "%d", (int) value);
|
||||
fclose(f);
|
||||
} else
|
||||
return -SENSORS_ERR_PROC;
|
||||
return -SENSORS_ERR_KERNEL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -171,8 +171,8 @@ static int do_a_set(const sensors_chip_name *name)
|
||||
int res;
|
||||
|
||||
if ((res = sensors_do_chip_sets(name))) {
|
||||
if (res == -SENSORS_ERR_PROC) {
|
||||
fprintf(stderr, "%s: %s for writing;\n",
|
||||
if (res == -SENSORS_ERR_KERNEL) {
|
||||
fprintf(stderr, "%s: %s;\n",
|
||||
sprintf_chip_name(name),
|
||||
sensors_strerror(res));
|
||||
fprintf(stderr, "Run as root?\n");
|
||||
|
Reference in New Issue
Block a user