bcp warning and comment

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
Well... again this warning

bcp.c: In function 'bcp_colfmt':
bcp.c:445: warning: suggest parentheses around && within ||

        /*
         * If there's a positive terminator length, we need a valid
terminator pointer.
         * If the terminator length is 0 or -1, then there's no terminator.
         */
        if (host_term == NULL && host_termlen > 0 || host_term != NULL
&& host_termlen == 0) {
                dbperror(dbproc, SYBEVDPT, 0);  /* "all
variable-length data must have either a length-prefix ..." */
                return FAIL;
        }

I removed a similar warning in dblib.c, see
http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/src/dblib/dblib.c?r1=1.343&r2=1.344&sortby=date
which IMHO is more readable.
Changing however following the same rules would lead to

        if (host_term == NULL ? host_termlen > 0 : host_termlen == 0) {

which is not consistent to the comment. What happen for instance if
host_termlen is -2 ? Also looking at comment is seems that bahavior is
the same if host_termlen is 0 or -1 but looking at the code if is -1
dbperror is not called. Probably code should be

        if (host_term == NULL && host_termlen > 0 || host_term != NULL
&& host_termlen <= 0) {

??

freddy77
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.