mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, xemul@openvz.org, roland@redhat.com
Subject: [PATCH] consolidate-checking-for-ignored-legacy-signals-simplify
Date: Wed, 13 Feb 2008 17:00:04 +0300	[thread overview]
Message-ID: <20080213140004.GA846@tv-sign.ru> (raw)
In-Reply-To: <200802122142.m1CLgrkp023736@imap1.linux-foundation.org>

Every user of send_signal() must check ret twice. Change the meaning of the
returned value, so that ret <= 0 means we can just return, and ret == 1 means
the signal was queued. Saves a couple of if's and imho makes the code more
logical.

Also, remove now unneeded "ret = 0" initializions.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Acked-by: Pavel Emelyanov <xemul@openvz.org>

--- t/kernel/signal.c	2008-02-12 15:10:07.814848687 +0300
+++ t/kernel/signal.c	2008-02-12 15:09:14.000000000 +0300
@@ -673,7 +673,7 @@ static int send_signal(int sig, struct s
 	 * detailed information about the cause of the signal.
 	 */
 	if (sig_ignored(t, sig) || legacy_queue(signals, sig))
-		return 1;
+		return 0;
 
 	/*
 	 * Deliver the signal to listening signalfds. This must be called
@@ -731,7 +731,7 @@ static int send_signal(int sig, struct s
 
 out_set:
 	sigaddset(&signals->signal, sig);
-	return 0;
+	return 1;
 }
 
 int print_fatal_signals;
@@ -769,16 +769,16 @@ __setup("print-fatal-signals=", setup_pr
 static int
 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
 {
-	int ret = 0;
+	int ret;
 
 	BUG_ON(!irqs_disabled());
 	assert_spin_locked(&t->sighand->siglock);
 
 	ret = send_signal(sig, info, t, &t->pending);
-	if (ret < 0)
+	if (ret <= 0)
 		return ret;
 
-	if (!ret && !sigismember(&t->blocked, sig))
+	if (!sigismember(&t->blocked, sig))
 		signal_wake_up(t, sig == SIGKILL);
 	return 0;
 }
@@ -946,7 +946,7 @@ __group_complete_signal(int sig, struct 
 int
 __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
 {
-	int ret = 0;
+	int ret;
 
 	assert_spin_locked(&p->sighand->siglock);
 	handle_stop_signal(sig, p);
@@ -957,11 +957,10 @@ __group_send_sig_info(int sig, struct si
 	 * to avoid several races.
 	 */
 	ret = send_signal(sig, info, p, &p->signal->shared_pending);
-	if (unlikely(ret < 0))
+	if (ret <= 0)
 		return ret;
 
-	if (!ret)
-		__group_complete_signal(sig, p);
+	__group_complete_signal(sig, p);
 	return 0;
 }
 


           reply	other threads:[~2008-02-13 13:56 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <200802122142.m1CLgrkp023736@imap1.linux-foundation.org>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080213140004.GA846@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@redhat.com \
    --cc=xemul@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®