Remove Warnings caused by signed/unsigned integer comparaisons

This commit is contained in:
Thomas Bernard 2012-05-01 11:52:21 +02:00
parent ad95793e93
commit e42dfd3284
11 changed files with 41 additions and 27 deletions

View File

@ -2,6 +2,7 @@ $Id: Changelog.txt,v 1.278 2012/04/30 21:21:32 nanard Exp $
2012/04/30:
Clean up settings of CFLAGS in Makefile's
Remove Warnings caused by signed/unsigned integer comparaisons
Add UNUSED(arg) macro to remove unused argument warning.
Fix error handling in upnpevents.c (was causing segfault on Solaris !)

View File

@ -1,4 +1,4 @@
/* $Id: minissdp.c,v 1.33 2012/04/12 13:08:15 nanard Exp $ */
/* $Id: minissdp.c,v 1.34 2012/04/30 13:46:28 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2012 Thomas Bernard
@ -434,7 +434,12 @@ SendSSDPNotifies(int s, const char * host, unsigned short port,
known_service_types[i], (i==0?"":"1"),
uuidvalue, known_service_types[i], (i==0?"":"1"),
upnp_bootid, upnp_bootid, upnp_configid );
if(l>=sizeof(bufr))
if(l<0)
{
syslog(LOG_ERR, "SendSSDPNotifies() snprintf error");
continue;
}
if((unsigned int)l >= sizeof(bufr))
{
syslog(LOG_WARNING, "SendSSDPNotifies(): truncated output");
l = sizeof(bufr);

View File

@ -1,4 +1,4 @@
/* $Id: miniupnpd.c,v 1.153 2012/04/27 06:48:42 nanard Exp $ */
/* $Id: miniupnpd.c,v 1.154 2012/04/30 13:38:21 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2012 Thomas Bernard
@ -541,7 +541,7 @@ parselanaddr(struct lan_addr_s * lan_addr, const char * str)
while(*p && *p != '/' && !isspace(*p))
p++;
n = p - str;
if(!isdigit(str[0]) && n < sizeof(lan_addr->ifname))
if(!isdigit(str[0]) && n < (int)sizeof(lan_addr->ifname))
{
/* not starting with a digit : suppose it is an interface name */
memcpy(lan_addr->ifname, str, n);
@ -683,7 +683,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
}
else
{
for(i=0; i<num_options; i++)
for(i=0; i<(int)num_options; i++)
{
switch(ary_options[i].id)
{
@ -1387,13 +1387,13 @@ main(int argc, char * * argv)
/* Remove expired port mappings, based on UPnP IGD LeaseDuration
* or NAT-PMP lifetime) */
if(nextruletoclean_timestamp
&& (timeofday.tv_sec >= nextruletoclean_timestamp))
&& ((unsigned int)timeofday.tv_sec >= nextruletoclean_timestamp))
{
syslog(LOG_DEBUG, "cleaning expired Port Mappings");
get_upnp_rules_state_list(0);
}
if(nextruletoclean_timestamp
&& timeout.tv_sec >= (nextruletoclean_timestamp - timeofday.tv_sec))
&& ((unsigned int)timeout.tv_sec >= (nextruletoclean_timestamp - timeofday.tv_sec)))
{
timeout.tv_sec = nextruletoclean_timestamp - timeofday.tv_sec;
timeout.tv_usec = 0;

View File

@ -1,4 +1,4 @@
/* $Id: options.c,v 1.23 2012/02/05 00:29:49 nanard Exp $ */
/* $Id: options.c,v 1.25 2012/04/30 13:38:21 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* author: Ryan Wagoner
@ -17,7 +17,7 @@
struct option * ary_options = NULL;
static char * string_repo = NULL;
int num_options = 0;
unsigned int num_options = 0;
static const struct {
enum upnpconfigoptions id;
@ -72,7 +72,7 @@ readoptionsfile(const char * fname)
char *value;
char *t;
int linenum = 0;
int i;
unsigned int i;
enum upnpconfigoptions id;
size_t string_repo_len = 0;
size_t len;

View File

@ -1,4 +1,4 @@
/* $Id: options.h,v 1.18 2012/02/05 00:29:49 nanard Exp $ */
/* $Id: options.h,v 1.20 2012/04/30 13:38:21 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* author: Ryan Wagoner
@ -69,7 +69,7 @@ struct option
};
extern struct option * ary_options;
extern int num_options;
extern unsigned int num_options;
#endif

View File

@ -1,4 +1,4 @@
/* $Id: pfpinhole.c,v 1.16 2012/04/23 22:17:34 nanard Exp $ */
/* $Id: pfpinhole.c,v 1.17 2012/04/30 13:37:44 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2012 Thomas Bernard
@ -319,7 +319,7 @@ int clean_pinhole_list(unsigned int * next_timestamp)
syslog(LOG_INFO, "rule with label '%s' is not a IGD pinhole", pr.rule.label);
continue;
}
if(ts <= current_time) {
if(ts <= (unsigned int)current_time) {
syslog(LOG_INFO, "removing expired pinhole '%s'", pr.rule.label);
pr.action = PF_CHANGE_GET_TICKET;
if(ioctl(dev, DIOCCHANGERULE, &pr) < 0) {

View File

@ -1,4 +1,4 @@
/* $Id: upnpdescgen.c,v 1.64 2012/02/04 23:05:21 nanard Exp $ */
/* $Id: upnpdescgen.c,v 1.67 2012/04/30 14:03:52 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2012 Thomas Bernard
@ -824,7 +824,7 @@ strcat_int(char * str, int * len, int * tmplen, int i)
return str;
}
j = 0;
while(i && j < sizeof(buf)) {
while(i && j < (int)sizeof(buf)) {
buf[j++] = '0' + (i % 10);
i = i / 10;
}

View File

@ -220,7 +220,7 @@ error:
static void
upnp_event_notify_connect(struct upnp_event_notify * obj)
{
int i;
unsigned int i;
const char * p;
unsigned short port;
#ifdef ENABLE_IPV6

View File

@ -1,4 +1,4 @@
/* $Id: upnphttp.c,v 1.70 2012/04/25 22:28:34 nanard Exp $ */
/* $Id: upnphttp.c,v 1.71 2012/04/30 13:46:29 nanard Exp $ */
/* Project : miniupnp
* Website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* Author : Thomas Bernard
@ -287,7 +287,7 @@ checkCallbackURL(struct upnphttp * h)
char addrstr[48];
int ipv6;
const char * p;
int i;
unsigned int i;
if(h->req_CallbackOff <= 0 || h->req_CallbackLen < 8)
return 0;

View File

@ -210,7 +210,8 @@ int reload_from_lease_file()
continue;
}
*(desc++) = '\0';
timestamp = (unsigned int)atoi(p);
/*timestamp = (unsigned int)atoi(p);*/
timestamp = (unsigned int)strtoul(p, NULL, 10);
/* trim description */
while(isspace(*desc))
desc++;
@ -221,7 +222,7 @@ int reload_from_lease_file()
*(p--) = '\0';
if(timestamp > 0) {
if(timestamp <= current_time) {
if(timestamp <= (unsigned int)current_time) {
syslog(LOG_NOTICE, "already expired lease in lease file");
continue;
} else {
@ -366,7 +367,9 @@ upnp_get_redirection_infos(unsigned short eport, const char * protocol,
iaddr, iaddrlen, iport, desc, desclen,
rhost, rhostlen, &timestamp,
0, 0);
if(r == 0 && timestamp > 0 && timestamp > (current_time = time(NULL))) {
if(r == 0 &&
timestamp > 0 &&
timestamp > (unsigned int)(current_time = time(NULL))) {
*leaseduration = timestamp - current_time;
} else {
*leaseduration = 0;
@ -400,7 +403,7 @@ upnp_get_redirection_infos_by_index(int index,
else
{
current_time = time(NULL);
*leaseduration = (timestamp > current_time)
*leaseduration = (timestamp > (unsigned int)current_time)
? (timestamp - current_time)
: 0;
if(proto == IPPROTO_TCP)
@ -488,9 +491,9 @@ get_upnp_rules_state_list(int max_rules_number_target)
tmp->to_remove = 0;
if(timestamp > 0) {
/* need to remove this port mapping ? */
if(timestamp <= current_time)
if(timestamp <= (unsigned int)current_time)
tmp->to_remove = 1;
else if((nextruletoclean_timestamp <= current_time)
else if((nextruletoclean_timestamp <= (unsigned int)current_time)
|| (timestamp < nextruletoclean_timestamp))
nextruletoclean_timestamp = timestamp;
}
@ -775,7 +778,7 @@ upnp_get_pinhole_info(unsigned short uid,
if(leasetime) {
time_t current_time;
current_time = time(NULL);
if(timestamp > current_time)
if(timestamp > (unsigned int)current_time)
*leasetime = timestamp - current_time;
else
*leasetime = 0;

View File

@ -917,6 +917,11 @@ http://www.upnp.org/schemas/gw/WANIPConnection-v2.xsd">
}
bodylen = snprintf(body, bodyalloc, resp_start,
action, SERVICE_TYPE_WANIPC);
if(bodylen < 0)
{
SoapError(h, 501, "ActionFailed");
return;
}
memcpy(body+bodylen, list_start, sizeof(list_start));
bodylen += (sizeof(list_start) - 1);
@ -926,7 +931,7 @@ http://www.upnp.org/schemas/gw/WANIPConnection-v2.xsd">
for(i = 0; number > 0 && i < list_size; i++)
{
/* have a margin of 1024 bytes to store the new entry */
if(bodylen + 1024 > bodyalloc)
if((unsigned int)bodylen + 1024 > bodyalloc)
{
bodyalloc += 4096;
body = realloc(body, bodyalloc);