foxygit / doom Log in
commit 9be786f9a5a7019d465eb9f11dcc143bad388579
Author:     mfrancis95 <mikefrancis95@gmail.com>
AuthorDate: Thu Jul 2 23:36:07 2020 -0400
Commit:     mfrancis95 <mikefrancis95@gmail.com>
CommitDate: Thu Jul 2 23:36:07 2020 -0400

    When running sscanf on numbers in hex or octal, make sure the argument type is unsigned int *

    This fixes warnings that were showing up in cppcheck
---
 src/i_video.c  | 4 ++--
 src/m_config.c | 2 +-
 src/m_misc.c   | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/i_video.c b/src/i_video.c
index a05963b0..4d74744c 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1371,10 +1371,10 @@ void I_InitGraphics(void)
     if (env != NULL)
     {
         char winenv[30];
-        int winid;
+        unsigned int winid;

         sscanf(env, "0x%x", &winid);
-        M_snprintf(winenv, sizeof(winenv), "SDL_WINDOWID=%i", winid);
+        M_snprintf(winenv, sizeof(winenv), "SDL_WINDOWID=%u", winid);

         putenv(winenv);
     }
diff --git a/src/m_config.c b/src/m_config.c
index 673e011d..7c44fc58 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -1923,7 +1923,7 @@ static int ParseIntParameter(const char *strparm)
     int parm;

     if (strparm[0] == '0' && strparm[1] == 'x')
-        sscanf(strparm+2, "%x", &parm);
+        sscanf(strparm+2, "%x", (unsigned int *) &parm);
     else
         sscanf(strparm, "%i", &parm);

diff --git a/src/m_misc.c b/src/m_misc.c
index 1f8117be..9a5560e0 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -259,9 +259,9 @@ char *M_TempFile(const char *s)

 boolean M_StrToInt(const char *str, int *result)
 {
-    return sscanf(str, " 0x%x", result) == 1
-        || sscanf(str, " 0X%x", result) == 1
-        || sscanf(str, " 0%o", result) == 1
+    return sscanf(str, " 0x%x", (unsigned int *) result) == 1
+        || sscanf(str, " 0X%x", (unsigned int *) result) == 1
+        || sscanf(str, " 0%o", (unsigned int *) result) == 1
         || sscanf(str, " %d", result) == 1;
 }