[PATCH] lib: fwts_cpu: only assign a string if it has not yet been assigned
Colin King
colin.king at canonical.com
Mon Jun 10 11:10:36 UTC 2019
From: Colin Ian King <colin.king at canonical.com>
This just cleans up some static analysis warnings
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/lib/src/fwts_cpu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
index e866d1dc..71e0e877 100644
--- a/src/lib/src/fwts_cpu.c
+++ b/src/lib/src/fwts_cpu.c
@@ -151,7 +151,7 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(int which_cpu)
found = true;
- if (!strncmp(buffer, "vendor_id", 9)) {
+ if (!cpu->vendor_id && !strncmp(buffer, "vendor_id", 9)) {
cpu->vendor_id = strdup(ptr);
continue;
}
@@ -159,7 +159,7 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(int which_cpu)
sscanf(ptr, "%d", &cpu->x86);
continue;
}
- if (!strncmp(buffer, "model name", 10)) {
+ if (!cpu->model_name && !strncmp(buffer, "model name", 10)) {
cpu->model_name = strdup(ptr);
continue;
}
@@ -171,7 +171,7 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(int which_cpu)
sscanf(ptr, "%d", &cpu->stepping);
continue;
}
- if (!strncmp(buffer, "flags", 5)) {
+ if (!cpu->flags && !strncmp(buffer, "flags", 5)) {
cpu->flags = strdup(ptr);
continue;
}
--
2.20.1
More information about the fwts-devel
mailing list