C++ Software written by someone else for server-to-server communication with MUD softwares, uses htons()
g++ is spitting out the following error:
error: conversion to ‘short unsigned int’ from ‘int’ may alter its value
That line of code:
sa.sin_port = htons( siteinfo->port );
Other relevant code:
struct sockaddr_in sa; unsigned short int port; /* Port the server listens on */
extern uint16_t htons (uint16_t __hostshort)
Checking typedef for unit16_t also using grep on the .ii file:
typedef unsigned short int __uint16_t;
All proper header files for htons() & network sockets (<sys/socket.h>, <arpa/inet.h> and <netinet/in.h>) included.
So, am I missing something here... or is this a bad warning from the compiler?
g++ flags in use:
W_FLAGS = -Wall -Werror -Wformat-security -Wshadow -Wpointer-arith -Wcast-align -Wredundant-decls -Wconversion -pedantic
CFLAGS = -g2 -Os $(W_FLAGS)
LFLAGS = -g2 -lz
make/g++/ln version infos:
$ make --version GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++ --version g++ (GCC) 4.4.1 Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ ln --version ln (GNU coreutils) 7.5 Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Mike Parker and David MacKenzie.


