[CRIU] [PATCH 05/14] crtools: don't use global variables for saving service fds

Pavel Emelyanov xemul at parallels.com
Fri Jan 11 05:37:28 EST 2013


On 01/11/2013 01:22 PM, Andrey Vagin wrote:
> Global vars are used to detect uninitialized states. Now the interface
> of service fds is able to do that.
> 
> It's preparation for cloning service descriptors
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  image.c           | 24 +++++++++-------------
>  include/crtools.h |  2 +-
>  log.c             | 59 +++++++++++++++++--------------------------------------
>  tty.c             |  8 ++------
>  util.c            | 41 ++++++++++++--------------------------
>  5 files changed, 43 insertions(+), 91 deletions(-)
> 
> diff --git a/image.c b/image.c
> index f1f93a0..cded9f6 100644
> --- a/image.c
> +++ b/image.c
> @@ -227,10 +227,9 @@ struct cr_fdset *cr_glob_fdset_open(int mode)
>  	return cr_fdset_open(-1 /* ignored */, _CR_FD_GLOB_FROM, _CR_FD_GLOB_TO, mode);
>  }
>  
> -static int image_dir_fd = -1;
> -
>  int open_image(int type, unsigned long flags, ...)
>  {
> +	int dfd = get_service_fd(IMG_FD_OFF);

Try to avoid initialization at the declaration time with results of
functions/macros calls.

>  	char path[PATH_MAX];
>  	va_list args;
>  	int ret;


More information about the CRIU mailing list