mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] prctl: Removed redunant assignment of "error" to zero
@ 2012-05-30  9:55 Sasikantha babu
  2012-05-30 15:07 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Sasikantha babu @ 2012-05-30  9:55 UTC (permalink / raw)
  To: Serge Hallyn, Andrew Morton, Eric W. Biederman, Kees Cook, James Morris
  Cc: linux-kernel, Sasikantha babu

Just setting the "error" to error number is enough on failure and
It doesn't require to set "error" variable to zero in each switch case, since
it was already initialized with zero

Signed-off-by: Sasikantha babu <sasikanth.v19@gmail.com>
---
 kernel/sys.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index 6df4262..d8e9016 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1920,7 +1920,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 				break;
 			}
 			me->pdeath_signal = arg2;
-			error = 0;
 			break;
 		case PR_GET_PDEATHSIG:
 			error = put_user(me->pdeath_signal, (int __user *)arg2);
@@ -1934,7 +1933,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 				break;
 			}
 			set_dumpable(me->mm, arg2);
-			error = 0;
 			break;
 
 		case PR_SET_UNALIGN:
@@ -1961,8 +1959,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 		case PR_SET_TIMING:
 			if (arg2 != PR_TIMING_STATISTICAL)
 				error = -EINVAL;
-			else
-				error = 0;
 			break;
 
 		case PR_SET_NAME:
@@ -2013,7 +2009,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 					current->default_timer_slack_ns;
 			else
 				current->timer_slack_ns = arg2;
-			error = 0;
 			break;
 		case PR_MCE_KILL:
 			if (arg4 | arg5)
@@ -2039,7 +2034,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 			default:
 				return -EINVAL;
 			}
-			error = 0;
 			break;
 		case PR_MCE_KILL_GET:
 			if (arg2 | arg3 | arg4 | arg5)
@@ -2055,7 +2049,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 			break;
 		case PR_SET_CHILD_SUBREAPER:
 			me->signal->is_child_subreaper = !!arg2;
-			error = 0;
 			break;
 		case PR_GET_CHILD_SUBREAPER:
 			error = put_user(me->signal->is_child_subreaper,
-- 
1.7.3.4


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

* Re: [PATCH] prctl: Removed redunant assignment of "error" to zero
  2012-05-30  9:55 [PATCH] prctl: Removed redunant assignment of "error" to zero Sasikantha babu
@ 2012-05-30 15:07 ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2012-05-30 15:07 UTC (permalink / raw)
  To: Sasikantha babu
  Cc: Serge Hallyn, Andrew Morton, Eric W. Biederman, James Morris,
	linux-kernel

On Wed, May 30, 2012 at 2:55 AM, Sasikantha babu
<sasikanth.v19@gmail.com> wrote:
> Just setting the "error" to error number is enough on failure and
> It doesn't require to set "error" variable to zero in each switch case, since
> it was already initialized with zero

This looks fine. Can you include an additional clean up in this? It
looks like PR_SET_NAME and PR_GET_NAME both 'return 0' instead of
using 'break' like all the rest.

-Kees

-- 
Kees Cook
Chrome OS Security

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

end of thread, other threads:[~2012-05-30 15:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-30  9:55 [PATCH] prctl: Removed redunant assignment of "error" to zero Sasikantha babu
2012-05-30 15:07 ` Kees Cook

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®