From 301e18b511b8cc3f126a5723902d5ba7ad778114 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 29 Sep 2007 11:57:37 +0000 Subject: [PATCH] libsensors: Notify the caller when writing a value fails. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4895 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + lib/sysfs.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 20894860..906b3666 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ lm-sensors CHANGES file SVN Makefile: Add sensors-conf-convert to make install + libsensors: Notify the caller when writing a value fails sensord: Log the error code on failure sensors: Fix spurious critical temperature alarm sensors-conf-convert: Add a short help text diff --git a/lib/sysfs.c b/lib/sysfs.c index 8317a932..f869cb13 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -577,9 +577,11 @@ int sensors_write_sysfs_attr(const sensors_chip_name *name, snprintf(n, NAME_MAX, "%s/%s", name->path, subfeature->name); if ((f = fopen(n, "w"))) { + int res; value *= get_type_scaling(subfeature->type); - fprintf(f, "%d", (int) value); - fclose(f); + res = fprintf(f, "%d", (int) value); + if (fclose(f) || res < 0) + return -SENSORS_ERR_ACCESS_W; } else return -SENSORS_ERR_KERNEL;