[PATCH 2/2] cgroups: fix cgroup_event_listener error handling

Tejun Heo tj at kernel.org
Mon Jan 7 17:44:27 UTC 2013


On Fri, Jan 04, 2013 at 01:05:18PM -0800, Greg Thelen wrote:
> If the <absolute-path-to-control-file> command line parameter cannot
> be opened, then cgroup_event_listener prints an error message and
> tries to return an error.  However, due to an uninitialized variable
> the return value was undefined.
> 
> With this patch such failures always return non-zero error.
> 
> Compiler warning found this:
>   $ gcc -Wall -O2 cgroup_event_listener.c
>   cgroup_event_listener.c: In function ‘main’:
>   cgroup_event_listener.c:109:2: warning: ‘ret’ may be used uninitialized in this function [-Wuninitialized]
> 
> Signed-off-by: Greg Thelen <gthelen at google.com>
> ---
>  tools/cgroup/cgroup_event_listener.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/tools/cgroup/cgroup_event_listener.c b/tools/cgroup/cgroup_event_listener.c
> index 3e082f9..a70f00c 100644
> --- a/tools/cgroup/cgroup_event_listener.c
> +++ b/tools/cgroup/cgroup_event_listener.c
> @@ -35,7 +35,7 @@ int main(int argc, char **argv)
>  	if (cfd == -1) {
>  		fprintf(stderr, "Cannot open %s: %s\n", argv[1],
>  				strerror(errno));
> -		goto out;
> +		return 1;

Hmm... so, event_control open failure path is broken the same way.
Can you please fix it together?  Please just remove the cleanup path.

Thanks.

-- 
tejun


More information about the Containers mailing list