Refactor to add `XATOI` for standard library function.

pull/2373/head
David Garske 2019-07-19 14:32:00 -07:00
parent 50fbdb961f
commit b0444bcfa1
4 changed files with 10 additions and 7 deletions

View File

@ -39,7 +39,7 @@
#include <wolfssl/wolfio.h>
#if defined(HAVE_HTTP_CLIENT)
#include <stdlib.h> /* atoi(), strtol() */
#include <stdlib.h> /* strtol() */
#endif
/*
@ -1101,7 +1101,7 @@ int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
else if (XSTRNCASECMP(start, "Content-Length:", 15) == 0) {
start += 15;
while (*start == ' ' && *start != '\0') start++;
chunkSz = atoi(start);
chunkSz = XATOI(start);
state = (state == phr_http_start) ? phr_have_length : phr_wait_end;
}
else if (XSTRNCASECMP(start, "Transfer-Encoding:", 18) == 0) {

View File

@ -5753,7 +5753,7 @@ int main(int argc, char** argv)
while (argc > 1) {
if (string_matches(argv[1], "-?")) {
if(--argc>1){
lng_index = atoi((++argv)[1]);
lng_index = XATOI((++argv)[1]);
if(lng_index<0||lng_index>1) {
lng_index = 0;
}
@ -5772,7 +5772,7 @@ int main(int argc, char** argv)
argc--;
argv++;
if(argc>1) {
lng_index = atoi(argv[1]);
lng_index = XATOI(argv[1]);
if(lng_index<0||lng_index>1){
printf("invalid number(%d) is specified. [<num> :0-1]\n",lng_index);
lng_index = 0;
@ -5802,7 +5802,7 @@ int main(int argc, char** argv)
argc--;
argv++;
if (argc > 1) {
g_threadCount = atoi(argv[1]);
g_threadCount = XATOI(argv[1]);
if (g_threadCount < 1 || lng_index > 128){
printf("invalid number(%d) is specified. [<num> :1-128]\n",
g_threadCount);
@ -5867,7 +5867,7 @@ int main(int argc, char** argv)
}
else {
/* parse for block size */
benchmark_configure(atoi(argv[1]));
benchmark_configure(XATOI(argv[1]));
}
argc--;
argv++;

View File

@ -10973,7 +10973,7 @@ int EncodePolicyOID(byte *out, word32 *outSz, const char *in, void* heap)
token = XSTRTOK(str, ".", &ptr);
while (token != NULL)
{
val = (word32)atoi(token);
val = (word32)XATOI(token);
if (nb_val == 0) {
if (val > 2) {

View File

@ -401,6 +401,9 @@
#define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
#define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
#include <stdlib.h>
#define XATOI(s) atoi((s))
#ifdef USE_WOLF_STRSEP
#define XSTRSEP(s1,d) wc_strsep((s1),(d))
#else