[lxc-devel] [lxc/master] coverity

brauner on Github lxc-bot at linuxcontainers.org
Thu Jul 12 15:53:10 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180712/0f5468a1/attachment.bin>
-------------- next part --------------
From 00c72a935fff560f68c70f51e4ac2e8c2ab3b703 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 12 Jul 2018 17:49:30 +0200
Subject: [PATCH 1/2] coverity: #1437936

Unchecked return value

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/attach.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lxc/attach.c b/src/lxc/attach.c
index da8bcda00..8ac83a6c9 100644
--- a/src/lxc/attach.c
+++ b/src/lxc/attach.c
@@ -908,13 +908,13 @@ static int attach_child_main(struct attach_clone_payload *payload)
 	 * may want to make sure the fds are closed, for example.
 	 */
 	if (options->stdin_fd >= 0 && options->stdin_fd != STDIN_FILENO)
-		dup2(options->stdin_fd, STDIN_FILENO);
+		(void)dup2(options->stdin_fd, STDIN_FILENO);
 
 	if (options->stdout_fd >= 0 && options->stdout_fd != STDOUT_FILENO)
-		dup2(options->stdout_fd, STDOUT_FILENO);
+		(void)dup2(options->stdout_fd, STDOUT_FILENO);
 
 	if (options->stderr_fd >= 0 && options->stderr_fd != STDERR_FILENO)
-		dup2(options->stderr_fd, STDERR_FILENO);
+		(void)dup2(options->stderr_fd, STDERR_FILENO);
 
 	/* close the old fds */
 	if (options->stdin_fd > STDERR_FILENO)

From a0ee564f646780b7aefc997f6fe04ebbad703bb6 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 12 Jul 2018 17:52:09 +0200
Subject: [PATCH 2/2] coverity: #1437935

Unchecked return value

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 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);
 	}
 }


More information about the lxc-devel mailing list