sensors_get_label: Merge pathname and label buffers (patch from

George Spelvin).
    
The lifetimes of the path and label name buffers are
disjoint, so a single buffer can be used for both purposes.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5748 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2009-06-30 20:52:20 +00:00
1 parent b3f39211b2
commit 6868367764
1 file changed
+4 -4
+4 -4
View File
@@ -168,7 +168,7 @@ char *sensors_get_label(const sensors_chip_name *name,
{
char *label;
const sensors_chip *chip;
char buf[128], path[PATH_MAX];
char buf[PATH_MAX];
FILE *f;
int i;
@@ -183,10 +183,10 @@ char *sensors_get_label(const sensors_chip_name *name,
}
/* No user specified label, check for a _label sysfs file */
snprintf(path, PATH_MAX, "%s/%s_label", name->path, feature->name);
snprintf(buf, PATH_MAX, "%s/%s_label", name->path, feature->name);
if ((f = fopen(path, "r"))) {
i = fread(buf, 1, sizeof(buf) - 1, f);
if ((f = fopen(buf, "r"))) {
i = fread(buf, 1, sizeof(buf), f);
fclose(f);
if (i > 0) {
/* i - 1 to strip the '\n' at the end */