[CRIU] [crtools-bot] Make sure no uninitialized values are used

Cyrill Gorcunov gorcunov at openvz.org
Wed Feb 1 06:24:39 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit 229defc9280f4c460e667330f75266ff56f20716
Author: Cyrill Gorcunov <gorcunov at openvz.org>
Date:   Wed Feb 1 15:24:39 2012 +0400

    Make sure no uninitialized values are used
    
    I've got it if -O2 compilation option used.
    
     | cr-restore.c:1069:5: error: ‘ret’ may be used uninitialized in this function [-Werror=uninitialized]
     | sockets.c:1145:7: error: ‘sk’ may be used uninitialized in this function [-Werror=uninitialized]
    
    In first case 'ret' indeed might be uninitialized, and
    in second case "goto err" was called too early. Fix them both.
    
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-restore.c |    3 ++-
 sockets.c    |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 74e6431..63e28ba 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -943,9 +943,10 @@ static rt_sigaction_t sigchld_act;
 static int prepare_sigactions(int pid)
 {
 	rt_sigaction_t act, oact;
-	int fd_sigact, ret;
+	int fd_sigact;
 	struct sa_entry e;
 	int sig, i;
+	int ret = -1;
 
 	fd_sigact = open_image_ro(CR_FD_SIGACT, pid);
 	if (fd_sigact < 0)
diff --git a/sockets.c b/sockets.c
index 2d36202..1c6d29c 100644
--- a/sockets.c
+++ b/sockets.c
@@ -1103,12 +1103,12 @@ static int open_inet_sk(struct inet_sk_entry *ie, int *img_fd)
 
 	if (ie->family != AF_INET) {
 		pr_err("Unsupported socket family: %d\n", ie->family);
-		goto err;
+		return -1;
 	}
 
 	if (ie->type != SOCK_STREAM) {
 		pr_err("Unsupported socket type: %d\n", ie->type);
-		goto err;
+		return -1;
 	}
 
 	sk = socket(ie->family, ie->type, ie->proto);


More information about the CRIU mailing list