C warning that I can't seem to track down

John Vetterli jvetterli-zC6tqtfhjqE at public.gmane.org
Tue Aug 8 15:15:25 UTC 2006


On Tue, 8 Aug 2006, Alex Beamish wrote:
> On 8/8/06, bob <ican-rZHaEmXdJNJWk0Htik3J/w at public.gmane.org> wrote:
>> int length;
>> ...
>> if(getsockname(s, (struct sockaddr *)&sin, &length))
>> socketUtils.c:259: warning: pointer targets in passing argument 3 of
>> 'getsockname' differ in signedness
> that getsockname has the following prototype:
> int getsockname(int s , struct sockaddr * name , socklen_t * namelen );
> so you need to cast length to a pointer to socklen_t, even if that works out
> to an int in the end. Change your line to
> if(getsockname(s, (struct sockaddr *)&sin, (socklen_t *)&length))

It might be preferable to just declare length as a socklen_t.  That way, 
if you ever move to a platform where socklen_t is a different size than 
int, you're still covered.

HTH
JV
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list