bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] define STREQ(a, b) consistently, removing useless parentheses


From: Jim Meyering
Subject: [PATCH] define STREQ(a, b) consistently, removing useless parentheses
Date: Sun, 24 Jan 2010 11:32:15 +0100

FYI,

>From c0221df484c4a8a32e42a595b9f6caa446cc2226 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 24 Jan 2010 11:31:42 +0100
Subject: [PATCH] define STREQ(a,b) consistently, removing useless parentheses

#define STREQ(a, b) (strcmp ((a), (b)) == 0) is over-parenthesized,
since the only risk is that "a" or "b" contains an unparenthesized
comma, but if either did that, STREQ would have 3 or more arguments.
Hence, #define STREQ(a, b) (strcmp (a, b) == 0) is better.
* lib/fts.c (STREQ): Remove unnecessary parentheses.
* lib/hash-triple.c (STREQ): Likewise.
* tests/test-argv-iter.c (STREQ): Use a and b, not s1 and s2.
* lib/getugroups.c (STREQ): Likewise.
---
 ChangeLog              |   12 ++++++++++++
 lib/fts.c              |    2 +-
 lib/getugroups.c       |    2 +-
 lib/hash-triple.c      |    2 +-
 tests/test-argv-iter.c |    2 +-
 5 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e85062f..373a1bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-01-24  Jim Meyering  <address@hidden>
+
+       define STREQ(a,b) consistently, removing useless parentheses
+       #define STREQ(a, b) (strcmp ((a), (b)) == 0) is over-parenthesized,
+       since the only risk is that "a" or "b" contains an unparenthesized
+       comma, but if either did that, STREQ would have 3 or more arguments.
+       Hence, #define STREQ(a, b) (strcmp (a, b) == 0) is better.
+       * lib/fts.c (STREQ): Remove unnecessary parentheses.
+       * lib/hash-triple.c (STREQ): Likewise.
+       * tests/test-argv-iter.c (STREQ): Use a and b, not s1 and s2.
+       * lib/getugroups.c (STREQ): Likewise.
+
 2010-01-23  Jim Meyering  <address@hidden>

        maint.mk: fix syntax-check in a non-srcdir build directory
diff --git a/lib/fts.c b/lib/fts.c
index ca967fc..374c58a 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -223,7 +223,7 @@ static void free_dir (FTS *fts) {}
 #endif

 #define ISDOT(a)        (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
-#define STREQ(a, b)     (strcmp ((a), (b)) == 0)
+#define STREQ(a, b)     (strcmp (a, b) == 0)

 #define CLR(opt)        (sp->fts_options &= ~(opt))
 #define ISSET(opt)      (sp->fts_options & (opt))
diff --git a/lib/getugroups.c b/lib/getugroups.c
index 4a5a69d..299bae6 100644
--- a/lib/getugroups.c
+++ b/lib/getugroups.c
@@ -45,7 +45,7 @@ getugroups (int maxcount _GL_UNUSED,
 #else /* HAVE_GRP_H */
 # include <grp.h>

-# define STREQ(s1, s2) (strcmp (s1, s2) == 0)
+# define STREQ(a, b) (strcmp (a, b) == 0)

 /* Like `getgroups', but for user USERNAME instead of for the current
    process.  Store at most MAXCOUNT group IDs in the GROUPLIST array.
diff --git a/lib/hash-triple.c b/lib/hash-triple.c
index 094ca69..4205376 100644
--- a/lib/hash-triple.c
+++ b/lib/hash-triple.c
@@ -27,7 +27,7 @@
 #include "same.h"
 #include "same-inode.h"

-#define STREQ(a, b) (strcmp ((a), (b)) == 0)
+#define STREQ(a, b) (strcmp (a, b) == 0)

 /* Hash an F_triple, and *do* consider the file name.  */
 size_t
diff --git a/tests/test-argv-iter.c b/tests/test-argv-iter.c
index 868635c..d0597bd 100644
--- a/tests/test-argv-iter.c
+++ b/tests/test-argv-iter.c
@@ -26,7 +26,7 @@
 #include "macros.h"

 #define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
-#define STREQ(s1, s2) (strcmp (s1, s2) == 0)
+#define STREQ(a, b) (strcmp (a, b) == 0)

 static FILE *
 write_nul_delimited_argv (char **argv)
--
1.6.6.1.557.g77031




reply via email to

[Prev in Thread] Current Thread [Next in Thread]