Re: [xml] xmllib2-2.3.4 compiler warnings on QNX



On Thu, Mar 22, 2001 at 07:08:28PM -0600, stan boehm philips com wrote:
I do not know if anyone would be interested in these warnings, but
our policy is that all code must be error and warning free when run on
compilers from HP,  QNX Watcom and GNU.    The following list of
warnings was found by Watcom on QNX.   It is my experiance that
some of these could be serious bugs.  We would like to clean these up,
but feel that this is a job for xmlsoft, and that everyone would benifit.

In particular, the warnings like:

Warning! W124: Comparison result always 1
Warning! W124: Comparison result always 0

are often related to bugs that rarely happen, are hard to reproduce
and next to impossible to find.

These two warnings usually come about when you compare
unsigned ints to 0

      if ( unsigned int < 0 )   -  result is always 0

      if( unsigned int > 0 ) - result is always 1

Depending on the logic, these can be real nasty errors, or nothing at all.
      Warnings found by the Watcom compiler on QNX. like

      libxml2-2.3.4

entities.c(550): Warning! W124: Comparison result always 1
entities.c(550): Warning! W124: Comparison result always 1
   
   IS_CHAR used for an unsigned char value, harmless but fixeable
by casting it first to an unsigned int, but I would prefer to avoid
this because if the compiler can optimize it, in this case it should !

entities.c(759): Warning! W124: Comparison result always 1
entities.c(759): Warning! W124: Comparison result always 1

   same thing

parser.c(853): Warning! W201: Unreachable code
parser.c(864): Warning! W201: Unreachable code
parser.c(4846): Warning! W201: Unreachable code

   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...

HTMLparser.c(1597): Warning! W201: Unreachable code
HTMLparser.c(1604): Warning! W201: Unreachable code

  Lack of context in the report, this is now in comments ... hard to guess
what's the problem, and similar for the next warnings on HTMLparser.c

debugXML.c(1553): Warning! W200: 'nbargs' has been referenced but never assigned a value

  good, right this one is a bug, in the xmlShell() function
(which is used only if you use the --shell option of xmllint
 to browse your document in a interactive way :-)

xpath.c(2144): Warning! W201: Unreachable code
xpointer.c(1990): Warning! W201: Unreachable code

The xpath/xpointer modules are seriously changed since 2.3.4 the warning
are not really usable in this context.

xinclude.c(497): Warning! W124: Comparison result always 1

  This is again an use of IS_CHAR for an unsigned char
value, there is a TODO associated and the final way to handle
this case is dependant on the resolution of the W3C XML Core WG
on an xinclude issue reagarding encoding for included text resources

nanohttp.c(735): Warning! W113: Pointer type mismatch
nanoftp.c(1334): Warning! W113: Pointer type mismatch
nanoftp.c(1342): Warning! W113: Pointer type mismatch

 related top getsockname and getsockopt having different
signatures on different OSes, already debated in the list previously
no good way to solve the problem

nanoftp.c(140): Warning! W301: No prototype found for 'gethostname'

-------------------------------------
GETHOSTNAME(2)      Linux Programmer's Manual      GETHOSTNAME(2)

NAME
       gethostname, sethostname - get/set host name

SYNOPSIS
      #include <unistd.h>
-------------------------------------

nanoftp.c: line 33 to 35 :

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

 Please fix your config.h !

Warning! Redefinition of symbol 'xmlDebugDumpDTD_' in file 'debugXML.o' ignored.
Warning! Redefinition of symbol 'xmlBufferWriteChar_' in file 'tree.o' ignored.

orchis:~/XML -> grep xmlDebugDumpDTD *.c
debugXML.c:void xmlDebugDumpDTD(FILE *output, xmlDtdPtr dtd) {
orchis:~/XML -> grep -i xmlDebugDumpDTD *.c
debugXML.c:void xmlDebugDumpDtd(FILE *output, xmlDtdPtr dtd, int depth) {
debugXML.c:         xmlDebugDumpDtd(output, (xmlDtdPtr) node, depth);
debugXML.c:void xmlDebugDumpDTD(FILE *output, xmlDtdPtr dtd) {
orchis:~/XML ->

  What about using a compiler/linker supporting case sensitivity like
the C standard requires ?

cc warning: cc: cannot find library 'm'

  no libm ??? Well find one or change you options to not compile
the XPath/XPointer/XInclude modules and fix the makefiles !

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]