{"thread":{"id":"1981","subject":"Re: [PATCH] Fix gcc-4 warning in accept() call","startedAt":"2005-09-29T23:11:35Z","lastAt":"2005-09-30T04:46:18Z","messageCount":3,"participants":["Horst von Brand","Pavel Roskin","H. Peter Anvin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"9519","messageId":"200509292311.j8TNBZDm022135@inti.inf.utfsm.cl","threadId":"1981","inReplyTo":"proski@gnu.org","subject":"Re: [PATCH] Fix gcc-4 warning in accept() call","fromName":"Horst von Brand","fromEmail":"vonbrand@inf.utfsm.cl","sentAt":"2005-09-29T23:11:35Z","receivedAt":"2005-09-29T23:11:35Z","isPatch":true,"sender":{"key":"vonbrand@inf.utfsm.cl","avatar":"https://avatars.githubusercontent.com/u/211384?v=4"},"body":"Pavel Roskin <proski@gnu.org> wrote:\n> Fix gcc-4 warning in accept() call\n> \n> gcc-4 warns about sign mismatch in pointers.  Third argument in accept()\n> is socklen_t, which is unsigned.  Since Linus doesn't like socklen_t\n> (see commit 7fa090844f7d1624c7d1ffc621aae6aec84a1110), let's use\n> unsigned int.\n> \n> Signed-off-by: Pavel Roskin <proski@gnu.org>\n> \n> diff --git a/daemon.c b/daemon.c\n> --- a/daemon.c\n> +++ b/daemon.c\n> @@ -459,7 +459,7 @@ static int serve(int port)\n>  \n>  \t\t\tif (FD_ISSET(sockfd, &fds)) {\n>  \t\t\t\tstruct sockaddr_storage ss;\n> -\t\t\t\tint sslen = sizeof(ss);\n> +\t\t\t\tunsigned int sslen = sizeof(ss);\n\nShouldn't this be size_t?\n\n>  \t\t\t\tint incoming = accept(sockfd, (struct sockaddr *)&ss, &sslen);\n>  \t\t\t\tif (incoming < 0) {\n>  \t\t\t\t\tswitch (errno) {\n-- \nDr. Horst H. von Brand                   User #22616 counter.li.org\nDepartamento de Informatica                     Fono: +56 32 654431\nUniversidad Tecnica Federico Santa Maria              +56 32 654239\nCasilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513\n"},{"id":"9527","messageId":"20050930000917.rrwggw4g0gogs8w4@webmail.spamcop.net","threadId":"1981","inReplyTo":"200509292311.j8TNBZDm022135@inti.inf.utfsm.cl","subject":"Re: [PATCH] Fix gcc-4 warning in accept() call","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-09-30T04:09:17Z","receivedAt":"2005-09-30T04:09:17Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Quoting Horst von Brand <vonbrand@inf.utfsm.cl>:\n\n> > +\t\t\t\tunsigned int sslen = sizeof(ss);\n>\n> Shouldn't this be size_t?\n\nNo.  That would actually break things on big-endian 64-bit platforms.\n\nYou can see \"info libc\" for the whole story.  My (limited!) understanding is\nthat it should be 32-bit for compatibility reasons, so socklen_t was a trick to\nfool size_t proponents from the POSIX committee :-)\n\n--\nRegards,\nPavel Roskin\n"},{"id":"9528","messageId":"433CC31A.9090808@zytor.com","threadId":"1981","inReplyTo":"20050930000917.rrwggw4g0gogs8w4@webmail.spamcop.net","subject":"Re: [PATCH] Fix gcc-4 warning in accept() call","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-30T04:46:18Z","receivedAt":"2005-09-30T04:46:18Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Pavel Roskin wrote:\n> Quoting Horst von Brand <vonbrand@inf.utfsm.cl>:\n> \n> \n>>>+\t\t\t\tunsigned int sslen = sizeof(ss);\n>>\n>>Shouldn't this be size_t?\n> \n> \n> No.  That would actually break things on big-endian 64-bit platforms.\n> \n> You can see \"info libc\" for the whole story.  My (limited!) understanding is\n> that it should be 32-bit for compatibility reasons, so socklen_t was a trick to\n> fool size_t proponents from the POSIX committee :-)\n> \n\nFormally it should be \"socklen_t\" or \"int\".  It should *not* be \n\"unsigned int\"!\n\n\t-hpa\n"}]}