Re: [PATCH] useless CHECK_NULP in dblib.c:tdsdbopen()
"Craig A. Berry" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
On Mar 23, 2009, at 6:09 AM, Frediano Ziglio wrote: > 2009/3/21 James K. Lowden <[email protected]>: >> Craig A. Berry wrote: >>>>> if (!(server)) { dbperror(dbproc, 20176, 0, "dbopen", >>>>> (int) 2); >>>>> return (void *)0; }; >>>>> >>>>> The check isn't against "random data from the stack"; it's against >>>>> the >>>>> server argument. >>>> >>>> I really wasn't clear (and hadn't looked at the macro long enough >>>> to >>>> understand it). It's dbproc, not server, that has been "fetched >>>> but >>>> not initialized". > I think that a > > DBPROCESS *dbproc = NULL; > > is better... so we check parameter and in case server is NULL we call > dbperror with proper DBPROCESS (which is NULL). > I don't understand why gcc don't detect this... Good question. The docs here: <http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Warning-Options.html#Warning-Options > say that -Wall implies -Wuninitialized only when -01 is in effect, and furthermore that -Wuninitialized only works when -O is present because without optimization the compiler doesn't have the necessary information to detect uninitialized values. Not sure if that's the reason for FreeTDS. ________________________________________ Craig A. Berry mailto:[email protected] "... getting out of a sonnet is much more difficult than getting in." Brad Leithauser