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