#26080 [Opn->WFx]: Comparisons always true in xml.c

From: Date: Mon, 03 Nov 2003 19:09:30 +0000
Subject: #26080 [Opn->WFx]: Comparisons always true in xml.c
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-49900@lists.php.net to get a copy of this message
ID: 26080 Updated by: sniper@php.net Reported By: AxelLuttgens at swing dot be -Status: Open +Status: Wont fix Bug Type: Compile Warning Operating System: Darwin 7.0.0 (Panther) PHP Version: 4.3.3 Previous Comments: ------------------------------------------------------------------------ [2003-11-02 10:00:18] AxelLuttgens at swing dot be 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 this bug report at http://bugs.php.net/?id=26080&edit=1

« previous php.bugs (#49900) next »