From 70329ae7cac412244aa8b7aab14583bdfa7b9a6a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 20 Jul 2009 22:45:39 +0200 Subject: [PATCH] Tweak for maintainability. --- ChangeLog | 5 +++++ tests/test-pipe.c | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea5f5fe9a..1b3d36c50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-07-20 Bruno Haible + + * tests/test-pipe.c (BACKUP_STDERR_FILENO): New macro. + (main): Use it. + 2009-07-20 Eric Blake test-pipe: make a bit more robust. diff --git a/tests/test-pipe.c b/tests/test-pipe.c index e28fae70e..16c72f603 100644 --- 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 @@ 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); } -- 2.11.0