[LEDE-DEV] [PATCH] libubox: Fix cppcheck warnings
Rosen Penev
rosenp at gmail.com
Tue Dec 13 21:47:54 PST 2016
Two formats and a memory leak.
Signed-off by: Rosen Penev <rosenp at gmail.com>
---
ulog.c | 2 +-
usock.c | 2 +-
utils.c | 3 +++
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/ulog.c b/ulog.c
index 985d366..e7fb081 100644
--- a/ulog.c
+++ b/ulog.c
@@ -91,7 +91,7 @@ static void ulog_kmsg(int priority, const char *fmt, va_list ap)
FILE *kmsg;
if ((kmsg = fopen("/dev/kmsg", "r+")) != NULL) {
- fprintf(kmsg, "<%u>", priority);
+ fprintf(kmsg, "<%d>", priority);
if (_ulog_ident)
fprintf(kmsg, "%s: ", _ulog_ident);
diff --git a/usock.c b/usock.c
index 0ce5390..0983806 100644
--- a/usock.c
+++ b/usock.c
@@ -247,7 +247,7 @@ const char *usock_port(int port)
if (port < 0 || port > 65535)
return NULL;
- snprintf(buffer, sizeof(buffer), "%u", port);
+ snprintf(buffer, sizeof(buffer), "%d", port);
return buffer;
}
diff --git a/utils.c b/utils.c
index 91dd71e..a8bc5c5 100644
--- a/utils.c
+++ b/utils.c
@@ -44,7 +44,10 @@ void *__calloc_a(size_t len, ...)
ptr = calloc(1, alloc_len);
if (!ptr)
+ {
+ va_end(ap);
return NULL;
+ }
alloc_len = 0;
foreach_arg(ap, cur_addr, cur_len, &ret, len) {
*cur_addr = &ptr[alloc_len];
--
2.8.3
More information about the Lede-dev
mailing list