bug-coreutils
[Top][All Lists]
Advanced

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

[PATCH] maint: factor out cycle warning, now that du will use it, too


From: Jim Meyering
Subject: [PATCH] maint: factor out cycle warning, now that du will use it, too
Date: Thu, 05 Nov 2009 08:43:10 +0100

With this long string now being used in two places,
I pulled it into system.h.

I would have preferred a function, but that would have
meant including error.h and quote.h for all 100+ tools.
There are still ~12 and 30 .c files respectively that do not
include those headers.

>From 38cb824673a53062ab0d2ee843cdf58affc17e04 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 5 Nov 2009 08:32:09 +0100
Subject: [PATCH] maint: factor out cycle warning, now that du will use it, too

* src/system.h (emit_cycle_warning): Define.  Factored out of...
* src/remove.c (rm_fts): ...here.  Use the new macro.
---
 src/remove.c |    7 +------
 src/system.h |   12 ++++++++++++
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/remove.c b/src/remove.c
index c4b93fe..5847200 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -564,12 +564,7 @@ rm_fts (FTS *fts, FTSENT *ent, struct rm_options const *x)
       }

     case FTS_DC:               /* directory that causes cycles */
-      error (0, 0, _("\
-WARNING: Circular directory structure.\n\
-This almost certainly means that you have a corrupted file system.\n\
-NOTIFY YOUR SYSTEM MANAGER.\n\
-The following directory is part of the cycle:\n  %s\n"),
-             quote (ent->fts_path));
+      emit_cycle_warning (ent->fts_path);
       fts_skip_tree (fts, ent);
       return RM_ERROR;

diff --git a/src/system.h b/src/system.h
index b4d5e77..be7811b 100644
--- a/src/system.h
+++ b/src/system.h
@@ -672,6 +672,18 @@ io_blksize (struct stat sb)

 void usage (int status) ATTRIBUTE_NORETURN;

+#define emit_cycle_warning(file_name)  \
+  do                                   \
+    {                                  \
+      error (0, 0, _("\
+WARNING: Circular directory structure.\n\
+This almost certainly means that you have a corrupted file system.\n\
+NOTIFY YOUR SYSTEM MANAGER.\n\
+The following directory is part of the cycle:\n  %s\n"), \
+             quote (file_name));       \
+    }                                  \
+  while (0)
+
 #ifndef ARRAY_CARDINALITY
 # define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
 #endif
--
1.6.5.2.303.g13162




reply via email to

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