[freetds] [PATCH] useless CHECK_NULP in dblib.c:tdsdbopen()

Craig A. Berry craigberry at mac.com
Mon Mar 23 08:19:33 EDT 2009


On Mar 23, 2009, at 6:09 AM, Frediano Ziglio wrote:

> 2009/3/21 James K. Lowden <jklowden at freetds.org>:
>> 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:craigberry at mac.com

"... getting out of a sonnet is much more
  difficult than getting in."
                  Brad Leithauser



More information about the FreeTDS mailing list