summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-04-08 15:20:33 +0000
committerJim Meyering <jim@meyering.net>2004-04-08 15:20:33 +0000
commit470a15a00ef27f1a26868202909e5a6a75feb29a (patch)
tree904abd0907906f140fedc4eee1d5fe4625113c70
parenta660c7e1658827cecd7534b25166bda297d7d558 (diff)
downloadcoreutils-470a15a00ef27f1a26868202909e5a6a75feb29a.tar.xz
(set_fd_flags): Don't OR in -1 when fcntl fails.
Rename parameter, flags, to avoid shadowing global.
-rw-r--r--src/dd.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/dd.c b/src/dd.c
index 9b72a6312..4df58ed9f 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));