]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* makeint.h (streq, patheq): Avoid pointer comparisons
authorPaul Smith <psmith@gnu.org>
Thu, 21 Aug 2025 12:17:24 +0000 (08:17 -0400)
committerPaul Smith <psmith@gnu.org>
Thu, 21 Aug 2025 13:09:06 +0000 (09:09 -0400)
Some compilers will warn about this and I doubt it provides much
benefit.

src/makeint.h

index 61c7822926e0b09f660fd7acc5bb15272c58eb43..120fc91563e88a11110330e2e2b122305354ee70 100644 (file)
@@ -320,18 +320,13 @@ extern mode_t umask (mode_t);
 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
 
 /* Test if two strings are equal. Is this worthwhile?  Should be profiled.  */
-#define streq(a, b) \
-   ((a) == (b) || \
-    (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
+#define streq(a, b) (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1)))
 
 /* Test if two strings are equal, but match case-insensitively on systems
    which have case-insensitive filesystems.  Should only be used for
    filenames!  */
 #ifdef HAVE_CASE_INSENSITIVE_FS
-# define patheq(a, b) \
-    ((a) == (b) \
-     || (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
-         && (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1))))
+# define patheq(a, b) (strcasecmp ((a), (b)) == 0)
 #else
 # define patheq(a, b) streq(a, b)
 #endif