Make virSysfsGet*ValueString() functions use virSysfsGetValueString()
then we have one more allocation, but the code is cleaner and it's
easier to make sure the behaviour (e.g. return -2 on missing file)
isn't changed by mistake.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/util/virsysfs.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c
index 8d3665377e8c..a8550bbfbc26 100644
--- a/src/util/virsysfs.c
+++ b/src/util/virsysfs.c
@@ -178,19 +178,11 @@ virSysfsGetCpuValueString(unsigned int cpu,
char *path = NULL;
int ret = -1;
- if (virAsprintf(&path, "%s/cpu/cpu%u/%s", sysfs_system_path, cpu, file)
< 0)
+ if (virAsprintf(&path, "cpu/cpu%u/%s", cpu, file) < 0)
return -1;
- if (!virFileExists(path)) {
- ret = -2;
- goto cleanup;
- }
+ ret = virSysfsGetValueString(path, value);
- if (virFileReadAll(path, VIR_SYSFS_VALUE_MAXLEN, value) < 0)
- goto cleanup;
-
- ret = 0;
- cleanup:
VIR_FREE(path);
return ret;
}
--
2.12.2