foxygit / doom Log in
commit 9f9fa99eb12d7a7df97b20b13d2200a4946e6ba3
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Wed Oct 19 20:38:03 2022 +0200
Commit:     GitHub <noreply@github.com>
CommitDate: Wed Oct 19 20:38:03 2022 +0200

    fix a cppcheck warning for M_DirName() and M_BaseName() (#1524)

    * fix a cppcheck warning for M_DirName() and M_BaseName()

    * fix pb and pf pointer checking order

    * simplify matters
---
 src/m_misc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/m_misc.c b/src/m_misc.c
index 9ede5581..210602c0 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -505,7 +505,7 @@ char *M_DirName(const char *path)
     }
     else
     {
-        const char *p = (pf > pb) ? pf : pb;
+        const char *p = (pb > pf) ? pb : pf;
         result = M_StringDuplicate(path);
         result[p - path] = '\0';
         return result;
@@ -531,7 +531,7 @@ const char *M_BaseName(const char *path)
     }
     else
     {
-        const char *p = (pf > pb) ? pf : pb;
+        const char *p = (pb > pf) ? pb : pf;
         return p + 1;
     }
 }
@@ -916,4 +916,4 @@ void M_NormalizeSlashes(char *str)
             }
         }
     }
-}
\ No newline at end of file
+}