coreutils
[Top][All Lists]
Advanced

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

[PATCH] mktemp: clarify intent and avoid unusual comma use


From: Tarmigan Casebolt
Subject: [PATCH] mktemp: clarify intent and avoid unusual comma use
Date: Wed, 20 Jul 2011 09:53:46 -0700

* src/mktemp.c: The comma syntax of the previous code (introduced in
be6120b5) was unusual and hard for a human to parse.  The underlying
logic is simple even if it does take a few more lines of code, so make
the code easier for a human to read.

In addition, (though this case is likely fine) some compilers may have
unexplored corner cases with comma separated statements.  See
    http://blog.regehr.org/archives/558
for a further discussion.
---
 src/mktemp.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/mktemp.c b/src/mktemp.c
index e592176..0f333cb 100644
--- a/src/mktemp.c
+++ b/src/mktemp.c
@@ -344,12 +344,16 @@ main (int argc, char **argv)
       puts (dest_name);
       /* If we created a file, but then failed to output the file
          name, we should clean up the mess before failing.  */
-      if (!dry_run && ((stdout_closed = true), close_stream (stdout) != 0))
+      if (!dry_run)
         {
-          int saved_errno = errno;
-          remove (dest_name);
-          error (EXIT_FAILURE, saved_errno, _("write error"));
-        }
+         stdout_closed = true;
+         if (close_stream (stdout) != 0)
+           {
+              int saved_errno = errno;
+              remove (dest_name);
+              error (EXIT_FAILURE, saved_errno, _("write error"));
+           }
+       }
     }
 
 #ifdef lint
-- 
1.7.4.4




reply via email to

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