Skip to content
Snippets Groups Projects
Commit 78e67f2c authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Avoid pasing NULL to strto*() functions.

Whill this is perfectly legal and is not a problem, Coverity complains.
parent 3aab34e0
No related branches found
No related tags found
No related merge requests found
...@@ -739,7 +739,10 @@ char* xp_asprintf_next(char *format, int type, ...) ...@@ -739,7 +739,10 @@ char* xp_asprintf_next(char *format, int type, ...)
break; break;
#endif #endif
case XP_PRINTF_TYPE_CHARP: case XP_PRINTF_TYPE_CHARP:
i=strtol(cp, NULL, 0); if (cp)
i=strtol(cp, NULL, 0);
else
i = 0;
break; break;
case XP_PRINTF_TYPE_DOUBLE: case XP_PRINTF_TYPE_DOUBLE:
i=(int)d; i=(int)d;
...@@ -776,7 +779,10 @@ char* xp_asprintf_next(char *format, int type, ...) ...@@ -776,7 +779,10 @@ char* xp_asprintf_next(char *format, int type, ...)
break; break;
#endif #endif
case XP_PRINTF_TYPE_CHARP: case XP_PRINTF_TYPE_CHARP:
ui=strtoul(cp, NULL, 0); if (cp)
ui=strtoul(cp, NULL, 0);
else
ui = 0;
break; break;
case XP_PRINTF_TYPE_DOUBLE: case XP_PRINTF_TYPE_DOUBLE:
ui=(unsigned)d; ui=(unsigned)d;
...@@ -813,7 +819,10 @@ char* xp_asprintf_next(char *format, int type, ...) ...@@ -813,7 +819,10 @@ char* xp_asprintf_next(char *format, int type, ...)
break; break;
#endif #endif
case XP_PRINTF_TYPE_CHARP: case XP_PRINTF_TYPE_CHARP:
l=strtol(cp, NULL, 0); if (cp)
l=strtol(cp, NULL, 0);
else
l = 0;
break; break;
case XP_PRINTF_TYPE_DOUBLE: case XP_PRINTF_TYPE_DOUBLE:
l=(long)d; l=(long)d;
...@@ -850,7 +859,10 @@ char* xp_asprintf_next(char *format, int type, ...) ...@@ -850,7 +859,10 @@ char* xp_asprintf_next(char *format, int type, ...)
break; break;
#endif #endif
case XP_PRINTF_TYPE_CHARP: case XP_PRINTF_TYPE_CHARP:
ul=strtoul(cp, NULL, 0); if (cp)
ul=strtoul(cp, NULL, 0);
else
ul = 0;
break; break;
case XP_PRINTF_TYPE_DOUBLE: case XP_PRINTF_TYPE_DOUBLE:
ul=(unsigned long)d; ul=(unsigned long)d;
...@@ -886,7 +898,10 @@ char* xp_asprintf_next(char *format, int type, ...) ...@@ -886,7 +898,10 @@ char* xp_asprintf_next(char *format, int type, ...)
ll=ull; ll=ull;
break; break;
case XP_PRINTF_TYPE_CHARP: case XP_PRINTF_TYPE_CHARP:
ll=strtoll(cp, NULL, 0); if (cp)
ll=strtoll(cp, NULL, 0);
else
ll = 0;
break; break;
case XP_PRINTF_TYPE_DOUBLE: case XP_PRINTF_TYPE_DOUBLE:
ll=d; ll=d;
...@@ -921,7 +936,10 @@ char* xp_asprintf_next(char *format, int type, ...) ...@@ -921,7 +936,10 @@ char* xp_asprintf_next(char *format, int type, ...)
ull=ll; ull=ll;
break; break;
case XP_PRINTF_TYPE_CHARP: case XP_PRINTF_TYPE_CHARP:
ull=strtoull(cp, NULL, 0); if (cp)
ull=strtoull(cp, NULL, 0);
else
ull = 0;
break; break;
case XP_PRINTF_TYPE_DOUBLE: case XP_PRINTF_TYPE_DOUBLE:
ull=d; ull=d;
...@@ -1013,7 +1031,10 @@ char* xp_asprintf_next(char *format, int type, ...) ...@@ -1013,7 +1031,10 @@ char* xp_asprintf_next(char *format, int type, ...)
break; break;
#endif #endif
case XP_PRINTF_TYPE_CHARP: case XP_PRINTF_TYPE_CHARP:
d=strtod(cp, NULL); if (cp)
d=strtod(cp, NULL);
else
d = 0.0;
break; break;
case XP_PRINTF_TYPE_LONGDOUBLE: case XP_PRINTF_TYPE_LONGDOUBLE:
d=ld; d=ld;
...@@ -1050,11 +1071,14 @@ char* xp_asprintf_next(char *format, int type, ...) ...@@ -1050,11 +1071,14 @@ char* xp_asprintf_next(char *format, int type, ...)
break; break;
#endif #endif
case XP_PRINTF_TYPE_CHARP: case XP_PRINTF_TYPE_CHARP:
if (cp)
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
ld=strtod(cp, NULL); ld=strtod(cp, NULL);
#else #else
ld=strtold(cp, NULL); ld=strtold(cp, NULL);
#endif #endif
else
ld = 0.0L;
break; break;
case XP_PRINTF_TYPE_DOUBLE: case XP_PRINTF_TYPE_DOUBLE:
ld=d; ld=d;
...@@ -1129,11 +1153,14 @@ char* xp_asprintf_next(char *format, int type, ...) ...@@ -1129,11 +1153,14 @@ char* xp_asprintf_next(char *format, int type, ...)
break; break;
#endif #endif
case XP_PRINTF_TYPE_CHARP: case XP_PRINTF_TYPE_CHARP:
if (cp)
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
s=strtoul(cp, NULL, 0); s=strtoul(cp, NULL, 0);
#else #else
s=strtoull(cp, NULL, 0); s=strtoull(cp, NULL, 0);
#endif #endif
else
s = 0;
break; break;
case XP_PRINTF_TYPE_DOUBLE: case XP_PRINTF_TYPE_DOUBLE:
s=(size_t)d; s=(size_t)d;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment