From dff374d5f393a6b4bec4877aa1c35ceb70e82843 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Fri, 26 Feb 2016 11:08:55 +0100 Subject: lib, irmd: Address Dimitri's comments This addresses several comments Dimitri had on the sockets layer code. --- src/irmd/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/irmd/main.c') diff --git a/src/irmd/main.c b/src/irmd/main.c index d2aa6cd9..137b2b61 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -29,6 +29,7 @@ #include #include #include +#include #define BUF_SIZE 256 @@ -55,10 +56,10 @@ int main() if (sockfd < 0) return -1; - buf = malloc(sizeof(buf) * BUF_SIZE); - if (!buf) { + buf = malloc(sizeof(*buf) * BUF_SIZE); + if (buf == NULL) { LOG_ERR("Cannot allocate memory"); - return -1; + return -ENOMEM; } while (true) { @@ -70,6 +71,7 @@ int main() cli_sockfd = accept(sockfd, 0, 0); if (cli_sockfd < 0) { LOG_ERR("Cannot accept new connection"); + continue; } count = read(cli_sockfd, buf, BUF_SIZE); @@ -77,7 +79,7 @@ int main() buffer.size = count; buffer.data = buf; msg = deserialize_irm_msg(&buffer); - if (!msg) + if (msg == NULL) continue; LOG_DBG("Got message code %d", msg->code); -- cgit v1.2.3