All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/siphash.c:: annotate implicit fall throughs
@ 2019-01-14 20:19 Mathieu Malaterre
  2019-01-14 21:04 ` Gustavo A. R. Silva
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Mathieu Malaterre @ 2019-01-14 20:19 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: Mathieu Malaterre, linux-kernel

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:434:12: warning: this statement may fall through [-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
 lib/siphash.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/siphash.c b/lib/siphash.c
index 3ae58b4edad6..b95624f5aa34 100644
--- a/lib/siphash.c
+++ b/lib/siphash.c
@@ -69,10 +69,14 @@ u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key)
 #else
 	switch (left) {
 	case 7: b |= ((u64)end[6]) << 48;
+		/* fall through */
 	case 6: b |= ((u64)end[5]) << 40;
+		/* fall through */
 	case 5: b |= ((u64)end[4]) << 32;
+		/* fall through */
 	case 4: b |= le32_to_cpup(data); break;
 	case 3: b |= ((u64)end[2]) << 16;
+		/* fall through */
 	case 2: b |= le16_to_cpup(data); break;
 	case 1: b |= end[0];
 	}
@@ -432,6 +436,7 @@ u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)
 	}
 	switch (left) {
 	case 3: b |= ((u32)end[2]) << 16;
+		/* fall through */
 	case 2: b |= le16_to_cpup(data); break;
 	case 1: b |= end[0];
 	}
-- 
2.19.2


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

* Re: [PATCH] lib/siphash.c:: annotate implicit fall throughs
  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 21:12 ` [PATCH v3] " Mathieu Malaterre
  2 siblings, 0 replies; 9+ messages in thread
From: Gustavo A. R. Silva @ 2019-01-14 21:04 UTC (permalink / raw)
  To: Mathieu Malaterre, Jason A. Donenfeld; +Cc: linux-kernel



On 1/14/19 2:19 PM, 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:434:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
> 
> Signed-off-by: Mathieu Malaterre <malat@debian.org>


Acked-by: Gustavo A. R. Silva <gustavo@embeddedor.com>


> ---
>   lib/siphash.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/lib/siphash.c b/lib/siphash.c
> index 3ae58b4edad6..b95624f5aa34 100644
> --- a/lib/siphash.c
> +++ b/lib/siphash.c
> @@ -69,10 +69,14 @@ u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key)
>   #else
>   	switch (left) {
>   	case 7: b |= ((u64)end[6]) << 48;
> +		/* fall through */
>   	case 6: b |= ((u64)end[5]) << 40;
> +		/* fall through */
>   	case 5: b |= ((u64)end[4]) << 32;
> +		/* fall through */
>   	case 4: b |= le32_to_cpup(data); break;
>   	case 3: b |= ((u64)end[2]) << 16;
> +		/* fall through */
>   	case 2: b |= le16_to_cpup(data); break;
>   	case 1: b |= end[0];
>   	}
> @@ -432,6 +436,7 @@ u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)
>   	}
>   	switch (left) {
>   	case 3: b |= ((u32)end[2]) << 16;
> +		/* fall through */
>   	case 2: b |= le16_to_cpup(data); break;
>   	case 1: b |= end[0];
>   	}
> 

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

* [PATCH v2] lib/siphash.c: annotate implicit fall throughs
  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 ` Mathieu Malaterre
  2019-03-13 20:34   ` Jason A. Donenfeld
  2019-03-13 21:12 ` [PATCH v3] " Mathieu Malaterre
  2 siblings, 1 reply; 9+ messages in thread
From: Mathieu Malaterre @ 2019-03-13 20:24 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: Mathieu Malaterre, Gustavo A. R. Silva, linux-kernel

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=]

Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
v2: some cases were missed in v1, update missing ones

 lib/siphash.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/siphash.c b/lib/siphash.c
index 3ae58b4edad6..f4f778d28660 100644
--- a/lib/siphash.c
+++ b/lib/siphash.c
@@ -69,10 +69,14 @@ u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key)
 #else
 	switch (left) {
 	case 7: b |= ((u64)end[6]) << 48;
+		/* fall through */
 	case 6: b |= ((u64)end[5]) << 40;
+		/* fall through */
 	case 5: b |= ((u64)end[4]) << 32;
+		/* fall through */
 	case 4: b |= le32_to_cpup(data); break;
 	case 3: b |= ((u64)end[2]) << 16;
+		/* fall through */
 	case 2: b |= le16_to_cpup(data); break;
 	case 1: b |= end[0];
 	}
@@ -102,10 +106,14 @@ u64 __siphash_unaligned(const void *data, size_t len, const siphash_key_t *key)
 #else
 	switch (left) {
 	case 7: b |= ((u64)end[6]) << 48;
+		/* fall through */
 	case 6: b |= ((u64)end[5]) << 40;
+		/* fall through */
 	case 5: b |= ((u64)end[4]) << 32;
+		/* fall through */
 	case 4: b |= get_unaligned_le32(end); break;
 	case 3: b |= ((u64)end[2]) << 16;
+		/* fall through */
 	case 2: b |= get_unaligned_le16(end); break;
 	case 1: b |= end[0];
 	}
@@ -432,6 +440,7 @@ u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)
 	}
 	switch (left) {
 	case 3: b |= ((u32)end[2]) << 16;
+		/* fall through */
 	case 2: b |= le16_to_cpup(data); break;
 	case 1: b |= end[0];
 	}
@@ -455,6 +464,7 @@ u32 __hsiphash_unaligned(const void *data, size_t len,
 	}
 	switch (left) {
 	case 3: b |= ((u32)end[2]) << 16;
+		/* fall through */
 	case 2: b |= get_unaligned_le16(end); break;
 	case 1: b |= end[0];
 	}
-- 
2.20.1


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

* Re: [PATCH v2] lib/siphash.c: annotate implicit fall throughs
  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
  0 siblings, 2 replies; 9+ messages in thread
From: Jason A. Donenfeld @ 2019-03-13 20:34 UTC (permalink / raw)
  To: Mathieu Malaterre; +Cc: Gustavo A. R. Silva, LKML

Conceptually this seems pretty reasonable. Though, style-wise, perhaps
you might want to put those breaks on the next line too, i.e. s/;
break;/;\n\t\tbreak;/?

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

* Re: [PATCH v2] lib/siphash.c: annotate implicit fall throughs
  2019-03-13 20:34   ` Jason A. Donenfeld
@ 2019-03-13 20:44     ` Gustavo A. R. Silva
  2019-03-13 20:52     ` Mathieu Malaterre
  1 sibling, 0 replies; 9+ messages in thread
From: Gustavo A. R. Silva @ 2019-03-13 20:44 UTC (permalink / raw)
  To: Jason A. Donenfeld, Mathieu Malaterre; +Cc: LKML



On 3/13/19 3:34 PM, Jason A. Donenfeld wrote:
> Conceptually this seems pretty reasonable. Though, style-wise, perhaps
> you might want to put those breaks on the next line too, i.e. s/;
> break;/;\n\t\tbreak;/?
> 

I agree.

With that, you can add my:

Acked-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Thanks
--
Gustavo

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

* Re: [PATCH v2] lib/siphash.c: annotate implicit fall throughs
  2019-03-13 20:34   ` Jason A. Donenfeld
  2019-03-13 20:44     ` Gustavo A. R. Silva
@ 2019-03-13 20:52     ` Mathieu Malaterre
  1 sibling, 0 replies; 9+ messages in thread
From: Mathieu Malaterre @ 2019-03-13 20:52 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: Gustavo A. R. Silva, LKML

On Wed, Mar 13, 2019 at 9:34 PM Jason A. Donenfeld <Jason@zx2c4.com> wrote:
>
> Conceptually this seems pretty reasonable. Though, style-wise, perhaps
> you might want to put those breaks on the next line too, i.e. s/;
> break;/;\n\t\tbreak;/?

Good point. This needs some more love since checkpatch complains now with:

ERROR: trailing statements should be on next line
#42: FILE: lib/siphash.c:77:
+ case 4: b |= le32_to_cpup(data);

Let me merge all that and send a v2.

Thanks

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

* [PATCH v3] lib/siphash.c: annotate implicit fall throughs
  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 21:12 ` Mathieu Malaterre
  2019-03-14  1:50   ` Joe Perches
  2019-03-14  7:01   ` Jason A. Donenfeld
  2 siblings, 2 replies; 9+ messages in thread
From: Mathieu Malaterre @ 2019-03-13 21:12 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: Mathieu Malaterre, Gustavo A. R. Silva, linux-kernel

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.

Acked-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
v3: move break statements onto next line and please checkpatch
v2: some cases were missed in v1, update missing ones

 lib/siphash.c | 76 +++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 56 insertions(+), 20 deletions(-)

diff --git a/lib/siphash.c b/lib/siphash.c
index 3ae58b4edad6..f459e0f4a14e 100644
--- 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;
-	case 4: b |= le32_to_cpup(data); break;
-	case 3: b |= ((u64)end[2]) << 16;
-	case 2: b |= le16_to_cpup(data); break;
-	case 1: b |= end[0];
+	case 7:
+		b |= ((u64)end[6]) << 48;
+		/* fall through */
+	case 6:
+		b |= ((u64)end[5]) << 40;
+		/* fall through */
+	case 5:
+		b |= ((u64)end[4]) << 32;
+		/* fall through */
+	case 4:
+		b |= le32_to_cpup(data);
+		break;
+	case 3:
+		b |= ((u64)end[2]) << 16;
+		/* fall through */
+	case 2:
+		b |= le16_to_cpup(data);
+		break;
+	case 1:
+		b |= end[0];
 	}
 #endif
 	POSTAMBLE
@@ -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;
-	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];
+	case 7:
+		b |= ((u64)end[6]) << 48;
+		/* fall through */
+	case 6:
+		b |= ((u64)end[5]) << 40;
+		/* fall through */
+	case 5:
+		b |= ((u64)end[4]) << 32;
+		/* fall through */
+	case 4:
+		b |= get_unaligned_le32(end);
+		break;
+	case 3:
+		b |= ((u64)end[2]) << 16;
+		/* fall through */
+	case 2:
+		b |= get_unaligned_le16(end);
+		break;
+	case 1:
+		b |= end[0];
 	}
 #endif
 	POSTAMBLE
@@ -431,9 +457,14 @@ u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)
 		v0 ^= m;
 	}
 	switch (left) {
-	case 3: b |= ((u32)end[2]) << 16;
-	case 2: b |= le16_to_cpup(data); break;
-	case 1: b |= end[0];
+	case 3:
+		b |= ((u32)end[2]) << 16;
+		/* fall through */
+	case 2:
+		b |= le16_to_cpup(data);
+		break;
+	case 1:
+		b |= end[0];
 	}
 	HPOSTAMBLE
 }
@@ -454,9 +485,14 @@ u32 __hsiphash_unaligned(const void *data, size_t len,
 		v0 ^= m;
 	}
 	switch (left) {
-	case 3: b |= ((u32)end[2]) << 16;
-	case 2: b |= get_unaligned_le16(end); break;
-	case 1: b |= end[0];
+	case 3:
+		b |= ((u32)end[2]) << 16;
+		/* fall through */
+	case 2:
+		b |= get_unaligned_le16(end);
+		break;
+	case 1:
+		b |= end[0];
 	}
 	HPOSTAMBLE
 }
-- 
2.20.1


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

* Re: [PATCH v3] lib/siphash.c: annotate implicit fall throughs
  2019-03-13 21:12 ` [PATCH v3] " Mathieu Malaterre
@ 2019-03-14  1:50   ` Joe Perches
  2019-03-14  7:01   ` Jason A. Donenfeld
  1 sibling, 0 replies; 9+ messages in thread
From: Joe Perches @ 2019-03-14  1:50 UTC (permalink / raw)
  To: Mathieu Malaterre, Jason A. Donenfeld; +Cc: Gustavo A. R. Silva, linux-kernel

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];



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

* Re: [PATCH v3] lib/siphash.c: annotate implicit fall throughs
  2019-03-13 21:12 ` [PATCH v3] " Mathieu Malaterre
  2019-03-14  1:50   ` Joe Perches
@ 2019-03-14  7:01   ` Jason A. Donenfeld
  1 sibling, 0 replies; 9+ messages in thread
From: Jason A. Donenfeld @ 2019-03-14  7:01 UTC (permalink / raw)
  To: Mathieu Malaterre; +Cc: Gustavo A. R. Silva, LKML, Greg Kroah-Hartman

Hi Mathieu,

Thanks for getting this v3 into shape.

On Wed, Mar 13, 2019 at 3:12 PM Mathieu Malaterre <malat@debian.org> 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.
>
> Acked-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
> v3: move break statements onto next line and please checkpatch
> v2: some cases were missed in v1, update missing ones
>
>  lib/siphash.c | 76 +++++++++++++++++++++++++++++++++++++--------------
>  1 file changed, 56 insertions(+), 20 deletions(-)
>
> diff --git a/lib/siphash.c b/lib/siphash.c
> index 3ae58b4edad6..f459e0f4a14e 100644
> --- 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;
> -       case 4: b |= le32_to_cpup(data); break;
> -       case 3: b |= ((u64)end[2]) << 16;
> -       case 2: b |= le16_to_cpup(data); break;
> -       case 1: b |= end[0];
> +       case 7:
> +               b |= ((u64)end[6]) << 48;
> +               /* fall through */
> +       case 6:
> +               b |= ((u64)end[5]) << 40;
> +               /* fall through */
> +       case 5:
> +               b |= ((u64)end[4]) << 32;
> +               /* fall through */
> +       case 4:
> +               b |= le32_to_cpup(data);
> +               break;
> +       case 3:
> +               b |= ((u64)end[2]) << 16;
> +               /* fall through */
> +       case 2:
> +               b |= le16_to_cpup(data);
> +               break;
> +       case 1:
> +               b |= end[0];
>         }
>  #endif
>         POSTAMBLE
> @@ -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;
> -       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];
> +       case 7:
> +               b |= ((u64)end[6]) << 48;
> +               /* fall through */
> +       case 6:
> +               b |= ((u64)end[5]) << 40;
> +               /* fall through */
> +       case 5:
> +               b |= ((u64)end[4]) << 32;
> +               /* fall through */
> +       case 4:
> +               b |= get_unaligned_le32(end);
> +               break;
> +       case 3:
> +               b |= ((u64)end[2]) << 16;
> +               /* fall through */
> +       case 2:
> +               b |= get_unaligned_le16(end);
> +               break;
> +       case 1:
> +               b |= end[0];
>         }
>  #endif
>         POSTAMBLE
> @@ -431,9 +457,14 @@ u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)
>                 v0 ^= m;
>         }
>         switch (left) {
> -       case 3: b |= ((u32)end[2]) << 16;
> -       case 2: b |= le16_to_cpup(data); break;
> -       case 1: b |= end[0];
> +       case 3:
> +               b |= ((u32)end[2]) << 16;
> +               /* fall through */
> +       case 2:
> +               b |= le16_to_cpup(data);
> +               break;
> +       case 1:
> +               b |= end[0];
>         }
>         HPOSTAMBLE
>  }
> @@ -454,9 +485,14 @@ u32 __hsiphash_unaligned(const void *data, size_t len,
>                 v0 ^= m;
>         }
>         switch (left) {
> -       case 3: b |= ((u32)end[2]) << 16;
> -       case 2: b |= get_unaligned_le16(end); break;
> -       case 1: b |= end[0];
> +       case 3:
> +               b |= ((u32)end[2]) << 16;
> +               /* fall through */
> +       case 2:
> +               b |= get_unaligned_le16(end);
> +               break;
> +       case 1:
> +               b |= end[0];
>         }
>         HPOSTAMBLE
>  }
> --
> 2.20.1

Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>

Greg - would you take this through your tree?

Jason

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

end of thread, other threads:[~2019-03-14  7:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-03-14  7:01   ` Jason A. Donenfeld

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.