Re: [xml] xmllib2-2.3.4 compiler warnings on QNX
- From: "Peter Jacobi" <pj walter-graphtek com>
- To: xml gnome org
- Subject: Re: [xml] xmllib2-2.3.4 compiler warnings on QNX
- Date: Fri, 23 Mar 2001 11:29:02 +0100
Hi Daniel, All,
if this is the use of COPY_BUF macro it seems, I don't see how
the compiler can detect an unreachable code in
#define COPY_BUF(l,b,i,v) \
if (l == 1) b[i++] = (xmlChar) v; \
else i += xmlCopyChar(l,&b[i],v)
int val = xmlParseStringCharRef(ctxt, &str);
if (val != 0) {
COPY_BUF(0,buffer,nbchars,val);
}
And I would appreciate insight on who's wrong there...
Calling COPY_BUF with first parameter (l) equal 0 will never process the
b[i++] = (xmlChar) v part.
I'm looking at a old sources (2.2.11), but I assume the documentation for
xmlCopyChar is out of sync, as the first parameter is referred to as
@len: pointer to the length of the char read (or zero)
On a related topic, the len parameter is hardly used in xmlCopyChar and
can probably be eliminated, along with the code branch computing len
when the parameter is zero:
xmlCopyChar(xmlChar *out, int val) {
if (val >= 0x80) {
xmlChar *savedout = out;
int bits;
if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6; }
else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; }
else {
xmlGenericError(xmlGenericErrorContext,
"Internal error, xmlCopyChar 0x%X out of bound\n", val);
return(0);
}
for ( ; bits >= 0; bits-= 6)
*out++= ((val >> bits) & 0x3F) | 0x80 ;
return (out - savedout);
}
*out = (xmlChar) val;
return 1;
}
Regards,
Peter Jacobi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]