From 6868367764b40ae34a4158b41ddc8d3e17d507ec Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 30 Jun 2009 20:52:20 +0000 Subject: [PATCH] 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 --- lib/access.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/access.c b/lib/access.c index d231dffb..92e63ddf 100644 --- a/lib/access.c +++ b/lib/access.c @@ -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 */