diff options
| author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-02-26 11:08:55 +0100 | 
|---|---|---|
| committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-02-26 11:44:38 +0100 | 
| commit | dff374d5f393a6b4bec4877aa1c35ceb70e82843 (patch) | |
| tree | 64e0e7804f1ee19834f019478c7199e83512c726 /src/irmd | |
| parent | 63633c57b1e2573890fa627dd63f7c79ee5777b8 (diff) | |
| download | ouroboros-dff374d5f393a6b4bec4877aa1c35ceb70e82843.tar.gz ouroboros-dff374d5f393a6b4bec4877aa1c35ceb70e82843.zip | |
lib, irmd: Address Dimitri's comments
This addresses several comments Dimitri had on the sockets layer code.
Diffstat (limited to 'src/irmd')
| -rw-r--r-- | src/irmd/main.c | 10 | 
1 files changed, 6 insertions, 4 deletions
| 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 <sys/socket.h>  #include <sys/un.h>  #include <stdlib.h> +#include <errno.h>  #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); | 
