[Patches] Fix compiler warning in posixmodule.c
Greg Ward
gward@cnri.reston.va.us
Wed, 1 Mar 2000 14:17:39 -0500
--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=us-ascii
On 01 March 2000, Fred L. Drake, Jr. said:
> Greg Ward writes:
> > Attached is a two-line patch that silences the compiler warnings by only
> > using the "_r" versions in a threaded Python.
>
> Actually, you missed the second #ifdef HAVE_TMPNAM_R; fix that,
> *then* check this in. ;)
Oops! Thanks Fred -- just shows that no patch is too trivial to escape
peer review.
Second patch attached -- this is relative to the original code, not to
my first patch. This one's cleaner, as it defines USE_CTERMID_R and
USE_TMPNAM_R up at the top of the file, so the preprocessor logic deep
in the guts is simple: "#ifdef USE_CTERMID_R". Is the "USE_XXX"
terminology OK? What about the placement of these two #define's (after
all the other conditional #define's at the top of the file)?
Greg
--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=posix-patch
Index: posixmodule.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.124
diff -c -r2.124 posixmodule.c
*** posixmodule.c 2000/02/25 17:51:00 2.124
--- posixmodule.c 2000/03/01 19:12:21
***************
*** 274,279 ****
--- 274,289 ----
#endif /* UNION_WAIT */
+ /* Don't use the "_r" form if we don't need it (also, won't have a
+ prototype for it, at least on Solaris -- maybe others as well?). */
+ #if defined(HAVE_CTERMID_R) && defined(WITH_THREAD)
+ #define USE_CTERMID_R
+ #endif
+
+ #if defined(HAVE_TMPNAM_R) && defined(WITH_THREAD)
+ #define USE_TMPNAM_R
+ #endif
+
/* Return a dictionary corresponding to the POSIX environment table */
#if !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) )
***************
*** 649,655 ****
if (!PyArg_ParseTuple(args, ":ctermid"))
return NULL;
! #ifdef HAVE_CTERMID_R
ret = ctermid_r(buffer);
#else
ret = ctermid(buffer);
--- 659,665 ----
if (!PyArg_ParseTuple(args, ":ctermid"))
return NULL;
! #ifdef USE_CTERMID_R
ret = ctermid_r(buffer);
#else
ret = ctermid(buffer);
***************
*** 3342,3348 ****
if (!PyArg_ParseTuple(args, ":tmpnam"))
return NULL;
! #ifdef HAVE_TMPNAM_R
name = tmpnam_r(buffer);
#else
name = tmpnam(buffer);
--- 3352,3358 ----
if (!PyArg_ParseTuple(args, ":tmpnam"))
return NULL;
! #ifdef USE_TMPNAM_R
name = tmpnam_r(buffer);
#else
name = tmpnam(buffer);
***************
*** 3350,3356 ****
if (name == NULL) {
PyErr_SetObject(PyExc_OSError,
Py_BuildValue("is", 0,
! #ifdef HAVE_TMPNAM_R
"unexpected NULL from tmpnam_r"
#else
"unexpected NULL from tmpnam"
--- 3360,3366 ----
if (name == NULL) {
PyErr_SetObject(PyExc_OSError,
Py_BuildValue("is", 0,
! #ifdef USE_TMPNAM_R
"unexpected NULL from tmpnam_r"
#else
"unexpected NULL from tmpnam"
--2fHTh5uZTiUOsy+g--