From 4bb9a4b7921aa469b90505033bb0c752e5db7a24 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 25 Oct 2018 23:29:20 +0000 Subject: [PATCH] sscanf format parameter fixups git-svn-id: https://svn.eduke32.com/eduke32@7083 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/audiolib/src/xa.cpp | 6 +++--- source/build/src/config.cpp | 4 +++- source/build/src/scriptfile.cpp | 2 +- source/duke3d/src/cmdline.cpp | 2 +- source/duke3d/src/gamedef.cpp | 2 +- source/duke3d/src/m32def.cpp | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/audiolib/src/xa.cpp b/source/audiolib/src/xa.cpp index 1be52ef96..9fb00a806 100644 --- a/source/audiolib/src/xa.cpp +++ b/source/audiolib/src/xa.cpp @@ -188,7 +188,7 @@ static void decodeSoundSectMono(XASector *ssct, xa_data * xad) } if (count > xad->blocksize) - xad->block = (int8_t *)realloc(xad->block, count); + xad->block = (int8_t *)Xrealloc(xad->block, count); memcpy(xad->block, decodeBuf, count); xad->blocksize = count; @@ -268,7 +268,7 @@ static void decodeSoundSectStereo(XASector *ssct, xa_data * xad) } if (count > xad->blocksize) - xad->block = (int8_t *)realloc(xad->block, count); + xad->block = (int8_t *)Xrealloc(xad->block, count); memcpy(xad->block, decodeBuf, count); xad->blocksize = count; @@ -448,7 +448,7 @@ int32_t MV_PlayXA return MV_Error; } - xad = (xa_data *) calloc( 1, sizeof(xa_data) ); + xad = (xa_data *) Xcalloc( 1, sizeof(xa_data) ); if (!xad) { MV_SetErrorCode( MV_InvalidFile ); return MV_Error; diff --git a/source/build/src/config.cpp b/source/build/src/config.cpp index 0c2c0bdf2..0caad1cdd 100644 --- a/source/build/src/config.cpp +++ b/source/build/src/config.cpp @@ -255,7 +255,9 @@ int32_t loadsetup(const char *fn) if (readconfig(fp, "remap", val, VL) > 0) { - char *p=val; int32_t v1,v2; + char *p=val; + uint32_t v1,v2; + while (*p) { if (!sscanf(p,"%x",&v1))break; diff --git a/source/build/src/scriptfile.cpp b/source/build/src/scriptfile.cpp index bfcee854b..e3d481829 100644 --- a/source/build/src/scriptfile.cpp +++ b/source/build/src/scriptfile.cpp @@ -379,7 +379,7 @@ int32_t scriptfile_getsymbolvalue(char const *name, int32_t *val) { if (name[0] == '0' && tolower(name[1]) == 'x') // hex constants { - int64_t x; + uint64_t x; sscanf(name + 2, "%" PRIx64 "", &x); if (EDUKE32_PREDICT_FALSE(x > UINT32_MAX)) diff --git a/source/duke3d/src/cmdline.cpp b/source/duke3d/src/cmdline.cpp index 08e80b016..2486df4e6 100644 --- a/source/duke3d/src/cmdline.cpp +++ b/source/duke3d/src/cmdline.cpp @@ -140,7 +140,7 @@ static void G_AddDemo(const char* param) // -d:[,] // profiling options *(colon++) = 0; - Bsscanf(colon, "%u,%u", &framespertic, &numrepeats); + Bsscanf(colon, "%d,%d", &framespertic, &numrepeats); } Demo_SetFirst(tempbuf); diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 688baabc4..d4e8a3424 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -1793,7 +1793,7 @@ static int32_t parse_decimal_number(void) // (textptr) static int32_t parse_hex_constant(const char *hexnum) { - int64_t x; + uint64_t x; sscanf(hexnum, "%" PRIx64 "", &x); if (EDUKE32_PREDICT_FALSE(x > UINT32_MAX)) diff --git a/source/duke3d/src/m32def.cpp b/source/duke3d/src/m32def.cpp index 7b974783c..0b42409ba 100644 --- a/source/duke3d/src/m32def.cpp +++ b/source/duke3d/src/m32def.cpp @@ -958,7 +958,7 @@ static int32_t GetGamearrayID(const char *szGameLabel, int32_t searchlocals) static int32_t parse_integer_literal(int32_t *num) { if (textptr[0] == '0' && tolower(textptr[1])=='x') - sscanf(textptr+2, "%" SCNx32, num); + sscanf(textptr+2, "%" SCNx32, (uint32_t *)&num); else { long lnum;