changeset 11724:99b6167ab3d5

Tweak for maintainability.
author Bruno Haible <bruno@clisp.org>
date Mon, 20 Jul 2009 22:45:39 +0200
parents 928845623bf5
children 957ea54e3885
files ChangeLog tests/test-pipe.c
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/tests/test-pipe.c
+++ b/tests/test-pipe.c
@@ -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 @@
     }
   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);
 }