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 hold error 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

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to