]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: factor out cycle warning, now that du will use it, too
authorJim Meyering <meyering@redhat.com>
Thu, 5 Nov 2009 07:32:09 +0000 (08:32 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 5 Nov 2009 07:32:31 +0000 (08:32 +0100)
* src/system.h (emit_cycle_warning): Define.  Factored out of...
* src/remove.c (rm_fts): ...here.  Use the new macro.

src/remove.c
src/system.h

index c4b93fe7e032c6cb873262d0a38744c81c1e2b58..584720079f26142d4536a76f460d88b473329f43 100644 (file)
@@ -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;
 
index b4d5e774f36ee581b3358e64f691cc6fb017d34b..be7811b485ad494d05ecbacc283c53c2e1f7c86a 100644 (file)
@@ -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