Unix Technical Forum

execl() sentinel

This is a discussion on execl() sentinel within the Pgsql Patches forums, part of the PostgreSQL category; --> Stefan Kaltenbrunner just let me know via Jabber that there's a warning in pg_regress.c: pg_regress.c: In function `spawn_process': pg_regress.c:914: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 11:22 AM
Alvaro Herrera
 
Posts: n/a
Default execl() sentinel

Stefan Kaltenbrunner just let me know via Jabber that there's a warning
in pg_regress.c:

pg_regress.c: In function `spawn_process':
pg_regress.c:914: warning: missing sentinel in function call

This small patch would seem to fix it, according to
http://www.linuxonly.nl/docs/sentinel/



--
Alvaro Herrera http://www.flickr.com/photos/alvherre/
"Los románticos son seres que mueren de deseos de vida"


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 11:24 AM
Bruce Momjian
 
Posts: n/a
Default Re: execl() sentinel

Alvaro Herrera wrote:
> Stefan Kaltenbrunner just let me know via Jabber that there's a warning
> in pg_regress.c:
>
> pg_regress.c: In function `spawn_process':
> pg_regress.c:914: warning: missing sentinel in function call
>
> This small patch would seem to fix it, according to
> http://www.linuxonly.nl/docs/sentinel/


You can apply this, but it sure seems like a compiler/include file bug
to me, even with the 64-bit explaination.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 11:24 AM
Tom Lane
 
Posts: n/a
Default Re: execl() sentinel

Bruce Momjian <bruce@momjian.us> writes:
> Alvaro Herrera wrote:
>> pg_regress.c: In function `spawn_process':
>> pg_regress.c:914: warning: missing sentinel in function call


> You can apply this, but it sure seems like a compiler/include file bug
> to me, even with the 64-bit explaination.


There are lots of platforms where the include files and the compiler are
not all that compatible, gcc + vendor include files being the prototype
case. It's too bad that gcc doesn't have a
-Wno-snarkiness-about-system-headers-thank-you switch.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-18-2008, 11:24 AM
Peter Eisentraut
 
Posts: n/a
Default Re: execl() sentinel

Tom Lane wrote:
> It's too bad that gcc doesn't have a
> -Wno-snarkiness-about-system-headers-thank-you switch.


It does have a switch to *add* snarkiness about system headers, but does
not do it by default.

The problem in this case is that an uncast null pointer constant is not
always a sufficient sentinel for variadic functions, as explained here:
<http://c-faq.com/null/null2.html>.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-18-2008, 11:24 AM
Tom Lane
 
Posts: n/a
Default Re: execl() sentinel

Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane wrote:
>> It's too bad that gcc doesn't have a
>> -Wno-snarkiness-about-system-headers-thank-you switch.


> It does have a switch to *add* snarkiness about system headers, but does
> not do it by default.


> The problem in this case is that an uncast null pointer constant is not
> always a sufficient sentinel for variadic functions, as explained here:
> <http://c-faq.com/null/null2.html>.


Sure, but on a machine where it actually matters (ie one where int and
pointer are of different sizes), I'd expect NULL to be #define'd as
"((void *) 0)" not just "0". You should *not* have to inform the
machine that NULL is a pointer.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-18-2008, 11:24 AM
Peter Eisentraut
 
Posts: n/a
Default Re: execl() sentinel

Am Mittwoch, 18. Juli 2007 16:16 schrieb Tom Lane:
> You should *not* have to inform the machine that NULL is a pointer.


For variadic functions, that expectation is invalid, AFAIK.

It might be good to check the actual definition of NULL in this case, however,
before wondering further.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-18-2008, 11:24 AM
Alvaro Herrera
 
Posts: n/a
Default Re: execl() sentinel

Peter Eisentraut wrote:
> Am Mittwoch, 18. Juli 2007 16:16 schrieb Tom Lane:
> > You should *not* have to inform the machine that NULL is a pointer.

>
> For variadic functions, that expectation is invalid, AFAIK.


No, what's invalid is that using an unadorned 0 is understood as a "null
pointer" by the compiler. That would happen in a lot of places except
on a variadic function.

However, the platform may define NULL as it wishes, and indeed in our
c.h it is defined (conditionally) as (void *)0. If the platform had
such a definition then it would work without issues.

I assume the platform in question does something like
#define NULL 0
which would be silly.

--
Alvaro Herrera http://www.advogato.org/person/alvherre
"El conflicto es el camino real hacia la unión"

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-18-2008, 11:24 AM
Peter Eisentraut
 
Posts: n/a
Default Re: execl() sentinel

Am Mittwoch, 18. Juli 2007 17:16 schrieb Alvaro Herrera:
> Peter Eisentraut wrote:
> > Am Mittwoch, 18. Juli 2007 16:16 schrieb Tom Lane:
> > > You should *not* have to inform the machine that NULL is a pointer.

> >
> > For variadic functions, that expectation is invalid, AFAIK.

>
> No, what's invalid is that using an unadorned 0 is understood as a "null
> pointer" by the compiler. That would happen in a lot of places except
> on a variadic function.
>
> However, the platform may define NULL as it wishes, and indeed in our
> c.h it is defined (conditionally) as (void *)0. If the platform had
> such a definition then it would work without issues.
>
> I assume the platform in question does something like
> #define NULL 0
> which would be silly.


I suggest that you read through <http://c-faq.com/null/>, which is at odds
with your statements.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-18-2008, 11:24 AM
Neil Conway
 
Posts: n/a
Default Re: execl() sentinel

On Wed, 2007-07-18 at 16:59 +0200, Peter Eisentraut wrote:
> It might be good to check the actual definition of NULL in this case, however,
> before wondering further.


Well, the existing coding is plainly wrong, regardless of the NULL
implementation used on any given machine (although it will usually
work). The simple rule is "you need to cast NULL to a pointer type when
passing arguments to a variadic function, or to a function whose
prototype is not in scope".

So +1 on this patch from me.

-Neil



---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-18-2008, 11:24 AM
Alvaro Herrera
 
Posts: n/a
Default Re: execl() sentinel

Neil Conway wrote:
> On Wed, 2007-07-18 at 16:59 +0200, Peter Eisentraut wrote:
> > It might be good to check the actual definition of NULL in this case, however,
> > before wondering further.

>
> Well, the existing coding is plainly wrong, regardless of the NULL
> implementation used on any given machine (although it will usually
> work). The simple rule is "you need to cast NULL to a pointer type when
> passing arguments to a variadic function, or to a function whose
> prototype is not in scope".
>
> So +1 on this patch from me.


Thanks, committed. I looked for other uses of execl(), execle() and
execlp() and found a single one of execl() which is already OK.

I wouldn't know how to look for other variadic functions using NULL
sentinels though.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:43 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com