linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: josh@joshtriplett.org
To: Pranith Kumar <bobby.prani@gmail.com>
Cc: paulmck@linux.vnet.ibm.com, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 4/5] kernel/rcu/tree.c:3435 fix a sparse warning
Date: Wed, 11 Jun 2014 14:25:40 -0700	[thread overview]
Message-ID: <20140611212540.GA16940@cloud> (raw)
In-Reply-To: <1402519183-12752-5-git-send-email-bobby.prani@gmail.com>

On Wed, Jun 11, 2014 at 04:39:42PM -0400, Pranith Kumar wrote:
> kernel/rcu/tree.c:3435:21: warning: incorrect type in argument 1 (different modifiers)
> kernel/rcu/tree.c:3435:21:    expected int ( *threadfn )( ... )
> kernel/rcu/tree.c:3435:21:    got int ( static [toplevel] [noreturn] *<noident> )( ... )
> 
> by removing __noreturn attribute and adding unreachable() as suggested on the
> mailing list: http://www.kernelhub.org/?p=2&msg=436683
> 
> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>

No, we should not do this.  And the mailing list post you point to seems
to explicitly recommend using noreturn rather than unreachable.

If sparse doesn't understand this, that's a bug in sparse, not in the
kernel.  Sparse needs to understand that it's OK to drop noreturn from a
function pointer type, just not OK to add it.

Rationale: If you call a noreturn function through a non-noreturn
function pointer, you might end up with unnecessary cleanup code, but
the call will work.  If you call a non-noreturn function through a
noreturn function pointer, the caller will not expect a return, and may
crash; *that* should require a cast.

>  kernel/rcu/tree.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index 9ab84d3..6029a2e 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -1689,7 +1689,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
>  /*
>   * Body of kthread that handles grace periods.
>   */
> -static int __noreturn rcu_gp_kthread(void *arg)
> +static int rcu_gp_kthread(void *arg)
>  {
>  	int fqs_state;
>  	int gf;
> @@ -1777,6 +1777,9 @@ static int __noreturn rcu_gp_kthread(void *arg)
>  		/* Handle grace-period end. */
>  		rcu_gp_cleanup(rsp);
>  	}
> +
> +	unreachable();
> +	return 0;
>  }
>  
>  /*
> -- 
> 1.9.1
> 

  reply	other threads:[~2014-06-11 21:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11 20:39 [RFC PATCH 0/5] rcu: fix sparse warnings Pranith Kumar
2014-06-11 20:39 ` [RFC PATCH 1/5] kernel/rcu/tree.c:1272 fix a sparse warning Pranith Kumar
2014-06-12 23:16   ` Paul E. McKenney
2014-06-13  4:54     ` Pranith Kumar
2014-06-13  5:52       ` Pranith Kumar
2014-06-11 20:39 ` [RFC PATCH 2/5] kernel/rcu/tree_plugin.h:1494 " Pranith Kumar
2014-06-26 19:39   ` Paul E. McKenney
2014-06-11 20:39 ` [RFC PATCH 3/5] kernel/rcu/tree_plugin.h:990 " Pranith Kumar
2014-06-26 19:39   ` Paul E. McKenney
2014-06-11 20:39 ` [RFC PATCH 4/5] kernel/rcu/tree.c:3435 " Pranith Kumar
2014-06-11 21:25   ` josh [this message]
2014-06-12  1:37     ` Pranith Kumar
2014-06-11 20:39 ` [RFC PATCH 5/5] kernel/rcu/rcutorture.c:185 " Pranith Kumar
2014-06-11 21:47   ` josh
2014-07-08 22:35     ` Paul E. McKenney
2014-07-08 22:46       ` Pranith Kumar

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=20140611212540.GA16940@cloud \
    --to=josh@joshtriplett.org \
    --cc=bobby.prani@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).