mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cgroup.c: remove goto statement from cgroup_init.
@ 2008-08-11  9:25 Rakib Mullick
  2008-08-11  9:32 ` Andreas Schwab
  2008-08-11  9:35 ` Paul Menage
  0 siblings, 2 replies; 3+ messages in thread
From: Rakib Mullick @ 2008-08-11  9:25 UTC (permalink / raw)
  To: Paul Menage, Paul Jackson; +Cc: linux-kernel

Hello everyone, following patch removes the use of goto statement.
Actually, we don't need it. Beacuse, if "err < 0", then it will never
be TRUE. So, we can skip the goto statement and can just return.
Thanks.

Signed-off-by: Rakib Mullick (rakib.mullick@gmail.com)

--- linux-2.6.27-rc2.orig/kernel/cgroup.c	2008-08-11 15:16:49.000000000 +0600
+++ linux-2.6.27-rc2/kernel/cgroup.c	2008-08-11 15:16:26.000000000 +0600
@@ -2562,11 +2562,10 @@ int __init cgroup_init(void)

 	err = register_filesystem(&cgroup_fs_type);
 	if (err < 0)
-		goto out;
+		return err;

 	proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations);

-out:
 	if (err)
 		bdi_destroy(&cgroup_backing_dev_info);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cgroup.c: remove goto statement from cgroup_init.
  2008-08-11  9:25 [PATCH] cgroup.c: remove goto statement from cgroup_init Rakib Mullick
@ 2008-08-11  9:32 ` Andreas Schwab
  2008-08-11  9:35 ` Paul Menage
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2008-08-11  9:32 UTC (permalink / raw)
  To: Rakib Mullick; +Cc: Paul Menage, Paul Jackson, linux-kernel

"Rakib Mullick" <rakib.mullick@gmail.com> writes:

> Hello everyone, following patch removes the use of goto statement.
> Actually, we don't need it. Beacuse, if "err < 0", then it will never
> be TRUE.

What is "it"?

> --- linux-2.6.27-rc2.orig/kernel/cgroup.c	2008-08-11 15:16:49.000000000 +0600
> +++ linux-2.6.27-rc2/kernel/cgroup.c	2008-08-11 15:16:26.000000000 +0600
> @@ -2562,11 +2562,10 @@ int __init cgroup_init(void)
>
>  	err = register_filesystem(&cgroup_fs_type);
>  	if (err < 0)
> -		goto out;
> +		return err;
>
>  	proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations);
>
> -out:
>  	if (err)
>  		bdi_destroy(&cgroup_backing_dev_info);

Doesn't this create a resource leak?

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cgroup.c: remove goto statement from cgroup_init.
  2008-08-11  9:25 [PATCH] cgroup.c: remove goto statement from cgroup_init Rakib Mullick
  2008-08-11  9:32 ` Andreas Schwab
@ 2008-08-11  9:35 ` Paul Menage
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Menage @ 2008-08-11  9:35 UTC (permalink / raw)
  To: Rakib Mullick; +Cc: Paul Jackson, linux-kernel

On Mon, Aug 11, 2008 at 2:25 AM, Rakib Mullick <rakib.mullick@gmail.com> wrote:
> Hello everyone, following patch removes the use of goto statement.
> Actually, we don't need it. Beacuse, if "err < 0", then it will never
> be TRUE.

"err" will be regarded by the compiler as true if it's anything other
than 0. So this patch introduces breakage.

Paul

> So, we can skip the goto statement and can just return.
> Thanks.
>
> Signed-off-by: Rakib Mullick (rakib.mullick@gmail.com)
>
> --- linux-2.6.27-rc2.orig/kernel/cgroup.c       2008-08-11 15:16:49.000000000 +0600
> +++ linux-2.6.27-rc2/kernel/cgroup.c    2008-08-11 15:16:26.000000000 +0600
> @@ -2562,11 +2562,10 @@ int __init cgroup_init(void)
>
>        err = register_filesystem(&cgroup_fs_type);
>        if (err < 0)
> -               goto out;
> +               return err;
>
>        proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations);
>
> -out:
>        if (err)
>                bdi_destroy(&cgroup_backing_dev_info);
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-11  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-11  9:25 [PATCH] cgroup.c: remove goto statement from cgroup_init Rakib Mullick
2008-08-11  9:32 ` Andreas Schwab
2008-08-11  9:35 ` Paul Menage

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®