Fix various SVACE complaints 47/224547/2
authorMateusz Majewski <m.majewski2@samsung.com>
Tue, 11 Feb 2020 10:09:19 +0000 (11:09 +0100)
committerMateusz Majewski <m.majewski2@samsung.com>
Tue, 11 Feb 2020 11:15:27 +0000 (12:15 +0100)
Change-Id: I910508371c5c728b00aec5c749fb11c8526a1bfb

src/shared/logcommon.c

index ac4fb66..8c4b6c8 100644 (file)
@@ -139,6 +139,7 @@ static void init_pipe_msg_control(struct msghdr *msg_hdr, int pipefd)
        assert(msg_hdr);
 
        struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg_hdr);
+       assert(cmsg);
        *cmsg = g_pipe_msg_ctl;
        memcpy(CMSG_DATA(cmsg), &pipefd, sizeof(pipefd));
 }
@@ -258,7 +259,8 @@ int recv_dlog_reply(int sockfd, int request, void **data, int *datalen)
        ||  header.result != DLOG_REQ_RESULT_OK)
                return -EINVAL;
 
-       *datalen = header.length - sizeof header;
+       // Cast necessary to avoid unsigned math, as both args are unsigned
+       *datalen = (int)header.length - (int)sizeof header;
        if (*datalen < 0)
                return -EINVAL;
        if (*datalen == 0) {