From:             AxelLuttgens at swing dot be
Operating system: Darwin 7.0.0 (Panther)
PHP version:      4.3.3
PHP Bug Type:     Compile Warning
Bug description:  Comparisons always true in xml.c

Description:
------------
Warnings while compiling xml.c with 4.3.3 as well as
php4-STABLE-200311020830:

ext/xml/xml.c: In function `xml_utf8_encode':
ext/xml/xml.c:489: warning: comparison is always true due to limited range
of data type
ext/xml/xml.c:493: warning: comparison is always true due to limited range
of data type

Relevant lines in xml.c are:

0455: static XML_Char *xml_utf8_encode(const char *s, int len, int
*newlen, const XML_Char *encoding)
0459:   unsigned short c;
0484:     if (c < 0x80) {
0486:     } else if (c < 0x800) {
0489:     } else if (c < 0x10000) {
0493:     } else if (c < 0x200000) {

On Darwin, a short seems to be a 32 bit value; comparisons at lines 0489
and 0493 are thus, indeed, always true.

Now, function xml_utf8_encode seems to be used only for implementing
utf8_encode(), thus for encoding iso-8559-1 into UTF-8.

So, one could be tempted to consider those warnings as "don't care" ones.

On the other hand, it seems that those warnings could be easily avoided
and thus allow for easier code maintenance.

HTH,
Axel


-- 
Edit bug report at http://bugs.php.net/?id=26080&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26080&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26080&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26080&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26080&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26080&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=26080&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26080&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26080&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26080&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26080&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26080&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26080&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26080&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26080&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26080&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26080&r=float

Reply via email to