Strange warning with clang and 9RC1 (ntohs)

From: Axel Gonzalez <loox_at_e-shell.net>
Date: Mon, 31 Oct 2011 18:35:18 -0600
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.
Received on Tue Nov 01 2011 - 00:35:12 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:19 UTC