Fix small issues 06/21006/2
authorJose Bollo <jose.bollo@iot.bzh>
Fri, 12 Apr 2019 07:39:34 +0000 (09:39 +0200)
committerJose Bollo <jose.bollo@iot.bzh>
Fri, 12 Apr 2019 08:55:54 +0000 (10:55 +0200)
These issues was discovered by static analysis tool.

Change-Id: Iea75151c9b1f5e4cb139d2dc4e8a5c8bae5bb303
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
bindings/samples/hello3.c
src/afb-wsj1.c
src/sig-monitor.c

index af19478..ff7da61 100644 (file)
@@ -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;
                }
index 33e0d19..4080edf 100644 (file)
@@ -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;
index f15f214..7059281 100644 (file)
@@ -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;
 }
 
 /*