Re: A couple of bugs in 0.91 with dblib bcp library

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
On Sat, 21 May 2011 08:35:29 +0100
"Thompson, William" <[email protected]> wrote:

Hi Bill, 

> -        assert(bufpos > 0);
> +        assert(bufpos >= 0);

Committed.  

> -         CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL);
> +         if (!(dbproc->bcpinfo))
> +                return 0;

Committed, except IMO the return code should be -1.  My reasoning is
the application should be able to detect a logical error, and the
function is misused if called twice without an intervening (and
successful) bcp_init().  

If the application is cavalier:

	bcp_done(dbproc);
	bcp_done(dbproc);

will now succeed and fail silently, in that order.  If it's careful:

	if( bcp_done(dbproc) == -1 ) {
		/* do error stuff */
	}
	if( bcp_done(dbproc) == -1 ) {
		/* do error stuff */
	}

it will break, as well it should, as the programmer should prefer.  

If that doesn't suit you, I'll #ifdef it for you.  

Regards, 

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