{"thread":{"id":"33942","subject":"[PATCH] daemon.c:handle: Remove unneeded check for null pointer.","startedAt":"2013-05-26T19:54:40Z","lastAt":"2013-05-26T19:54:40Z","messageCount":1,"participants":["Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"218579","messageId":"1369598080-9561-1-git-send-email-stefanbeller@googlemail.com","threadId":"33942","inReplyTo":null,"subject":"[PATCH] daemon.c:handle: Remove unneeded check for null pointer.","fromName":"Stefan Beller","fromEmail":"stefanbeller@googlemail.com","sentAt":"2013-05-26T19:54:40Z","receivedAt":"2013-05-26T19:54:40Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"The handle function has the signature\nstatic void handle(int incoming, struct sockaddr *addr, socklen_t addrlen);\nso the addr pointer may be passed as null syntactically.\n\nHowever there is just one place in daemon.c, which calls the handle\nfunction in function service_loop in daemon.c:1044:\nhandle(incoming, &ss.sa, sslen);\nso there is always a valid pointer for the sockaddr passed to the handle\nfunction.\n\nThe code in question was to its place in f9c87be6, when following the\ngit blame it originates from 5b276ee4.\nThat commit 5b276ee4 also seems to copy around the ipv6 code block\nand the sockaddr pointer check being null is introduced.\nHowever that commit has already a redundant check on addr being a\nnull pointer before.\n\nI am including the authors of said patches to the receivers.\n---\n daemon.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/daemon.c b/daemon.c\nindex 6aeddcb..5e48c1e 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -760,7 +760,7 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)\n \t\tsnprintf(portbuf, sizeof(portbuf), \"REMOTE_PORT=%d\",\n \t\t    ntohs(sin_addr->sin_port));\n #ifndef NO_IPV6\n-\t} else if (addr && addr->sa_family == AF_INET6) {\n+\t} else if (addr->sa_family == AF_INET6) {\n \t\tstruct sockaddr_in6 *sin6_addr = (void *) addr;\n \n \t\tchar *buf = addrbuf + 12;\n-- \n1.8.3\n"}]}