[PATCH] lib: acpica: explicitly set buffer to NULL to remove cppcheck warning
Colin King
colin.king at canonical.com
Fri May 15 10:36:24 UTC 2015
From: Colin Ian King <colin.king at canonical.com>
cppcheck isn't quite so smart as CoverityScan so it continues to complain
about a potential free issue as a false positive. I've taken the liberty
to explicity set buffer to NULL to make the code clearer and this helps
cppcheck to understand the flow of control better.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/acpica/fwts_acpica.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c
index 4a6baf6..9bfd0ae 100644
--- a/src/acpica/fwts_acpica.c
+++ b/src/acpica/fwts_acpica.c
@@ -452,8 +452,10 @@ void fwts_acpica_vprintf(const char *fmt, va_list args)
buffer = malloc(buffer_len);
if (buffer)
strcpy(buffer, tmp);
- else
+ else {
+ buffer = NULL;
buffer_len = 0;
+ }
} else {
char *new_buf;
@@ -464,11 +466,12 @@ void fwts_acpica_vprintf(const char *fmt, va_list args)
strcat(buffer, tmp);
} else {
free(buffer);
+ buffer = NULL;
buffer_len = 0;
}
}
- if (buffer_len && index(buffer, '\n') != NULL) {
+ if (buffer && index(buffer, '\n') != NULL) {
fwts_log_info(fwts_acpica_fw, "%s", buffer);
free(buffer);
buffer_len = 0;
--
2.1.4
More information about the fwts-devel
mailing list