From a0ee564f646780b7aefc997f6fe04ebbad703bb6 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Thu, 12 Jul 2018 17:52:09 +0200 Subject: [PATCH] coverity: #1437935 Unchecked return value Signed-off-by: Christian Brauner --- src/lxc/cmd/lxc_usernsexec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lxc/cmd/lxc_usernsexec.c b/src/lxc/cmd/lxc_usernsexec.c index cfe5db26c..1426eed5d 100644 --- a/src/lxc/cmd/lxc_usernsexec.c +++ b/src/lxc/cmd/lxc_usernsexec.c @@ -75,14 +75,15 @@ static void usage(const char *name) printf(" calling user permission to use the mapped ranges\n"); } -static void opentty(const char * tty, int which) { +static void opentty(const char *tty, int which) +{ int fd, flags; if (tty[0] == '\0') return; fd = open(tty, O_RDWR | O_NONBLOCK); - if (fd == -1) { + if (fd < 0) { printf("WARN: could not reopen tty: %s\n", strerror(errno)); return; } @@ -97,7 +98,7 @@ static void opentty(const char * tty, int which) { close(which); if (fd != which) { - dup2(fd, which); + (void)dup2(fd, which); close(fd); } } -- 2.47.2