]> granicus.if.org Git - python/commitdiff
Add function attributes that allow GCC to check the arguments of printf-like
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>
Tue, 23 Oct 2001 02:21:22 +0000 (02:21 +0000)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>
Tue, 23 Oct 2001 02:21:22 +0000 (02:21 +0000)
functions.

Include/pgenheaders.h
Include/pyerrors.h
Include/stringobject.h
Include/sysmodule.h

index 20ac2c7be996e9044c97c69159ca75dac8e0af8a..051173cc5eeb5b4fe07b90b7a1d9b580f21f2604 100644 (file)
@@ -25,8 +25,10 @@ extern "C" {
 
 #include "pydebug.h"
 
-DL_IMPORT(void) PySys_WriteStdout(const char *format, ...);
-DL_IMPORT(void) PySys_WriteStderr(const char *format, ...);
+DL_IMPORT(void) PySys_WriteStdout(const char *format, ...)
+                       __attribute__((format(printf, 1, 2)));
+DL_IMPORT(void) PySys_WriteStderr(const char *format, ...)
+                       __attribute__((format(printf, 1, 2)));
 
 #define addarc _Py_addarc
 #define addbit _Py_addbit
index c3960b7e593154bec06c7c4ef2c68273eb09a0c1..29ee1b6b000ca38e9f36810a4e233308ca2d6744 100644 (file)
@@ -77,7 +77,8 @@ extern DL_IMPORT(int) PyErr_BadArgument(void);
 extern DL_IMPORT(PyObject *) PyErr_NoMemory(void);
 extern DL_IMPORT(PyObject *) PyErr_SetFromErrno(PyObject *);
 extern DL_IMPORT(PyObject *) PyErr_SetFromErrnoWithFilename(PyObject *, char *);
-extern DL_IMPORT(PyObject *) PyErr_Format(PyObject *, const char *, ...);
+extern DL_IMPORT(PyObject *) PyErr_Format(PyObject *, const char *, ...)
+                       __attribute__((format(printf, 2, 3)));
 #ifdef MS_WINDOWS
 extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErrWithFilename(int, const char *);
 extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErr(int);
@@ -126,8 +127,10 @@ extern DL_IMPORT(PyObject *) PyErr_ProgramText(char *, int);
 
 #ifndef HAVE_SNPRINTF
 #include <stdarg.h>
-extern DL_IMPORT(int) PyOS_snprintf(char *str, size_t size, const char  *format, ...);
-extern DL_IMPORT(int) PyOS_vsnprintf(char *str, size_t size, const char  *format, va_list va);
+extern DL_IMPORT(int) PyOS_snprintf(char *str, size_t size, const char  *format, ...)
+                       __attribute__((format(printf, 3, 4)));
+extern DL_IMPORT(int) PyOS_vsnprintf(char *str, size_t size, const char  *format, va_list va)
+                       __attribute__((format(printf, 3, 0)));
 #else
 # define PyOS_vsnprintf        vsnprintf
 # define PyOS_snprintf snprintf
index 052eacf85e38c9e6c9669c596b41221c3971af7f..a5d97fa891b2f8bc6c520cd744e882816b5be8b7 100644 (file)
@@ -56,8 +56,10 @@ extern DL_IMPORT(PyTypeObject) PyString_Type;
 
 extern DL_IMPORT(PyObject *) PyString_FromStringAndSize(const char *, int);
 extern DL_IMPORT(PyObject *) PyString_FromString(const char *);
-extern DL_IMPORT(PyObject *) PyString_FromFormatV(const char*, va_list);
-extern DL_IMPORT(PyObject *) PyString_FromFormat(const char*, ...);
+extern DL_IMPORT(PyObject *) PyString_FromFormatV(const char*, va_list)
+                               __attribute__((format(printf, 1, 0)));
+extern DL_IMPORT(PyObject *) PyString_FromFormat(const char*, ...)
+                               __attribute__((format(printf, 1, 2)));
 extern DL_IMPORT(int) PyString_Size(PyObject *);
 extern DL_IMPORT(char *) PyString_AsString(PyObject *);
 extern DL_IMPORT(void) PyString_Concat(PyObject **, PyObject *);
index 92f2207be3d8d452d767aedbd3f1351a81a95d55..ca6b6d78982732264a1b7aaeb4d2b540df3e1339 100644 (file)
@@ -13,8 +13,10 @@ DL_IMPORT(FILE *) PySys_GetFile(char *, FILE *);
 DL_IMPORT(void) PySys_SetArgv(int, char **);
 DL_IMPORT(void) PySys_SetPath(char *);
 
-DL_IMPORT(void) PySys_WriteStdout(const char *format, ...);
-DL_IMPORT(void) PySys_WriteStderr(const char *format, ...);
+DL_IMPORT(void) PySys_WriteStdout(const char *format, ...)
+                       __attribute__((format(printf, 1, 2)));
+DL_IMPORT(void) PySys_WriteStderr(const char *format, ...)
+                       __attribute__((format(printf, 1, 2)));
 
 extern DL_IMPORT(PyObject *) _PySys_TraceFunc, *_PySys_ProfileFunc;
 extern DL_IMPORT(int) _PySys_CheckInterval;