From: Jim Meyering Date: Thu, 8 Apr 2004 15:20:33 +0000 (+0000) Subject: (set_fd_flags): Don't OR in -1 when fcntl fails. X-Git-Tag: v5.3.0~1851 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=470a15a00ef27f1a26868202909e5a6a75feb29a;p=thirdparty%2Fcoreutils.git (set_fd_flags): Don't OR in -1 when fcntl fails. Rename parameter, flags, to avoid shadowing global. --- diff --git a/src/dd.c b/src/dd.c index 9b72a63124..4df58ed9f3 100644 --- a/src/dd.c +++ b/src/dd.c @@ -1017,12 +1017,12 @@ copy_with_unblock (char const *buf, size_t nread) in FLAGS. The file's name is NAME. */ static void -set_fd_flags (int fd, int flags, char const *name) +set_fd_flags (int fd, int add_flags, char const *name) { - if (flags) + if (add_flags) { int old_flags = fcntl (fd, F_GETFL); - int new_flags = old_flags | flags; + 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)) error (EXIT_FAILURE, errno, _("setting flags for %s"), quote (name));