Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Nov 2011 07:56:51 +0100
From:      Roman Divacky <rdivacky@freebsd.org>
To:        Axel Gonzalez <loox@e-shell.net>
Cc:        freebsd-current@freebsd.org
Subject:   Re: Strange warning with clang and 9RC1 (ntohs)
Message-ID:  <20111101065651.GA27751@freebsd.org>
In-Reply-To: <1562351.Ln9lEKl2rv@moonlight.e-shell.tk>
References:  <1562351.Ln9lEKl2rv@moonlight.e-shell.tk>

next in thread | previous in thread | raw e-mail | index | archive | help
It doesnt warn here. Can you check with "clang -E" what the ntohs()
is being expanded to and what the real prototype is?

On Mon, Oct 31, 2011 at 06:35:18PM -0600, Axel Gonzalez wrote:
> 
> I'm getting an strange warning whem compiling with clang (from base) on RC1.
> 
> This warning doesn't appear with 8.X and clang from ports.
> 
> The warning is strange because ntohs is not int:
> 
> uint16_t
>      ntohs(uint16_t netshort);
> 
> 
> Any insight would be appreciated, thanks in advance!
> 
> A
> 
> ****
> 
> % gcc -Wall -o ntohs ntohs.c
> % clang -Wall -o ntohs ntohs.c
> ntohs.c:8:12: warning: conversion specifies type 'unsigned short' but the 
> argument has type
>       'int' [-Wformat]
>         printf("%hu\n", ntohs(x));
>                 ~~^     ~~~~~~~~
>                 %d                                                                              
> 1 warning generated.
>  
>  
> #include <stdio.h>
> #include <netinet/in.h>
>  
> int main()
> {
>         uint16_t x = htons(80);
>         printf("%hu\n", (uint16_t)ntohs(x));
>         printf("%hu\n", ntohs(x));
>         return (0);
> }
>  
> 
> -- 
> Mon Oct 31 18:02:13 2011 GMT
> 
>         **
>          ****
>           *****
>           ******
>           ******
>           *****
>          ****
>         **      5.
> 
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111101065651.GA27751>