From: | Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | phil(at)river-bank(dot)demon(dot)co(dot)uk (Phil Thompson) |
Cc: | goran(at)bildbasen(dot)se, fenix(at)am(dot)ring(dot)ru, pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: [HACKERS] Snapshot 270198 compile error |
Date: | 1998-01-27 19:50:01 |
Message-ID: | 199801271950.OAA20007@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>
> Bruce Momjian wrote:
>
> > #define UNIXSOCK_PATH(sun,port) \
> > (sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
> > ! + 1 + sizeof ((sun).sun_family))
> > ! /*
> > ! * + 1 is for BSD-specific sizeof((sun).sun_len)
> > ! * We never actually set sun_len, and I can't think of a
> > ! * platform-safe way of doing it, but the code still works. bjm
> > ! */
OK, I am with you. Even better, let's use offset(). Takes care of
possible OS padding between fields too:
---------------------------------------------------------------------------
*** ./include/libpq/pqcomm.h.orig Tue Jan 27 14:28:27 1998
--- ./include/libpq/pqcomm.h Tue Jan 27 14:48:15 1998
***************
*** 35,44 ****
#define UNIXSOCK_PATH(sun,port) \
(sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
! + 1 + sizeof ((sun).sun_family))
/*
! * + 1 is for BSD-specific sizeof((sun).sun_len)
! * We never actually set sun_len, and I can't think of a
* platform-safe way of doing it, but the code still works. bjm
*/
--- 35,44 ----
#define UNIXSOCK_PATH(sun,port) \
(sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
! offsetof(struct sockaddr_un, sun_path))
/*
! * We do this because sun_len is in BSD's struct, while others don't.
! * We never actually set BSD's sun_len, and I can't think of a
* platform-safe way of doing it, but the code still works. bjm
*/
--
Bruce Momjian
maillist(at)candle(dot)pha(dot)pa(dot)us
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 1998-01-27 19:57:10 | Re: Frontend/Backend Protocol Patch |
Previous Message | Phil Thompson | 1998-01-27 19:25:11 | Re: [HACKERS] Snapshot 270198 compile error |