[lxc-devel] [lxcfs/master] memory_utils: make it easier for Coverity

brauner on Github lxc-bot at linuxcontainers.org
Wed Apr 15 13:33:42 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 365 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200415/549285d2/attachment.bin>
-------------- next part --------------
From 7eaf033e0352f43a86068e7afe4f29fb15534bcd Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 15 Apr 2020 15:32:44 +0200
Subject: [PATCH] memory_utils: make it easier for Coverity

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/memory_utils.h | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/memory_utils.h b/src/memory_utils.h
index 87d9c6d..c4af530 100644
--- a/src/memory_utils.h
+++ b/src/memory_utils.h
@@ -7,7 +7,6 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
 
@@ -31,12 +30,12 @@
 	}
 
 #define close_prot_errno_replace(fd, new_fd) \
-       if (fd >= 0) {                       \
-               int _e_ = errno;             \
-               close(fd);                   \
-               errno = _e_;                 \
-               fd = new_fd;                 \
-       }
+	if (fd >= 0) {                       \
+		int _e_ = errno;             \
+		close(fd);                   \
+		errno = _e_;                 \
+		fd = new_fd;                 \
+	}
 
 static inline void close_prot_errno_disarm_function(int *fd)
 {
@@ -50,10 +49,10 @@ define_cleanup_function(FILE *, fclose);
 define_cleanup_function(DIR *, closedir);
 #define __do_closedir call_cleaner(closedir)
 
-#define free_disarm(ptr)       \
-	({                     \
-		free(ptr);     \
-		move_ptr(ptr); \
+#define free_disarm(ptr)    \
+	({                  \
+		free(ptr);  \
+		ptr = NULL; \
 	})
 
 static inline void free_disarm_function(void *ptr)


More information about the lxc-devel mailing list