findutils-patches
[Top][All Lists]
Advanced

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

[Findutils-patches] [PATCH 2/3] Eliminate the need for the DEBUG_STAT pr


From: jay
Subject: [Findutils-patches] [PATCH 2/3] Eliminate the need for the DEBUG_STAT preprocessor macro.
Date: Wed, 30 Dec 2015 23:51:08 +0000

From: James Youngman <address@hidden>

* configure.ac: We no longer need to #define DEBUG_STAT with
--enable-debug, since the relevant debug messages are controlled
instead with find's command-line option -D stat.
* find/defs.h (enum DebugOption): bitmask values are now expressed
as 1 << N instead of decimal values, simply to make it clearer
when we need to start worrying about which integer type is used to
hold the bitmask.
* find/parser.c (fallback_getfilecon): Print a debug message when
the -D stat option is in effect, whether or not find was
configured with --enable-debug.
(parse_version): DEBUG_STAT is no longer a (distinct) feature.
---
 configure.ac  |  1 -
 find/defs.h   | 14 +++++++-------
 find/parser.c | 13 +++++--------
 3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index bfc94f1..58b2e4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,7 +41,6 @@ if test x$ac_cv_debug = xno; then
 else
    AC_MSG_RESULT([yes])
    AC_DEFINE([DEBUG], 1, [Define if you want to see find's innards])
-   AC_DEFINE([DEBUG_STAT], 1, [Define if you want to see a message every time 
find calls the stat() system call])
 fi
 
 AC_MSG_CHECKING([for leaf optimisation])
diff --git a/find/defs.h b/find/defs.h
index ba0b855..fe45388 100644
--- a/find/defs.h
+++ b/find/defs.h
@@ -526,13 +526,13 @@ bool looks_like_expression (const char *arg, bool 
leading);
 enum DebugOption
   {
     DebugNone             = 0,
-    DebugExpressionTree   = 1,
-    DebugStat             = 2,
-    DebugSearch           = 4,
-    DebugTreeOpt          = 8,
-    DebugHelp             = 16,
-    DebugExec             = 32,
-    DebugSuccessRates     = 64
+    DebugExpressionTree   = 1 << 0,
+    DebugStat             = 1 << 1,
+    DebugSearch           = 1 << 2,
+    DebugTreeOpt          = 1 << 3,
+    DebugHelp             = 1 << 4,
+    DebugExec             = 1 << 5,
+    DebugSuccessRates     = 1 << 6
   };
 
 struct options
diff --git a/find/parser.c b/find/parser.c
index b57cdda..84a940f 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -344,10 +344,11 @@ fallback_getfilecon (int fd, const char *name, 
security_context_t *p,
     {
       case ENOENT:
       case ENOTDIR:
-#ifdef DEBUG_STAT
-       fprintf (stderr, "fallback_getfilecon(): getfilecon(%s) failed; falling 
"
-                       "back on lgetfilecon()\n", name);
-#endif
+       if (options.debug_options & DebugStat)
+         {
+           fprintf (stderr, "fallback_getfilecon(): getfilecon(%s) failed; 
falling "
+                    "back on lgetfilecon()\n", name);
+         }
        return lgetfileconat (fd, name, p);
 
       case EACCES:
@@ -2593,10 +2594,6 @@ parse_version (const struct parser_table* entry, char 
**argv, int *arg_ptr)
   printf ("DEBUG ");
   has_features = true;
 #endif
-#if DEBUG_STAT
-  printf ("DEBUG_STAT ");
-  has_features = true;
-#endif
 #if defined HAVE_STRUCT_DIRENT_D_TYPE
   printf ("D_TYPE ");
   has_features = true;
-- 
2.1.4




reply via email to

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