No description
Find a file
Kir Kolyshkin 02c3605c02 criu/filesystems.c: refactor binfmt_misc_restore_bme
The following error is emitted by clang:

>   CC       criu/filesystems.o
> criu/filesystems.c:280:13: error: variable 'ret' is used uninitialized
>    whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>         } else if (bme->extension) {
>                    ^~~~~~~~~~~~~~
> criu/filesystems.c:287:6: note: uninitialized use occurs here
>         if (ret > 0) {
>             ^~~
> criu/filesystems.c:280:9: note: remove the 'if' if its condition is
>    always true
>         } else if (bme->extension) {
>                ^~~~~~~~~~~~~~~~~~~~
> criu/filesystems.c:272:9: note: initialize the variable 'ret' to silence
>    this warning
>         int ret;
>                ^
>                 = 0
> 1 error generated.

This code was a result of commit 398e7d3.

If we look closely, this is a false alarm, as "else if (bme->extension)"
is always true as it was checked before. But this is not very clear,
and the issue with clangs still needs to be fixed.

There are many ways to do so:

1. Initialize ret to 0. This is what initial version of this patch did.

2. Remove the always-true condition, like this:

	-	} else if (bme->extension) {
	+	} else {

In my opinion this would hurt readability.

3. Change the code flow, improving readability at the same time.

I believe that #3 is what this patch does. In addition, it fixes
handling of a few corner cases:

- an overflow in snprintf();
- a case when bme->name is NULL (as it is used for strlen/snprintf,
  there is a potential for SIGSEGV);
- a case of ret == 0 (currently there is no code flow that
  results in ret being 0, so it's just for the future).

[v2: use linux kernel style for 'else' after a block]
[xemul: Fix // comments ]

Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 14:59:35 +03:00
contrib Add script to install required packages to compile in Debian 2016-09-26 15:42:43 +03:00
coredump coredump: Rename dir to coredump 2016-06-28 13:04:58 +03:00
crit crit/decode: set default opts['nopl'] to False 2016-05-30 13:47:54 +03:00
criu criu/filesystems.c: refactor binfmt_misc_restore_bme 2016-10-24 14:59:35 +03:00
Documentation Added --display-stats to the man page 2016-10-24 14:59:35 +03:00
images images: rename NONE to CG_NONE 2016-10-10 12:49:28 +03:00
lib python lib: rename rpc.py to rpc_pb2.py 2016-10-10 12:49:28 +03:00
scripts scripts: allow to skip travis specific parts in travis-tests 2016-10-13 15:48:41 +03:00
test zdtm: check pre-dump of shared memory 2016-10-13 15:51:08 +03:00
.gitignore uninstall: use --record with setup.py, v2 2016-05-06 14:38:29 +03:00
.mailmap repo: Add mailmap file 2012-03-25 23:31:20 +04:00
.travis.yml travis: turn on alpine build 2016-09-06 19:00:21 +03:00
COPYING COPYING: fix a typo in a preamble 2016-08-11 16:18:43 +03:00
CREDITS Add the CREDITS file 2012-07-30 13:52:37 +04:00
INSTALL.md build: Add INSTALL.md and update "make help" 2016-05-06 14:38:29 +03:00
Makefile Makefile: move default goal up 2016-10-10 12:48:19 +03:00
Makefile.install build/make: return to make from top directory 2016-08-01 18:38:32 +03:00
Makefile.versions criu: Version 2.7 2016-10-17 11:30:31 +03:00
README.md Add ascciinema tour on basic criu features. 2016-06-16 16:37:06 +03:00

CRIU (Checkpoint and Restore in Userspace)

An utility to checkpoint/restore tasks. Using this tool, you can freeze a running application (or part of it) and checkpoint it to a hard drive as a collection of files. You can then use the files to restore and run the application from the point it was frozen at. The distinctive feature of the CRIU project is that it is mainly implemented in user space.

The project home is at http://criu.org.

Pages worth starting with are:

A video tour on basic CRIU features

CRIU introduction

How to contribute