linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cleanup: correct tabbing of check_kill_permission()
@ 2008-03-01 22:32 Andrew G. Morgan
  2008-03-02  0:49 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew G. Morgan @ 2008-03-01 22:32 UTC (permalink / raw)
  To: Andrew Morton; +Cc: lkml

[-- Attachment #1: Type: text/plain, Size: 472 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrew

Here is a small patch to reformat the check_kill_permission() function.
It doesn't change any functionality.

There was something confusing about its tabbing previously, and it also
ran over the 80 column limit.

Cheers

Andrew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFHydmF+bHCR3gb8jsRAmehAKDVnrOMVkHPhZslnhE1tVVXl2x07gCgsAse
LdjzfIwC+dmOqfDGLwnhaOo=
=pQEM
-----END PGP SIGNATURE-----

[-- Attachment #2: 0001-Reformat-check_kill_permission-function-to-make-it.patch --]
[-- Type: text/plain, Size: 1426 bytes --]

From 7dda0a7adb7ab870e01f93b6b066598665e15f7d Mon Sep 17 00:00:00 2001
From: Andrew G. Morgan <morgan@kernel.org>
Date: Mon, 25 Feb 2008 21:49:22 -0800
Subject: [PATCH] Reformat check_kill_permission() function to make it readable.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
---
 kernel/signal.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 84917fe..77f0439 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -530,17 +530,19 @@ static int check_kill_permission(int sig, struct siginfo *info,
 	if (!valid_signal(sig))
 		return error;
 
-	if (info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info))) {
-		error = audit_signal_info(sig, t); /* Let audit system see the signal */
+	if (info == SEND_SIG_NOINFO
+	    || (!is_si_special(info) && SI_FROMUSER(info))) {
+		 /* Let audit system see the signal */
+		error = audit_signal_info(sig, t);
 		if (error)
 			return error;
 		error = -EPERM;
-		if (((sig != SIGCONT) ||
-			(task_session_nr(current) != task_session_nr(t)))
+		if (((sig != SIGCONT)
+		     || (task_session_nr(current) != task_session_nr(t)))
 		    && (current->euid ^ t->suid) && (current->euid ^ t->uid)
 		    && (current->uid ^ t->suid) && (current->uid ^ t->uid)
 		    && !capable(CAP_KILL))
-		return error;
+			return error;
 	}
 
 	return security_task_kill(t, info, sig, 0);
-- 
1.5.3.7


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

* Re: [PATCH] cleanup: correct tabbing of check_kill_permission()
  2008-03-01 22:32 [PATCH] cleanup: correct tabbing of check_kill_permission() Andrew G. Morgan
@ 2008-03-02  0:49 ` Christoph Hellwig
  2008-03-02  5:15   ` Andrew G. Morgan
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2008-03-02  0:49 UTC (permalink / raw)
  To: Andrew G. Morgan; +Cc: Andrew Morton, lkml

On Sat, Mar 01, 2008 at 02:32:38PM -0800, Andrew G. Morgan wrote:
> +	if (info == SEND_SIG_NOINFO
> +	    || (!is_si_special(info) && SI_FROMUSER(info))) {
> +		 /* Let audit system see the signal */
> +		error = audit_signal_info(sig, t);
>  		if (error)
>  			return error;
>  		error = -EPERM;
> -		if (((sig != SIGCONT) ||
> -			(task_session_nr(current) != task_session_nr(t)))
> +		if (((sig != SIGCONT)
> +		     || (task_session_nr(current) != task_session_nr(t)))
>  		    && (current->euid ^ t->suid) && (current->euid ^ t->uid)
>  		    && (current->uid ^ t->suid) && (current->uid ^ t->uid)
>  		    && !capable(CAP_KILL))
> -		return error;
> +			return error;

If you start reformmating it please get it completely right:

	if (info == SEND_SIG_NOINFO ||
	    (!is_si_special(info) && SI_FROMUSER(info))) {
		/* Let audit system see the signal */
		error = audit_signal_info(sig, t);
 		if (error)
 			return error;
 		error = -EPERM;
		if ((sig != SIGCONT ||
		     (task_session_nr(current) != task_session_nr(t))) &&
		    (current->euid ^ t->suid) && (current->euid ^ t->uid) &&
		    (current->uid ^ t->suid) && (current->uid ^ t->uid) &&
		    !capable(CAP_KILL))
			return error;
 	}

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

* Re: [PATCH] cleanup: correct tabbing of check_kill_permission()
  2008-03-02  0:49 ` Christoph Hellwig
@ 2008-03-02  5:15   ` Andrew G. Morgan
  2008-03-02  8:16     ` Adrian Bunk
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew G. Morgan @ 2008-03-02  5:15 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Andrew Morton, lkml

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Christoph,

I ran it through scripts/checkpatch.pl - it said it was ok - and I see
that other places in this file contain code of this style -
do_sigaltstack() for example.

Could you give me a reference for "completely right"? Its not obvious to
me that Documentation/CodingStyle is what you are using as a reference.

Thanks

Andrew

Christoph Hellwig wrote:
| On Sat, Mar 01, 2008 at 02:32:38PM -0800, Andrew G. Morgan wrote:
|> +	if (info == SEND_SIG_NOINFO
|> +	    || (!is_si_special(info) && SI_FROMUSER(info))) {
|> +		 /* Let audit system see the signal */
|> +		error = audit_signal_info(sig, t);
|>  		if (error)
|>  			return error;
|>  		error = -EPERM;
|> -		if (((sig != SIGCONT) ||
|> -			(task_session_nr(current) != task_session_nr(t)))
|> +		if (((sig != SIGCONT)
|> +		     || (task_session_nr(current) != task_session_nr(t)))
|>  		    && (current->euid ^ t->suid) && (current->euid ^ t->uid)
|>  		    && (current->uid ^ t->suid) && (current->uid ^ t->uid)
|>  		    && !capable(CAP_KILL))
|> -		return error;
|> +			return error;
|
| If you start reformmating it please get it completely right:
|
| 	if (info == SEND_SIG_NOINFO ||
| 	    (!is_si_special(info) && SI_FROMUSER(info))) {
| 		/* Let audit system see the signal */
| 		error = audit_signal_info(sig, t);
|  		if (error)
|  			return error;
|  		error = -EPERM;
| 		if ((sig != SIGCONT ||
| 		     (task_session_nr(current) != task_session_nr(t))) &&
| 		    (current->euid ^ t->suid) && (current->euid ^ t->uid) &&
| 		    (current->uid ^ t->suid) && (current->uid ^ t->uid) &&
| 		    !capable(CAP_KILL))
| 			return error;
|  	}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFHyjfn+bHCR3gb8jsRAuilAJ9QJKsEQz66UrFtLOCcHVokGcVV7wCeP0HE
ftOI2APLX1YpWiznyhLfN6U=
=HGa0
-----END PGP SIGNATURE-----

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

* Re: [PATCH] cleanup: correct tabbing of check_kill_permission()
  2008-03-02  5:15   ` Andrew G. Morgan
@ 2008-03-02  8:16     ` Adrian Bunk
  0 siblings, 0 replies; 4+ messages in thread
From: Adrian Bunk @ 2008-03-02  8:16 UTC (permalink / raw)
  To: Andrew G. Morgan; +Cc: Christoph Hellwig, Andrew Morton, lkml

On Sat, Mar 01, 2008 at 09:15:19PM -0800, Andrew G. Morgan wrote:
>...
> I ran it through scripts/checkpatch.pl - it said it was ok
>...

checkpatch is just a tool pointing to some common mistakes, not the 
definite authority for proving that code is stylistically correct.

Similar to the fact that I hope you wouldn't claim your code was working 
correctly only because gcc compiled it without warnings...

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


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

end of thread, other threads:[~2008-03-02  8:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-01 22:32 [PATCH] cleanup: correct tabbing of check_kill_permission() Andrew G. Morgan
2008-03-02  0:49 ` Christoph Hellwig
2008-03-02  5:15   ` Andrew G. Morgan
2008-03-02  8:16     ` Adrian Bunk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).