[CRIU] [PATCH 02/23] criu/parasite-syscall.c: init a var

Kir Kolyshkin kir at openvz.org
Tue Oct 11 18:46:40 PDT 2016


Got the following from clang:

>   CC       criu/parasite-syscall.o
> criu/parasite-syscall.c:1494:6: error: variable 'parasite_size' is used
> uninitialized whenever 'if' condition is false
> [-Werror,-Wsometimes-uninitialized]
>         if (seized_native(ctl))
>             ^~~~~~~~~~~~~~~~~~
> criu/parasite-syscall.c:1503:2: note: uninitialized use occurs here
>         parasite_size += ctl->args_size;
>         ^~~~~~~~~~~~~
> criu/parasite-syscall.c:1494:2: note: remove the 'if' if its condition
> is always true
>         if (seized_native(ctl))
>         ^~~~~~~~~~~~~~~~~~~~~~~

I look at the code and I'm still not quite sure whether parasite_size
can end up being uninitialized. Looks like for CONFIG_X86_64 it can.

So, let's initialize it.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 criu/parasite-syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index 2482bf8..4debc00 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -1463,7 +1463,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 {
 	int ret;
 	struct parasite_ctl *ctl;
-	unsigned long p, map_exchange_size, parasite_size;
+	unsigned long p, map_exchange_size, parasite_size = 0;
 
 	BUG_ON(item->threads[0].real != pid);
 
-- 
2.7.4



More information about the CRIU mailing list