All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Daniel Borkmann' <dborkman@redhat.com>,
	"davem@davemloft.net" <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>
Subject: RE: [PATCH net-next 5/5] net: sctp: fix incorrect type in gfp initializer
Date: Wed, 11 Jun 2014 14:55:09 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1725AF78@AcuExch.aculab.com> (raw)
In-Reply-To: <1402497297-27100-6-git-send-email-dborkman@redhat.com>

From: Daniel Borkmann
> This fixes the following sparse warning:
> 
>   net/sctp/associola.c:1556:29: warning: incorrect type in initializer (different base types)
>   net/sctp/associola.c:1556:29:    expected bool [unsigned] [usertype] preload
>   net/sctp/associola.c:1556:29:    got restricted gfp_t
...
> --- a/net/sctp/associola.c
> +++ b/net/sctp/associola.c
> @@ -1591,7 +1591,7 @@ int sctp_assoc_lookup_laddr(struct sctp_association *asoc,
>  /* Set an association id for a given association */
>  int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp)
>  {
> -	bool preload = gfp & __GFP_WAIT;
> +	bool preload = !!(gfp & __GFP_WAIT);
>  	int ret;
> 
>  	/* If the id is already assigned, keep it. */
> --

I was wondering if the compiler still manages to optimise this in a
manner that avoids actually calculating the boolean value...

So I disassembled the compilation I just did of the old code (gcc 4.7.3).
The object code looks strange.
I think that idr_preload_end() must be an empty inline function.
The compiler has duplicated the code between the two 'if (preload)'
clauses (to avoid the conditional test), and the failed to tail
merge everything in the latter stages.
I suspect that an empty '#define' would generate smaller code.

	David

  reply	other threads:[~2014-06-11 14:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11 14:34 [PATCH net-next 0/5] SCTP update Daniel Borkmann
2014-06-11 14:34 ` Daniel Borkmann
2014-06-11 14:34 ` [PATCH net-next 1/5] ktime: add ktime_after and ktime_before helper Daniel Borkmann
2014-06-11 14:34   ` Daniel Borkmann
2014-06-11 14:34 ` [PATCH net-next 2/5] net: sctp: refactor active path selection Daniel Borkmann
2014-06-11 14:34   ` Daniel Borkmann
2014-06-11 14:34 ` [PATCH net-next 3/5] net: sctp: migrate most recently used transport to ktime Daniel Borkmann
2014-06-11 14:34   ` Daniel Borkmann
2014-06-11 14:34 ` [PATCH net-next 4/5] net: sctp: improve sctp_select_active_and_retran_path selection Daniel Borkmann
2014-06-11 14:34   ` Daniel Borkmann
2014-06-11 14:34 ` [PATCH net-next 5/5] net: sctp: fix incorrect type in gfp initializer Daniel Borkmann
2014-06-11 14:34   ` Daniel Borkmann
2014-06-11 14:55   ` David Laight [this message]
2014-06-11 15:09     ` Daniel Borkmann
2014-06-11 15:09       ` Daniel Borkmann
2014-06-11 17:18       ` Alexei Starovoitov
2014-06-11 17:18         ` Alexei Starovoitov
2014-06-12  8:46         ` David Laight
2014-06-12  8:46           ` David Laight
2014-06-18 18:30           ` Tejun Heo
2014-06-18 18:30             ` Tejun Heo
2014-06-19  8:13             ` David Laight
2014-06-19 13:46               ` 'Tejun Heo'
2014-06-19 13:46                 ` 'Tejun Heo'

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=063D6719AE5E284EB5DD2968C1650D6D1725AF78@AcuExch.aculab.com \
    --to=david.laight@aculab.com \
    --cc=davem@davemloft.net \
    --cc=dborkman@redhat.com \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.