Skip to content

Commit

Permalink
Prefer strtoll over atoll
Browse files Browse the repository at this point in the history
Both are specified by C99, but strtoll has specified overflow
behavior while atoll does not, so prefer using it.
  • Loading branch information
nikic committed Aug 5, 2020
1 parent 74b285d commit 2965c8f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
6 changes: 1 addition & 5 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ static inline long long php_date_llabs( long long i ) { return i >= 0 ? i : -i;
int st = snprintf(s, len, "%lld", i); \
s[st] = '\0'; \
} while (0);
#ifdef HAVE_ATOLL
# define DATE_A64I(i, s) i = atoll(s)
#else
# define DATE_A64I(i, s) i = strtoll(s, NULL, 10)
#endif
#define DATE_A64I(i, s) i = strtoll(s, NULL, 10)
#endif

PHPAPI time_t php_time(void)
Expand Down
9 changes: 0 additions & 9 deletions main/rfc1867.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
#include "ext/standard/php_string.h"
#include "zend_smart_string.h"

#if defined(PHP_WIN32) && !defined(HAVE_ATOLL)
# define atoll(s) _atoi64(s)
# define HAVE_ATOLL 1
#endif

#ifndef DEBUG_FILE_UPLOAD
# define DEBUG_FILE_UPLOAD 0
#endif
Expand Down Expand Up @@ -903,11 +898,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
}

if (!strcasecmp(param, "MAX_FILE_SIZE")) {
#ifdef HAVE_ATOLL
max_file_size = atoll(value);
#else
max_file_size = strtoll(value, NULL, 10);
#endif
}

efree(param);
Expand Down

0 comments on commit 2965c8f

Please sign in to comment.