From 036629f2e6306f3e2bb520bc58565d9a9db28a45 Mon Sep 17 00:00:00 2001 From: Jose Bollo Date: Fri, 12 Apr 2019 09:39:34 +0200 Subject: [PATCH] Fix small issues These issues was discovered by static analysis tool. Change-Id: Iea75151c9b1f5e4cb139d2dc4e8a5c8bae5bb303 Signed-off-by: Jose Bollo --- bindings/samples/hello3.c | 1 + src/afb-wsj1.c | 6 ++++-- src/sig-monitor.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bindings/samples/hello3.c b/bindings/samples/hello3.c index af194785..ff7da61a 100644 --- a/bindings/samples/hello3.c +++ b/bindings/samples/hello3.c @@ -913,6 +913,7 @@ static void api (afb_req_t request) } sapi->api = afb_api_new_api(api, apiname, NULL, 1, apipreinit, NULL); if (!sapi->api) { + free(sapi); afb_req_reply_f(request, NULL, "cant-create", "%m"); goto end; } diff --git a/src/afb-wsj1.c b/src/afb-wsj1.c index 33e0d195..4080edf2 100644 --- a/src/afb-wsj1.c +++ b/src/afb-wsj1.c @@ -307,11 +307,13 @@ static struct afb_wsj1_msg *wsj1_msg_make(struct afb_wsj1 *wsj1, char *text, siz /* scan */ n = wsj1_msg_scan(text, items); - if (n < 0) + if (n <= 0) goto bad_header; /* scans code: 2|3|4|5 */ - if (items[0][1] != 1) goto bad_header; + if (items[0][1] != 1) + goto bad_header; + switch (text[items[0][0]]) { case '2': msg->code = CALL; break; case '3': msg->code = RETOK; break; diff --git a/src/sig-monitor.c b/src/sig-monitor.c index f15f214e..70592812 100644 --- a/src/sig-monitor.c +++ b/src/sig-monitor.c @@ -154,7 +154,7 @@ static inline int timeout_create() rc = timer_create(CLOCK_THREAD_CPUTIME_ID, &sevp, &thread_timerid); thread_timer_set = !rc; } - return 0; + return rc; } /* -- 2.16.6