2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-31 06:15:15 +00:00

Consolidate strdup calls in sensors_get_label (patch from George Spelvin).

There were multiple in-line calls that then fell through to
a common exit.  Instead, set up a pointer to the original
strings, and have a single strdup in the common code.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5747 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2009-06-30 20:47:53 +00:00
parent 408111412b
commit b3f39211b2

View File

@@ -178,7 +178,7 @@ char *sensors_get_label(const sensors_chip_name *name,
for (chip = NULL; (chip = sensors_for_all_config_chips(name, chip));)
for (i = 0; i < chip->labels_count; i++)
if (!strcmp(feature->name, chip->labels[i].name)) {
label = strdup(chip->labels[i].value);
label = chip->labels[i].value;
goto sensors_get_label_exit;
}
@@ -191,15 +191,16 @@ char *sensors_get_label(const sensors_chip_name *name,
if (i > 0) {
/* i - 1 to strip the '\n' at the end */
buf[i - 1] = 0;
label = strdup(buf);
label = buf;
goto sensors_get_label_exit;
}
}
/* No label, return the feature name instead */
label = strdup(feature->name);
label = feature->name;
sensors_get_label_exit:
label = strdup(label);
if (!label)
sensors_fatal_error(__func__, "Allocating label text");
return label;