Skip to Content.
Sympa Menu

freetds - [freetds] bcp warning and comment

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] bcp warning and comment
  • Date: Tue, 10 Mar 2009 14:50:26 +0100

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




Archive powered by MHonArc 2.6.24.

Top of Page