mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@CS.UCLA.EDU>
To: Jim Meyering <jim@meyering.net>
Cc: bug-coreutils@gnu.org, Andrew Morton <akpm@osdl.org>,
	Bruce Allen <ballen@gravity.phys.uwm.edu>,
	linux-kernel@vger.kernel.org, Andy Isaacson <adi@hexapodia.org>
Subject: Re: dd PATCH: add conv=direct
Date: Thu, 08 Apr 2004 12:32:46 -0700	[thread overview]
Message-ID: <87vfkaw9i9.fsf@penguin.cs.ucla.edu> (raw)
In-Reply-To: <85k70qsp71.fsf@pi.meyering.net> (Jim Meyering's message of "Thu, 08 Apr 2004 13:07:30 +0200")

Jim Meyering <jim@meyering.net> writes:

> 2004-04-08  Jim Meyering  <jim@meyering.net>
>
> 	* src/dd.c (set_fd_flags): Don't OR in -1 when fcntl fails.

Doesn't that fix generate worse code in the usual case, since it
causes two conditional branches instead of one?

How about this further patch?  It relies on common subexpression
elimination, but that's common these days.

2004-04-08  Paul Eggert  <eggert@twinsun.com>

	* src/dd.c (set_fd_flags): Don't test old_flags < 0 twice.

Index: src/dd.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/dd.c,v
retrieving revision 1.157
diff -p -u -r1.157 dd.c
--- src/dd.c	8 Apr 2004 15:25:39 -0000	1.157
+++ src/dd.c	8 Apr 2004 19:17:02 -0000
@@ -1014,7 +1014,7 @@ copy_with_unblock (char const *buf, size
 }
 
 /* Set the file descriptor flags for FD that correspond to the nonzero bits
-   in FLAGS.  The file's name is NAME.  */
+   in ADD_FLAGS.  The file's name is NAME.  */
 
 static void
 set_fd_flags (int fd, int add_flags, char const *name)
@@ -1022,9 +1022,9 @@ set_fd_flags (int fd, int add_flags, cha
   if (add_flags)
     {
       int old_flags = fcntl (fd, F_GETFL);
-      int new_flags = old_flags < 0 ? add_flags : (old_flags | add_flags);
       if (old_flags < 0
-	  || (new_flags != old_flags && fcntl (fd, F_SETFL, new_flags) == -1))
+	  || (old_flags != (old_flags | add_flags)
+	      && fcntl (fd, F_SETFL, old_flags | add_flags) == -1))
 	error (EXIT_FAILURE, errno, _("setting flags for %s"), quote (name));
     }
 }

  reply	other threads:[~2004-04-08 19:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-06 22:03 Andy Isaacson
2004-04-07  0:33 ` Andrew Morton
2004-04-07 16:21   ` Bruce Allen
2004-04-07 16:42     ` Andrew Morton
2004-04-07 17:31   ` Andy Isaacson
2004-04-07 18:18     ` Andrew Morton
2004-04-07 19:24       ` Andy Isaacson
2004-04-07 19:34         ` Andrew Morton
2004-04-07 19:47           ` Andy Isaacson
2004-04-07 20:03             ` Andrew Morton
2004-04-07 20:43               ` Andy Isaacson
2004-04-07 21:00                 ` Valdis.Kletnieks
2004-04-07 21:35                 ` Bruce Allen
2004-04-08  6:56                   ` Paul Eggert
2004-04-08 11:07                     ` Jim Meyering
2004-04-08 19:32                       ` Paul Eggert [this message]
2004-04-08 19:51                         ` Paul Jarc
2004-04-08 21:34                         ` Jim Meyering
2004-04-08 16:23                     ` Philippe Troin
2004-04-08 20:20                       ` dd patch to remove noctty Paul Eggert
2004-04-08 21:40                         ` Jim Meyering
2004-04-09  0:37             ` dd PATCH: add conv=direct Anton Blanchard
2004-04-09  1:42               ` Wim Coekaerts
2004-04-10 21:28                 ` Jim Meyering
2004-04-07 20:46       ` Paul Eggert
2004-04-07 21:06         ` Andrew Morton
2004-04-07 21:09         ` Andy Isaacson
2004-04-07 19:12     ` Miquel van Smoorenburg
2004-04-07 20:14       ` Andy Isaacson
2004-04-07 22:02 ` Nathan Straz
2004-04-07 22:09   ` Andy Isaacson
2004-04-08 11:44     ` Miquel van Smoorenburg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vfkaw9i9.fsf@penguin.cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=adi@hexapodia.org \
    --cc=akpm@osdl.org \
    --cc=ballen@gravity.phys.uwm.edu \
    --cc=bug-coreutils@gnu.org \
    --cc=jim@meyering.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®