Tweak for maintainability.
authorBruno Haible <bruno@clisp.org>
Mon, 20 Jul 2009 20:45:39 +0000 (22:45 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 20 Jul 2009 20:45:39 +0000 (22:45 +0200)
ChangeLog
tests/test-pipe.c

index ea5f5fe..1b3d36c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-20  Bruno Haible  <bruno@clisp.org>
+
+       * tests/test-pipe.c (BACKUP_STDERR_FILENO): New macro.
+       (main): Use it.
+
 2009-07-20  Eric Blake  <ebb9@byu.net>
 
        test-pipe: make a bit more robust.
index e28fae7..16c72f6 100644 (file)
@@ -38,6 +38,7 @@
    (outside the range of interesting fd's during the test) set up to
    duplicate the original stderr.  */
 
+#define BACKUP_STDERR_FILENO 10
 static FILE *myerr;
 
 #define ASSERT(expr) \
@@ -226,15 +227,16 @@ main (int argc, char *argv[])
     }
   if (strcmp (argv[1], "child") == 0)
     {
-      /* fd 2 might be closed, but fd 10 is the original stderr.  */
-      myerr = fdopen (10, "w");
+      /* fd 2 might be closed, but fd BACKUP_STDERR_FILENO is the original
+        stderr.  */
+      myerr = fdopen (BACKUP_STDERR_FILENO, "w");
       if (!myerr)
        return 2;
       return child_main (argc, argv);
     }
   /* We might close fd 2 later, so save it in fd 10.  */
-  if (dup2 (STDERR_FILENO, 10) != 10
-      || (myerr = fdopen (10, "w")) == NULL)
+  if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO
+      || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL)
     return 2;
   return parent_main (argc, argv);
 }