All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add a comment to indicate valid fallthrough
@ 2017-04-19 19:13 Khem Raj
  2017-04-28 15:16 ` Khem Raj
  0 siblings, 1 reply; 2+ messages in thread
From: Khem Raj @ 2017-04-19 19:13 UTC (permalink / raw)
  To: linux-raid; +Cc: Khem Raj

gcc7 warns about code with fallthroughs, this patch adds
the comment to indicate a valid fallthrough, helps gcc7
compiler warnings

This works in cross and native compilation case

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 Grow.c        | 4 ++++
 bitmap.c      | 8 ++++++++
 mdadm.c       | 2 ++
 super-intel.c | 1 +
 util.c        | 1 +
 5 files changed, 16 insertions(+)

diff --git a/Grow.c b/Grow.c
index 455c5f9..27c73b1 100755
--- a/Grow.c
+++ b/Grow.c
@@ -1257,6 +1257,7 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
 		switch (info->new_level) {
 		case 4:
 			delta_parity = 1;
+			/* fallthrough */
 		case 0:
 			re->level = 4;
 			re->before.layout = 0;
@@ -1284,10 +1285,12 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
 
 	case 4:
 		info->array.layout = ALGORITHM_PARITY_N;
+		/* fallthrough */
 	case 5:
 		switch (info->new_level) {
 		case 0:
 			delta_parity = -1;
+			/* fallthrough */
 		case 4:
 			re->level = info->array.level;
 			re->before.data_disks = info->array.raid_disks - 1;
@@ -1343,6 +1346,7 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
 		case 4:
 		case 5:
 			delta_parity = -1;
+			/* fallthrough */
 		case 6:
 			re->level = 6;
 			re->before.data_disks = info->array.raid_disks - 2;
diff --git a/bitmap.c b/bitmap.c
index ccedfd3..a6ff091 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -82,13 +82,21 @@ static inline int count_dirty_bits_byte(char byte, int num_bits)
 
 	switch (num_bits) { /* fall through... */
 		case 8:	if (byte & 128) num++;
+		/* fallthrough */
 		case 7:	if (byte &  64) num++;
+		/* fallthrough */
 		case 6:	if (byte &  32) num++;
+		/* fallthrough */
 		case 5:	if (byte &  16) num++;
+		/* fallthrough */
 		case 4:	if (byte &   8) num++;
+		/* fallthrough */
 		case 3: if (byte &   4) num++;
+		/* fallthrough */
 		case 2:	if (byte &   2) num++;
+		/* fallthrough */
 		case 1:	if (byte &   1) num++;
+		/* fallthrough */
 		default: break;
 	}
 
diff --git a/mdadm.c b/mdadm.c
index c3a265b..2d06d3b 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -148,6 +148,7 @@ int main(int argc, char *argv[])
 			    mode == CREATE || mode == GROW ||
 			    mode == INCREMENTAL || mode == MANAGE)
 				break; /* b means bitmap */
+		/* fallthrough */
 		case Brief:
 			c.brief = 1;
 			continue;
@@ -828,6 +829,7 @@ int main(int argc, char *argv[])
 
 		case O(INCREMENTAL,NoDegraded):
 			pr_err("--no-degraded is deprecated in Incremental mode\n");
+			/* fallthrough */
 		case O(ASSEMBLE,NoDegraded): /* --no-degraded */
 			c.runstop = -1; /* --stop isn't allowed for --assemble,
 					 * so we overload slightly */
diff --git a/super-intel.c b/super-intel.c
index 4e466ff..00a2925 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -3271,6 +3271,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
 						<< SECT_PER_MB_SHIFT;
 			}
 		}
+		/* fallthrough */
 		case MIGR_VERIFY:
 			/* we could emulate the checkpointing of
 			 * 'sync_action=check' migrations, but for now
diff --git a/util.c b/util.c
index 32bd909..f2a4d19 100644
--- a/util.c
+++ b/util.c
@@ -335,6 +335,7 @@ unsigned long long parse_size(char *size)
 		switch (*c) {
 		case 'K':
 			c++;
+		/* fallthrough */
 		default:
 			s *= 2;
 			break;
-- 
2.12.2


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

* Re: [PATCH] Add a comment to indicate valid fallthrough
  2017-04-19 19:13 [PATCH] Add a comment to indicate valid fallthrough Khem Raj
@ 2017-04-28 15:16 ` Khem Raj
  0 siblings, 0 replies; 2+ messages in thread
From: Khem Raj @ 2017-04-28 15:16 UTC (permalink / raw)
  To: linux-raid; +Cc: Khem Raj

ping

On Wed, Apr 19, 2017 at 12:13 PM, Khem Raj <raj.khem@gmail.com> wrote:
> gcc7 warns about code with fallthroughs, this patch adds
> the comment to indicate a valid fallthrough, helps gcc7
> compiler warnings
>
> This works in cross and native compilation case
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  Grow.c        | 4 ++++
>  bitmap.c      | 8 ++++++++
>  mdadm.c       | 2 ++
>  super-intel.c | 1 +
>  util.c        | 1 +
>  5 files changed, 16 insertions(+)
>
> diff --git a/Grow.c b/Grow.c
> index 455c5f9..27c73b1 100755
> --- a/Grow.c
> +++ b/Grow.c
> @@ -1257,6 +1257,7 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
>                 switch (info->new_level) {
>                 case 4:
>                         delta_parity = 1;
> +                       /* fallthrough */
>                 case 0:
>                         re->level = 4;
>                         re->before.layout = 0;
> @@ -1284,10 +1285,12 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
>
>         case 4:
>                 info->array.layout = ALGORITHM_PARITY_N;
> +               /* fallthrough */
>         case 5:
>                 switch (info->new_level) {
>                 case 0:
>                         delta_parity = -1;
> +                       /* fallthrough */
>                 case 4:
>                         re->level = info->array.level;
>                         re->before.data_disks = info->array.raid_disks - 1;
> @@ -1343,6 +1346,7 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
>                 case 4:
>                 case 5:
>                         delta_parity = -1;
> +                       /* fallthrough */
>                 case 6:
>                         re->level = 6;
>                         re->before.data_disks = info->array.raid_disks - 2;
> diff --git a/bitmap.c b/bitmap.c
> index ccedfd3..a6ff091 100644
> --- a/bitmap.c
> +++ b/bitmap.c
> @@ -82,13 +82,21 @@ static inline int count_dirty_bits_byte(char byte, int num_bits)
>
>         switch (num_bits) { /* fall through... */
>                 case 8: if (byte & 128) num++;
> +               /* fallthrough */
>                 case 7: if (byte &  64) num++;
> +               /* fallthrough */
>                 case 6: if (byte &  32) num++;
> +               /* fallthrough */
>                 case 5: if (byte &  16) num++;
> +               /* fallthrough */
>                 case 4: if (byte &   8) num++;
> +               /* fallthrough */
>                 case 3: if (byte &   4) num++;
> +               /* fallthrough */
>                 case 2: if (byte &   2) num++;
> +               /* fallthrough */
>                 case 1: if (byte &   1) num++;
> +               /* fallthrough */
>                 default: break;
>         }
>
> diff --git a/mdadm.c b/mdadm.c
> index c3a265b..2d06d3b 100644
> --- a/mdadm.c
> +++ b/mdadm.c
> @@ -148,6 +148,7 @@ int main(int argc, char *argv[])
>                             mode == CREATE || mode == GROW ||
>                             mode == INCREMENTAL || mode == MANAGE)
>                                 break; /* b means bitmap */
> +               /* fallthrough */
>                 case Brief:
>                         c.brief = 1;
>                         continue;
> @@ -828,6 +829,7 @@ int main(int argc, char *argv[])
>
>                 case O(INCREMENTAL,NoDegraded):
>                         pr_err("--no-degraded is deprecated in Incremental mode\n");
> +                       /* fallthrough */
>                 case O(ASSEMBLE,NoDegraded): /* --no-degraded */
>                         c.runstop = -1; /* --stop isn't allowed for --assemble,
>                                          * so we overload slightly */
> diff --git a/super-intel.c b/super-intel.c
> index 4e466ff..00a2925 100644
> --- a/super-intel.c
> +++ b/super-intel.c
> @@ -3271,6 +3271,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
>                                                 << SECT_PER_MB_SHIFT;
>                         }
>                 }
> +               /* fallthrough */
>                 case MIGR_VERIFY:
>                         /* we could emulate the checkpointing of
>                          * 'sync_action=check' migrations, but for now
> diff --git a/util.c b/util.c
> index 32bd909..f2a4d19 100644
> --- a/util.c
> +++ b/util.c
> @@ -335,6 +335,7 @@ unsigned long long parse_size(char *size)
>                 switch (*c) {
>                 case 'K':
>                         c++;
> +               /* fallthrough */
>                 default:
>                         s *= 2;
>                         break;
> --
> 2.12.2
>

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

end of thread, other threads:[~2017-04-28 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-19 19:13 [PATCH] Add a comment to indicate valid fallthrough Khem Raj
2017-04-28 15:16 ` Khem Raj

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.