diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-07 01:00:52 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-07 01:00:52 (GMT) |
commit | ef12810f0c23a0c0e8b276e76d289f0f211ab5bb (patch) | |
tree | 256b3c2ccecf66e01a127ba374c8426f64823124 /Modules/timemodule.c | |
parent | 4726e40e00ad9c2e333c4dfc5005f410a520834c (diff) | |
download | cpython-ef12810f0c23a0c0e8b276e76d289f0f211ab5bb.zip cpython-ef12810f0c23a0c0e8b276e76d289f0f211ab5bb.tar.gz cpython-ef12810f0c23a0c0e8b276e76d289f0f211ab5bb.tar.bz2 |
time: fix gcc warning
* Create format_arg variable to use the right types
* Strip trailing spaces
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index cbb05cd..1a85662 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -384,31 +384,31 @@ gettmarg(PyObject *args, struct tm *p) * asctime(). Return 1 if all values are valid, otherwise set an exception * and returns 0. */ -static int -checktm(struct tm* buf) +static int +checktm(struct tm* buf) { - /* Checks added to make sure strftime() and asctime() does not crash Python by - indexing blindly into some array for a textual representation - by some bad index (fixes bug #897625 and #6608). - - Also support values of zero from Python code for arguments in which - that is out of range by forcing that value to the lowest value that - is valid (fixed bug #1520914). - - Valid ranges based on what is allowed in struct tm: - - - tm_year: [0, max(int)] (1) - - tm_mon: [0, 11] (2) - - tm_mday: [1, 31] - - tm_hour: [0, 23] - - tm_min: [0, 59] - - tm_sec: [0, 60] - - tm_wday: [0, 6] (1) - - tm_yday: [0, 365] (2) - - tm_isdst: [-max(int), max(int)] - - (1) gettmarg() handles bounds-checking. - (2) Python's acceptable range is one greater than the range in C, + /* Checks added to make sure strftime() and asctime() does not crash Python by + indexing blindly into some array for a textual representation + by some bad index (fixes bug #897625 and #6608). + + Also support values of zero from Python code for arguments in which + that is out of range by forcing that value to the lowest value that + is valid (fixed bug #1520914). + + Valid ranges based on what is allowed in struct tm: + + - tm_year: [0, max(int)] (1) + - tm_mon: [0, 11] (2) + - tm_mday: [1, 31] + - tm_hour: [0, 23] + - tm_min: [0, 59] + - tm_sec: [0, 60] + - tm_wday: [0, 6] (1) + - tm_yday: [0, 365] (2) + - tm_isdst: [-max(int), max(int)] + + (1) gettmarg() handles bounds-checking. + (2) Python's acceptable range is one greater than the range in C, thus need to check against automatic decrement by gettmarg(). */ if (buf->tm_mon == -1) @@ -472,6 +472,7 @@ time_strftime(PyObject *self, PyObject *args) #else PyObject *format; #endif + PyObject *format_arg; size_t fmtlen, buflen; time_char *outbuf = NULL; size_t i; @@ -482,7 +483,7 @@ time_strftime(PyObject *self, PyObject *args) /* Will always expect a unicode string to be passed as format. Given that there's no str type anymore in py3k this seems safe. */ - if (!PyArg_ParseTuple(args, "U|O:strftime", &format, &tup)) + if (!PyArg_ParseTuple(args, "U|O:strftime", &format_arg, &tup)) return NULL; if (tup == NULL) { @@ -501,13 +502,13 @@ time_strftime(PyObject *self, PyObject *args) buf.tm_isdst = 1; #ifdef HAVE_WCSFTIME - format = PyUnicode_AsWideCharString((PyUnicodeObject*)format, NULL); + format = PyUnicode_AsWideCharString((PyUnicodeObject*)format_arg, NULL); if (format == NULL) return NULL; fmt = format; #else /* Convert the unicode string to an ascii one */ - format = PyUnicode_AsEncodedString(format, TZNAME_ENCODING, NULL); + format = PyUnicode_AsEncodedString(format_arg, TZNAME_ENCODING, NULL); if (format == NULL) return NULL; fmt = PyBytes_AS_STRING(format); |