linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Mathieu Malaterre <malat@debian.org>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] lib/siphash.c: annotate implicit fall throughs
Date: Wed, 13 Mar 2019 18:50:57 -0700	[thread overview]
Message-ID: <f7497e7ee0365364e8215d8ee3436812f75096c4.camel@perches.com> (raw)
In-Reply-To: <20190313211230.17527-1-malat@debian.org>

On Wed, 2019-03-13 at 22:12 +0100, Mathieu Malaterre wrote:
> There is a plan to build the kernel with -Wimplicit-fallthrough and
> these places in the code produced warnings (W=1). Fix them up.
> 
> This commit remove the following warnings:
> 
>   lib/siphash.c:71:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
>   lib/siphash.c:72:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
>   lib/siphash.c:73:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
>   lib/siphash.c:75:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
>   lib/siphash.c:108:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
>   lib/siphash.c:109:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
>   lib/siphash.c:110:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
>   lib/siphash.c:112:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
>   lib/siphash.c:434:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
>   lib/siphash.c:462:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
> 
> Move the break statement onto the next line to match the fall-through
> comment pattern. Also move the trailing statement onto the next line to
> pass checkpatch verification.
[]
> diff --git a/lib/siphash.c b/lib/siphash.c
[].
> @@ -68,13 +68,26 @@ u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key)
>  						  bytemask_from_count(left)));
>  #else
>  	switch (left) {
> -	case 7: b |= ((u64)end[6]) << 48;
> -	case 6: b |= ((u64)end[5]) << 40;
> -	case 5: b |= ((u64)end[4]) << 32;

It might also be worth not casting to u64 then shift
as that can be
moderately expensive on 32 bit systems
and instead use ((char
*)&b)[<appropriate_index>].

> -	case 4: b |= le32_to_cpup(data); break;
> -	case 3: b |= ((u64)end[2]) << 16;

Perhaps an unnecessary cast before shift

> -	case 2: b |= le16_to_cpup(data); break;
> -	case 1: b |= end[0];

[]

> @@ -101,13 +114,26 @@ u64 __siphash_unaligned(const void *data, size_t len, const siphash_key_t *key)
>  						  bytemask_from_count(left)));
>  #else
>  	switch (left) {
> -	case 7: b |= ((u64)end[6]) << 48;
> -	case 6: b |= ((u64)end[5]) << 40;
> -	case 5: b |= ((u64)end[4]) << 32;

etc...

> -	case 4: b |= get_unaligned_le32(end); break;
> -	case 3: b |= ((u64)end[2]) << 16;
> -	case 2: b |= get_unaligned_le16(end); break;
> -	case 1: b |= end[0];



  reply	other threads:[~2019-03-14  1:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-14 20:19 [PATCH] lib/siphash.c:: annotate implicit fall throughs Mathieu Malaterre
2019-01-14 21:04 ` Gustavo A. R. Silva
2019-03-13 20:24 ` [PATCH v2] lib/siphash.c: " Mathieu Malaterre
2019-03-13 20:34   ` Jason A. Donenfeld
2019-03-13 20:44     ` Gustavo A. R. Silva
2019-03-13 20:52     ` Mathieu Malaterre
2019-03-13 21:12 ` [PATCH v3] " Mathieu Malaterre
2019-03-14  1:50   ` Joe Perches [this message]
2019-03-14  7:01   ` Jason A. Donenfeld

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=f7497e7ee0365364e8215d8ee3436812f75096c4.camel@perches.com \
    --to=joe@perches.com \
    --cc=Jason@zx2c4.com \
    --cc=gustavo@embeddedor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=malat@debian.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;
as well as URLs for NNTP newsgroup(s).