[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #33398] Compiler says 'Pointless Comparison'
From: |
Mike Kleshov |
Subject: |
[lwip-devel] [bug #33398] Compiler says 'Pointless Comparison' |
Date: |
Wed, 25 May 2011 09:30:11 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24 |
URL:
<http://savannah.nongnu.org/bugs/?33398>
Summary: Compiler says 'Pointless Comparison'
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: kleshov
Submitted on: Wed 25 May 2011 13:30:00 MSD
Category: TCP
Severity: 2 - Minor
Item Group: Compiler Warning
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release:
lwIP version: CVS Head
_______________________________________________________
Details:
Here is the snippet of code:
#ifndef TCP_LOCAL_PORT_RANGE_START
/* From http://www.iana.org/assignments/port-numbers:
"The Dynamic and/or Private Ports are those from 49152 through 65535" */
#define TCP_LOCAL_PORT_RANGE_START 0xc000
#define TCP_LOCAL_PORT_RANGE_END 0xffff
#endif
static u16_t port = TCP_LOCAL_PORT_RANGE_START;
again:
if (port++ >= TCP_LOCAL_PORT_RANGE_END) {
port = TCP_LOCAL_PORT_RANGE_START;
}
The line with the if statement causes a compiler warning: 'pointless integer
comparison, the result is always true.' The compiler is IAR for ColdFire. Size
of int is 32 bits.
The funny thing is when I change '>=' to '>', it says 'pointless integer
comparison, the result is always false.'
It could be a compiler bug. But still, wouldn't it make sense to change it to
(port++ == TCP_LOCAL_PORT_RANGE_END), like in UDP code? Presumably, port can
never be greater than 0xffff since it's u16_t.
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?33398>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
- [lwip-devel] [bug #33398] Compiler says 'Pointless Comparison',
Mike Kleshov <=