Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Snapshot 270198 compile error

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 (view raw or flat)
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

In response to

pgsql-hackers by date

Next:From: Bruce MomjianDate: 1998-01-27 19:57:10
Subject: Re: Frontend/Backend Protocol Patch
Previous:From: Phil ThompsonDate: 1998-01-27 19:25:11
Subject: Re: [HACKERS] Snapshot 270198 compile error

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group