Re: new compiler warnings

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: new compiler warnings
Дата
Msg-id 25087.1318974750@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: new compiler warnings  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
I wrote:
> I think a large fraction of the -Waddress warnings are coming from
> this line in the heap_getattr macro:
>     AssertMacro((tup) != NULL), \
> Seems to me we could just lose that test and be no worse off, since
> the macro is surely gonna dump core anyway on a null pointer.

Actually, all the ones in the backend are coming from that, so I went
ahead and removed that.

> But some of the remaining -Waddress warnings are not so painless to
> get rid of.  Ultimately we might have to add -Wno-address to the
> default CFLAGS.

The remaining -Waddress warnings are all from applying PQExpBufferBroken
to the address of a local variable.  We could silence them along these
lines:


*** src/interfaces/libpq/pqexpbuffer.h.orig    Thu Apr 28 16:07:00 2011
--- src/interfaces/libpq/pqexpbuffer.h    Tue Oct 18 17:46:18 2011
***************
*** 60,65 ****
--- 60,73 ----     ((str) == NULL || (str)->maxlen == 0)  /*------------------------
+  * Same, but for use when using a static or local PQExpBufferData struct.
+  * For that, a null-pointer test is useless and may draw compiler warnings.
+  *------------------------
+  */
+ #define PQExpBufferDataBroken(buf)    \
+     ((buf).maxlen == 0)
+ 
+ /*------------------------  * Initial size of the data buffer in a PQExpBuffer.  * NB: this must be large enough to
holderror messages that might  * be returned by PQrequestCancel().
 
*** src/interfaces/libpq/fe-connect.c.orig    Sun Sep 25 18:43:15 2011
--- src/interfaces/libpq/fe-connect.c    Tue Oct 18 17:46:58 2011
***************
*** 829,835 ****     PQconninfoOption *connOptions;      initPQExpBuffer(&errorBuf);
!     if (PQExpBufferBroken(&errorBuf))         return NULL;            /* out of memory already :-( */     connOptions
=conninfo_parse("", &errorBuf, true);     termPQExpBuffer(&errorBuf);
 
--- 829,835 ----     PQconninfoOption *connOptions;      initPQExpBuffer(&errorBuf);
!     if (PQExpBufferDataBroken(errorBuf))         return NULL;            /* out of memory already :-( */
connOptions= conninfo_parse("", &errorBuf, true);     termPQExpBuffer(&errorBuf);
 
***************
*** 3967,3973 ****     if (errmsg)         *errmsg = NULL;            /* default */     initPQExpBuffer(&errorBuf);
!     if (PQExpBufferBroken(&errorBuf))         return NULL;            /* out of memory already :-( */     connOptions
=conninfo_parse(conninfo, &errorBuf, false);     if (connOptions == NULL && errmsg)
 
--- 3967,3973 ----     if (errmsg)         *errmsg = NULL;            /* default */     initPQExpBuffer(&errorBuf);
!     if (PQExpBufferDataBroken(errorBuf))         return NULL;            /* out of memory already :-( */
connOptions= conninfo_parse(conninfo, &errorBuf, false);     if (connOptions == NULL && errmsg)
 


(and one similar place in psql, which I did not bother to test).

Any objections or better ideas?
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Kevin Grittner"
Дата:
Сообщение: Re: new compiler warnings
Следующее
От: Tom Lane
Дата:
Сообщение: Re: new compiler warnings