# [PATCH] Fix gcc-4 warning in accept() call

5 messages from 2005-09-29 to 2005-09-30. Participants: Pavel Roskin, Junio C Hamano, H. Peter Anvin.
Thread: https://gitlist.dev/t/1979

## Pavel Roskin, 2005-09-29 21:05

Subject: [PATCH] Fix gcc-4 warning in accept() call
Message-ID: <1128027901.24397.57.camel@dv>
URL: https://gitlist.dev/e/1128027901.24397.57.camel%40dv

```
Fix gcc-4 warning in accept() call

gcc-4 warns about sign mismatch in pointers.  Third argument in accept()
is socklen_t, which is unsigned.  Since Linus doesn't like socklen_t
(see commit 7fa090844f7d1624c7d1ffc621aae6aec84a1110), let's use
unsigned int.

Signed-off-by: Pavel Roskin <proski@gnu.org>

diff --git a/daemon.c b/daemon.c
--- a/daemon.c
+++ b/daemon.c
@@ -459,7 +459,7 @@ static int serve(int port)
 
 			if (FD_ISSET(sockfd, &fds)) {
 				struct sockaddr_storage ss;
-				int sslen = sizeof(ss);
+				unsigned int sslen = sizeof(ss);
 				int incoming = accept(sockfd, (struct sockaddr *)&ss, &sslen);
 				if (incoming < 0) {
 					switch (errno) {


-- 
Regards,
Pavel Roskin

```

## Junio C Hamano, 2005-09-30 05:49

Subject: Re: [PATCH] Fix gcc-4 warning in accept() call
Message-ID: <7vachv9kbq.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vachv9kbq.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <1128027901.24397.57.camel@dv>

```
Pavel Roskin <proski@gnu.org> writes:

> gcc-4 warns about sign mismatch in pointers.  Third argument in accept()
> is socklen_t, which is unsigned.  Since Linus doesn't like socklen_t
> (see commit 7fa090844f7d1624c7d1ffc621aae6aec84a1110), let's use
> unsigned int.

Based on the list comments, I'd drop this patch -- it appears
that gcc-4 warning is useless in this case.

```

## H. Peter Anvin, 2005-09-30 05:53

Subject: Re: [PATCH] Fix gcc-4 warning in accept() call
Message-ID: <433CD2E7.5090909@zytor.com>
URL: https://gitlist.dev/e/433CD2E7.5090909%40zytor.com
In-Reply-To: <7vachv9kbq.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:
> Pavel Roskin <proski@gnu.org> writes:
> 
> 
>>gcc-4 warns about sign mismatch in pointers.  Third argument in accept()
>>is socklen_t, which is unsigned.  Since Linus doesn't like socklen_t
>>(see commit 7fa090844f7d1624c7d1ffc621aae6aec84a1110), let's use
>>unsigned int.
> 
> Based on the list comments, I'd drop this patch -- it appears
> that gcc-4 warning is useless in this case.
> 

No, it's not.  The proper type, if you don't use socklen_t, is int, not 
unsigned int.

	-hpa

```

## H. Peter Anvin, 2005-09-30 05:58

Subject: Re: [PATCH] Fix gcc-4 warning in accept() call
Message-ID: <433CD412.8020409@zytor.com>
URL: https://gitlist.dev/e/433CD412.8020409%40zytor.com
In-Reply-To: <433CD2E7.5090909@zytor.com>

```
H. Peter Anvin wrote:
> Junio C Hamano wrote:
> 
>> Pavel Roskin <proski@gnu.org> writes:
>>
>>
>>> gcc-4 warns about sign mismatch in pointers.  Third argument in accept()
>>> is socklen_t, which is unsigned.  Since Linus doesn't like socklen_t
>>> (see commit 7fa090844f7d1624c7d1ffc621aae6aec84a1110), let's use
>>> unsigned int.
>>
>>
>> Based on the list comments, I'd drop this patch -- it appears
>> that gcc-4 warning is useless in this case.
>>
> 
> No, it's not.  The proper type, if you don't use socklen_t, is int, not 
> unsigned int.
> 

Apparently I'm wrong; socklen_t is unsigned int at least on glibc for 
i386.  I'll shut up now.

	-hpa

```

## Junio C Hamano, 2005-09-30 06:21

Subject: Re: [PATCH] Fix gcc-4 warning in accept() call
Message-ID: <7vvf0j849c.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vvf0j849c.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <433CD412.8020409@zytor.com>

```
"H. Peter Anvin" <hpa@zytor.com> writes:

> Apparently I'm wrong; socklen_t is unsigned int at least on glibc for 
> i386.  I'll shut up now.

Ah, I should shut up too.  Thanks for checking what we should
use.

```
