[Patches] [ python-Patches-473240 ] printf-like function warnings

noreply@sourceforge.net noreply@sourceforge.net
Mon, 22 Oct 2001 19:25:42 -0700


Patches item #473240, was opened at 2001-10-20 13:13
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=473240&group_id=5470

Category: Core (C code)
Group: None
>Status: Closed
Resolution: Accepted
Priority: 2
Submitted By: Neil Schemenauer (nascheme)
Assigned to: Neil Schemenauer (nascheme)
Summary: printf-like function warnings

Initial Comment:
This patch adds GCC function attributes to printf
like functions.  This allows GCC to check calls
to these functions for errors.

The preprocessor tests in pyport.h were stolen
from Apache 1.3.19 so they should be fairly well
tested.

Assigned to Tim since he seems to be the portability
guy.  Please review, reject or assign to someone
else.

----------------------------------------------------------------------

>Comment By: Neil Schemenauer (nascheme)
Date: 2001-10-22 19:25

Message:
Logged In: YES 
user_id=35752

Commited (with additions for functions that use a va_list).

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-10-22 18:49

Message:
Logged In: YES 
user_id=31435

Accepted, and back to Neil for checkin.  Guido, I'll 
compile it on Windows after it's checked in (it's so 
obvious that it won't hurt Windows that I don't want to pee 
away time on that in advance -- and, if I'm wrong, then  
needing to fix it in crisis mode will teach me a lesson for 
being so arrogant <wink>).

The gcc printf/scanf warnings caught several subtle bugs in 
Dragon's software, so I'm all in favor of this.  Question:  
why isn't PyOS_vsnprintf() decorated too?  gcc can't check 
the arglist in that case, but it can check the format 
string for well-formedness.  I believe you pass a last 
argument of 0 to tell gcc "no, you can't check any 
arguments for this function, just the format".

----------------------------------------------------------------------

Comment By: Neil Schemenauer (nascheme)
Date: 2001-10-21 15:22

Message:
Logged In: YES 
user_id=35752

The Py_inline define could be used as a hint that some
functions should be inlined.  The _sre module already does
something like this.  Since there seems to be no other modules
using inline I left it commented out.  If we want to use it
we should add some more magic for other compilers.  IOW,
ignore it.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-10-20 17:47

Message:
Logged In: YES 
user_id=6380

I have no problem with this.

Tim: if it compiles on Windows, and you like it enough,
assign it back to Neil for checkin.

Neil: what is this about?

+/* #define Py_inline */
+#else
+/* #define Py_inline __inline__ */ /* enable this someday?
*/


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=473240&group_id=5470