[lxc-devel] [PATCH 2/2] cgroup: change unfreeze_fromhandler to return bool

Stéphane Graber stgraber at ubuntu.com
Fri Jan 31 09:51:47 UTC 2014


On Thu, Jan 30, 2014 at 02:19:41PM +0000, Serge Hallyn wrote:
> To be more consistent with other cgroup_ops methods, in the hopes
> of having less return-value-related mixups.
> 
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/cgmanager.c | 6 +++---
>  src/lxc/cgroup.c    | 8 ++++----
>  src/lxc/cgroup.h    | 4 ++--
>  src/lxc/commands.c  | 6 ++----
>  4 files changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c
> index ca6b317..f5d42ff 100644
> --- a/src/lxc/cgmanager.c
> +++ b/src/lxc/cgmanager.c
> @@ -570,7 +570,7 @@ static inline bool cgm_init(struct lxc_handler *handler)
>  	return collect_subsytems();
>  }
>  
> -static int cgm_unfreeze_fromhandler(struct lxc_handler *handler)
> +static bool cgm_unfreeze_fromhandler(struct lxc_handler *handler)
>  {
>  	char *cgroup_path = handler->cgroup_info->data;
>  
> @@ -581,9 +581,9 @@ static int cgm_unfreeze_fromhandler(struct lxc_handler *handler)
>  		ERROR("call to cgmanager_set_value_sync failed: %s", nerr->message);
>  		nih_free(nerr);
>  		ERROR("Error unfreezing %s", cgroup_path);
> -		return -1;
> +		return false;
>  	}
> -	return 0;
> +	return true;
>  }
>  
>  static bool setup_limits(struct lxc_handler *h, bool do_devices)
> diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c
> index 288fe20..c23b784 100644
> --- a/src/lxc/cgroup.c
> +++ b/src/lxc/cgroup.c
> @@ -2279,7 +2279,7 @@ static char *cgfs_get_cgroup(struct lxc_handler *handler, const char *subsystem)
>  	return lxc_cgroup_get_hierarchy_path_handler(subsystem, handler);
>  }
>  
> -static int cgfs_unfreeze_fromhandler(struct lxc_handler *handler)
> +static bool cgfs_unfreeze_fromhandler(struct lxc_handler *handler)
>  {
>  	char *cgabspath, *cgrelpath;
>  	int ret;
> @@ -2287,11 +2287,11 @@ static int cgfs_unfreeze_fromhandler(struct lxc_handler *handler)
>  	cgrelpath = lxc_cgroup_get_hierarchy_path_handler("freezer", handler);
>  	cgabspath = lxc_cgroup_find_abs_path("freezer", cgrelpath, true, NULL);
>  	if (!cgabspath)
> -		return -1;
> +		return false;
>  
>  	ret = do_cgroup_set(cgabspath, "freezer.state", "THAWED");
>  	free(cgabspath);
> -	return ret;
> +	return ret == 0;
>  }
>  
>  bool cgroupfs_setup_limits(struct lxc_handler *h, bool with_devices)
> @@ -2431,7 +2431,7 @@ int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *na
>  	return active_cg_ops->get(filename, value, len, name, lxcpath);
>  }
>  
> -int lxc_unfreeze_fromhandler(struct lxc_handler *handler)
> +bool lxc_unfreeze_fromhandler(struct lxc_handler *handler)
>  {
>  	return active_cg_ops->unfreeze_fromhandler(handler);
>  }
> diff --git a/src/lxc/cgroup.h b/src/lxc/cgroup.h
> index 45b58d0..da77473 100644
> --- a/src/lxc/cgroup.h
> +++ b/src/lxc/cgroup.h
> @@ -192,7 +192,7 @@ struct cgroup_ops {
>  	char *(*get_cgroup)(struct lxc_handler *handler, const char *subsystem);
>  	int (*set)(const char *filename, const char *value, const char *name, const char *lxcpath);
>  	int (*get)(const char *filename, char *value, size_t len, const char *name, const char *lxcpath);
> -	int (*unfreeze_fromhandler)(struct lxc_handler *handler);
> +	bool (*unfreeze_fromhandler)(struct lxc_handler *handler);
>  	bool (*setup_limits)(struct lxc_handler *handler, bool with_devices);
>  	bool (*chown)(struct lxc_handler *handler);
>  	bool (*attach)(const char *name, const char *lxcpath, pid_t pid);
> @@ -220,8 +220,8 @@ extern bool cgroup_create_legacy(struct lxc_handler *handler);
>  extern char *cgroup_get_cgroup(struct lxc_handler *handler, const char *subsystem);
>  extern bool lxc_cgroup_attach(const char *name, const char *lxcpath, pid_t pid);
>  extern bool lxc_setup_mount_cgroup(const char *root, struct lxc_cgroup_info *cgroup_info, int type);
> +extern bool lxc_unfreeze_fromhandler(struct lxc_handler *handler);
>  extern int lxc_cgroup_set(const char *filename, const char *value, const char *name, const char *lxcpath);
>  extern int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath);
> -extern int lxc_unfreeze_fromhandler(struct lxc_handler *handler);
>  
>  #endif
> diff --git a/src/lxc/commands.c b/src/lxc/commands.c
> index 1fca13e..e9ab42f 100644
> --- a/src/lxc/commands.c
> +++ b/src/lxc/commands.c
> @@ -583,7 +583,6 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req,
>  				 struct lxc_handler *handler)
>  {
>  	struct lxc_cmd_rsp rsp;
> -	int ret;
>  	int stopsignal = SIGKILL;
>  
>  	if (handler->conf->stopsignal)
> @@ -591,11 +590,10 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req,
>  	memset(&rsp, 0, sizeof(rsp));
>  	rsp.ret = kill(handler->pid, stopsignal);
>  	if (!rsp.ret) {
> -		ret = lxc_unfreeze_fromhandler(handler);
> -		if (!ret)
> +		if (lxc_unfreeze_fromhandler(handler))
>  			return 0;
>  		ERROR("Failed to unfreeze %s:%s", handler->lxcpath, handler->name);
> -		rsp.ret = ret;
> +		rsp.ret = -1;
>  	}
>  
>  	return lxc_cmd_rsp_send(fd, &rsp);
> -- 
> 1.8.5.3
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140131/cdca097b/attachment.pgp>


More information about the lxc-devel mailing list