diff mbox series

[2/2] arm64: KVM: hyp: debug-sr: Mark expected switch fall-through

Message ID 20190726112710.19051-1-anders.roxell@linaro.org
State New
Headers show
Series [1/2] drm: sun4i: sun6i_mipi_dsi: Mark expected switch fall-through | expand

Commit Message

Anders Roxell July 26, 2019, 11:27 a.m. UTC
When fall-through warnings was enabled by default the following warnings
was starting to show up:

../arch/arm64/kvm/hyp/debug-sr.c: In function ‘__debug_save_state’:
../arch/arm64/kvm/hyp/debug-sr.c:20:19: warning: this statement may fall
 through [-Wimplicit-fallthrough=]
  case 15: ptr[15] = read_debug(reg, 15);   \
../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’
  save_debug(dbg->dbg_bcr, dbgbcr, brps);
  ^~~~~~~~~~
../arch/arm64/kvm/hyp/debug-sr.c:21:2: note: here
  case 14: ptr[14] = read_debug(reg, 14);   \
  ^~~~
../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’
  save_debug(dbg->dbg_bcr, dbgbcr, brps);
  ^~~~~~~~~~
../arch/arm64/kvm/hyp/debug-sr.c:21:19: warning: this statement may fall
 through [-Wimplicit-fallthrough=]
  case 14: ptr[14] = read_debug(reg, 14);   \
../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’
  save_debug(dbg->dbg_bcr, dbgbcr, brps);
  ^~~~~~~~~~
../arch/arm64/kvm/hyp/debug-sr.c:22:2: note: here
  case 13: ptr[13] = read_debug(reg, 13);   \
  ^~~~
../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’
  save_debug(dbg->dbg_bcr, dbgbcr, brps);
  ^~~~~~~~~~

Rework to add a 'break;' where the compiler warned about fall-through.

Fixes: d93512ef0f0e ("Makefile: Globally enable fall-through warning")
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>

---
 arch/arm64/kvm/hyp/debug-sr.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

-- 
2.20.1

Comments

Marc Zyngier July 26, 2019, 12:31 p.m. UTC | #1
On Fri, 26 Jul 2019 12:27:10 +0100,
Anders Roxell <anders.roxell@linaro.org> wrote:
> 

> When fall-through warnings was enabled by default the following warnings

> was starting to show up:

> 

> ../arch/arm64/kvm/hyp/debug-sr.c: In function ‘__debug_save_state’:

> ../arch/arm64/kvm/hyp/debug-sr.c:20:19: warning: this statement may fall

>  through [-Wimplicit-fallthrough=]

>   case 15: ptr[15] = read_debug(reg, 15);   \

> ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

>   save_debug(dbg->dbg_bcr, dbgbcr, brps);

>   ^~~~~~~~~~

> ../arch/arm64/kvm/hyp/debug-sr.c:21:2: note: here

>   case 14: ptr[14] = read_debug(reg, 14);   \

>   ^~~~

> ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

>   save_debug(dbg->dbg_bcr, dbgbcr, brps);

>   ^~~~~~~~~~

> ../arch/arm64/kvm/hyp/debug-sr.c:21:19: warning: this statement may fall

>  through [-Wimplicit-fallthrough=]

>   case 14: ptr[14] = read_debug(reg, 14);   \

> ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

>   save_debug(dbg->dbg_bcr, dbgbcr, brps);

>   ^~~~~~~~~~

> ../arch/arm64/kvm/hyp/debug-sr.c:22:2: note: here

>   case 13: ptr[13] = read_debug(reg, 13);   \

>   ^~~~

> ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

>   save_debug(dbg->dbg_bcr, dbgbcr, brps);

>   ^~~~~~~~~~

> 

> Rework to add a 'break;' where the compiler warned about

> fall-through.


That's not what this patch does, I'm afraid.

Thanks,

	M.

> 

> Fixes: d93512ef0f0e ("Makefile: Globally enable fall-through warning")

> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>

> ---

>  arch/arm64/kvm/hyp/debug-sr.c | 30 ++++++++++++++++++++++++++++++

>  1 file changed, 30 insertions(+)

> 

> diff --git a/arch/arm64/kvm/hyp/debug-sr.c b/arch/arm64/kvm/hyp/debug-sr.c

> index 26781da3ad3e..0fc9872a1467 100644

> --- a/arch/arm64/kvm/hyp/debug-sr.c

> +++ b/arch/arm64/kvm/hyp/debug-sr.c

> @@ -18,40 +18,70 @@

>  #define save_debug(ptr,reg,nr)						\

>  	switch (nr) {							\

>  	case 15:	ptr[15] = read_debug(reg, 15);			\

> +			/* Fall through */				\

>  	case 14:	ptr[14] = read_debug(reg, 14);			\

> +			/* Fall through */				\

>  	case 13:	ptr[13] = read_debug(reg, 13);			\

> +			/* Fall through */				\

>  	case 12:	ptr[12] = read_debug(reg, 12);			\

> +			/* Fall through */				\

>  	case 11:	ptr[11] = read_debug(reg, 11);			\

> +			/* Fall through */				\

>  	case 10:	ptr[10] = read_debug(reg, 10);			\

> +			/* Fall through */				\

>  	case 9:		ptr[9] = read_debug(reg, 9);			\

> +			/* Fall through */				\

>  	case 8:		ptr[8] = read_debug(reg, 8);			\

> +			/* Fall through */				\

>  	case 7:		ptr[7] = read_debug(reg, 7);			\

> +			/* Fall through */				\

>  	case 6:		ptr[6] = read_debug(reg, 6);			\

> +			/* Fall through */				\

>  	case 5:		ptr[5] = read_debug(reg, 5);			\

> +			/* Fall through */				\

>  	case 4:		ptr[4] = read_debug(reg, 4);			\

> +			/* Fall through */				\

>  	case 3:		ptr[3] = read_debug(reg, 3);			\

> +			/* Fall through */				\

>  	case 2:		ptr[2] = read_debug(reg, 2);			\

> +			/* Fall through */				\

>  	case 1:		ptr[1] = read_debug(reg, 1);			\

> +			/* Fall through */				\

>  	default:	ptr[0] = read_debug(reg, 0);			\

>  	}

>  

>  #define restore_debug(ptr,reg,nr)					\

>  	switch (nr) {							\

>  	case 15:	write_debug(ptr[15], reg, 15);			\

> +			/* Fall through */				\

>  	case 14:	write_debug(ptr[14], reg, 14);			\

> +			/* Fall through */				\

>  	case 13:	write_debug(ptr[13], reg, 13);			\

> +			/* Fall through */				\

>  	case 12:	write_debug(ptr[12], reg, 12);			\

> +			/* Fall through */				\

>  	case 11:	write_debug(ptr[11], reg, 11);			\

> +			/* Fall through */				\

>  	case 10:	write_debug(ptr[10], reg, 10);			\

> +			/* Fall through */				\

>  	case 9:		write_debug(ptr[9], reg, 9);			\

> +			/* Fall through */				\

>  	case 8:		write_debug(ptr[8], reg, 8);			\

> +			/* Fall through */				\

>  	case 7:		write_debug(ptr[7], reg, 7);			\

> +			/* Fall through */				\

>  	case 6:		write_debug(ptr[6], reg, 6);			\

> +			/* Fall through */				\

>  	case 5:		write_debug(ptr[5], reg, 5);			\

> +			/* Fall through */				\

>  	case 4:		write_debug(ptr[4], reg, 4);			\

> +			/* Fall through */				\

>  	case 3:		write_debug(ptr[3], reg, 3);			\

> +			/* Fall through */				\

>  	case 2:		write_debug(ptr[2], reg, 2);			\

> +			/* Fall through */				\

>  	case 1:		write_debug(ptr[1], reg, 1);			\

> +			/* Fall through */				\

>  	default:	write_debug(ptr[0], reg, 0);			\

>  	}

>  

> -- 

> 2.20.1

> 


-- 
Jazz is not dead, it just smells funny.
Anders Roxell July 26, 2019, 2:11 p.m. UTC | #2
On Fri, 26 Jul 2019 at 14:31, Marc Zyngier <marc.zyngier@arm.com> wrote:
>

> On Fri, 26 Jul 2019 12:27:10 +0100,

> Anders Roxell <anders.roxell@linaro.org> wrote:

> >

> > When fall-through warnings was enabled by default the following warnings

> > was starting to show up:

> >

> > ../arch/arm64/kvm/hyp/debug-sr.c: In function ‘__debug_save_state’:

> > ../arch/arm64/kvm/hyp/debug-sr.c:20:19: warning: this statement may fall

> >  through [-Wimplicit-fallthrough=]

> >   case 15: ptr[15] = read_debug(reg, 15);   \

> > ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

> >   save_debug(dbg->dbg_bcr, dbgbcr, brps);

> >   ^~~~~~~~~~

> > ../arch/arm64/kvm/hyp/debug-sr.c:21:2: note: here

> >   case 14: ptr[14] = read_debug(reg, 14);   \

> >   ^~~~

> > ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

> >   save_debug(dbg->dbg_bcr, dbgbcr, brps);

> >   ^~~~~~~~~~

> > ../arch/arm64/kvm/hyp/debug-sr.c:21:19: warning: this statement may fall

> >  through [-Wimplicit-fallthrough=]

> >   case 14: ptr[14] = read_debug(reg, 14);   \

> > ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

> >   save_debug(dbg->dbg_bcr, dbgbcr, brps);

> >   ^~~~~~~~~~

> > ../arch/arm64/kvm/hyp/debug-sr.c:22:2: note: here

> >   case 13: ptr[13] = read_debug(reg, 13);   \

> >   ^~~~

> > ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

> >   save_debug(dbg->dbg_bcr, dbgbcr, brps);

> >   ^~~~~~~~~~

> >

> > Rework to add a 'break;' where the compiler warned about

> > fall-through.

>

> That's not what this patch does, I'm afraid.


urgh I'm sorry.
Sending a v2 shortly.

>

> Thanks,

>

>         M.

>

> >

> > Fixes: d93512ef0f0e ("Makefile: Globally enable fall-through warning")

> > Signed-off-by: Anders Roxell <anders.roxell@linaro.org>

> > ---

> >  arch/arm64/kvm/hyp/debug-sr.c | 30 ++++++++++++++++++++++++++++++

> >  1 file changed, 30 insertions(+)

> >

> > diff --git a/arch/arm64/kvm/hyp/debug-sr.c b/arch/arm64/kvm/hyp/debug-sr.c

> > index 26781da3ad3e..0fc9872a1467 100644

> > --- a/arch/arm64/kvm/hyp/debug-sr.c

> > +++ b/arch/arm64/kvm/hyp/debug-sr.c

> > @@ -18,40 +18,70 @@

> >  #define save_debug(ptr,reg,nr)                                               \

> >       switch (nr) {                                                   \

> >       case 15:        ptr[15] = read_debug(reg, 15);                  \

> > +                     /* Fall through */                              \

> >       case 14:        ptr[14] = read_debug(reg, 14);                  \

> > +                     /* Fall through */                              \

> >       case 13:        ptr[13] = read_debug(reg, 13);                  \

> > +                     /* Fall through */                              \

> >       case 12:        ptr[12] = read_debug(reg, 12);                  \

> > +                     /* Fall through */                              \

> >       case 11:        ptr[11] = read_debug(reg, 11);                  \

> > +                     /* Fall through */                              \

> >       case 10:        ptr[10] = read_debug(reg, 10);                  \

> > +                     /* Fall through */                              \

> >       case 9:         ptr[9] = read_debug(reg, 9);                    \

> > +                     /* Fall through */                              \

> >       case 8:         ptr[8] = read_debug(reg, 8);                    \

> > +                     /* Fall through */                              \

> >       case 7:         ptr[7] = read_debug(reg, 7);                    \

> > +                     /* Fall through */                              \

> >       case 6:         ptr[6] = read_debug(reg, 6);                    \

> > +                     /* Fall through */                              \

> >       case 5:         ptr[5] = read_debug(reg, 5);                    \

> > +                     /* Fall through */                              \

> >       case 4:         ptr[4] = read_debug(reg, 4);                    \

> > +                     /* Fall through */                              \

> >       case 3:         ptr[3] = read_debug(reg, 3);                    \

> > +                     /* Fall through */                              \

> >       case 2:         ptr[2] = read_debug(reg, 2);                    \

> > +                     /* Fall through */                              \

> >       case 1:         ptr[1] = read_debug(reg, 1);                    \

> > +                     /* Fall through */                              \

> >       default:        ptr[0] = read_debug(reg, 0);                    \

> >       }

> >

> >  #define restore_debug(ptr,reg,nr)                                    \

> >       switch (nr) {                                                   \

> >       case 15:        write_debug(ptr[15], reg, 15);                  \

> > +                     /* Fall through */                              \

> >       case 14:        write_debug(ptr[14], reg, 14);                  \

> > +                     /* Fall through */                              \

> >       case 13:        write_debug(ptr[13], reg, 13);                  \

> > +                     /* Fall through */                              \

> >       case 12:        write_debug(ptr[12], reg, 12);                  \

> > +                     /* Fall through */                              \

> >       case 11:        write_debug(ptr[11], reg, 11);                  \

> > +                     /* Fall through */                              \

> >       case 10:        write_debug(ptr[10], reg, 10);                  \

> > +                     /* Fall through */                              \

> >       case 9:         write_debug(ptr[9], reg, 9);                    \

> > +                     /* Fall through */                              \

> >       case 8:         write_debug(ptr[8], reg, 8);                    \

> > +                     /* Fall through */                              \

> >       case 7:         write_debug(ptr[7], reg, 7);                    \

> > +                     /* Fall through */                              \

> >       case 6:         write_debug(ptr[6], reg, 6);                    \

> > +                     /* Fall through */                              \

> >       case 5:         write_debug(ptr[5], reg, 5);                    \

> > +                     /* Fall through */                              \

> >       case 4:         write_debug(ptr[4], reg, 4);                    \

> > +                     /* Fall through */                              \

> >       case 3:         write_debug(ptr[3], reg, 3);                    \

> > +                     /* Fall through */                              \

> >       case 2:         write_debug(ptr[2], reg, 2);                    \

> > +                     /* Fall through */                              \

> >       case 1:         write_debug(ptr[1], reg, 1);                    \

> > +                     /* Fall through */                              \

> >       default:        write_debug(ptr[0], reg, 0);                    \

> >       }

> >

> > --

> > 2.20.1

> >

>

> --

> Jazz is not dead, it just smells funny.
Marc Zyngier July 29, 2019, 9:49 a.m. UTC | #3
On Fri, 26 Jul 2019 15:11:05 +0100,
Anders Roxell <anders.roxell@linaro.org> wrote:
> 

> On Fri, 26 Jul 2019 at 14:31, Marc Zyngier <marc.zyngier@arm.com> wrote:

> >

> > On Fri, 26 Jul 2019 12:27:10 +0100,

> > Anders Roxell <anders.roxell@linaro.org> wrote:

> > >

> > > When fall-through warnings was enabled by default the following warnings

> > > was starting to show up:

> > >

> > > ../arch/arm64/kvm/hyp/debug-sr.c: In function ‘__debug_save_state’:

> > > ../arch/arm64/kvm/hyp/debug-sr.c:20:19: warning: this statement may fall

> > >  through [-Wimplicit-fallthrough=]

> > >   case 15: ptr[15] = read_debug(reg, 15);   \

> > > ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

> > >   save_debug(dbg->dbg_bcr, dbgbcr, brps);

> > >   ^~~~~~~~~~

> > > ../arch/arm64/kvm/hyp/debug-sr.c:21:2: note: here

> > >   case 14: ptr[14] = read_debug(reg, 14);   \

> > >   ^~~~

> > > ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

> > >   save_debug(dbg->dbg_bcr, dbgbcr, brps);

> > >   ^~~~~~~~~~

> > > ../arch/arm64/kvm/hyp/debug-sr.c:21:19: warning: this statement may fall

> > >  through [-Wimplicit-fallthrough=]

> > >   case 14: ptr[14] = read_debug(reg, 14);   \

> > > ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

> > >   save_debug(dbg->dbg_bcr, dbgbcr, brps);

> > >   ^~~~~~~~~~

> > > ../arch/arm64/kvm/hyp/debug-sr.c:22:2: note: here

> > >   case 13: ptr[13] = read_debug(reg, 13);   \

> > >   ^~~~

> > > ../arch/arm64/kvm/hyp/debug-sr.c:113:2: note: in expansion of macro ‘save_debug’

> > >   save_debug(dbg->dbg_bcr, dbgbcr, brps);

> > >   ^~~~~~~~~~

> > >

> > > Rework to add a 'break;' where the compiler warned about

> > > fall-through.

> >

> > That's not what this patch does, I'm afraid.

> 

> urgh I'm sorry.

> Sending a v2 shortly.


Don't bother, I'll fix it locally.

Thanks,

	M.

-- 
Jazz is not dead, it just smells funny.
diff mbox series

Patch

diff --git a/arch/arm64/kvm/hyp/debug-sr.c b/arch/arm64/kvm/hyp/debug-sr.c
index 26781da3ad3e..0fc9872a1467 100644
--- a/arch/arm64/kvm/hyp/debug-sr.c
+++ b/arch/arm64/kvm/hyp/debug-sr.c
@@ -18,40 +18,70 @@ 
 #define save_debug(ptr,reg,nr)						\
 	switch (nr) {							\
 	case 15:	ptr[15] = read_debug(reg, 15);			\
+			/* Fall through */				\
 	case 14:	ptr[14] = read_debug(reg, 14);			\
+			/* Fall through */				\
 	case 13:	ptr[13] = read_debug(reg, 13);			\
+			/* Fall through */				\
 	case 12:	ptr[12] = read_debug(reg, 12);			\
+			/* Fall through */				\
 	case 11:	ptr[11] = read_debug(reg, 11);			\
+			/* Fall through */				\
 	case 10:	ptr[10] = read_debug(reg, 10);			\
+			/* Fall through */				\
 	case 9:		ptr[9] = read_debug(reg, 9);			\
+			/* Fall through */				\
 	case 8:		ptr[8] = read_debug(reg, 8);			\
+			/* Fall through */				\
 	case 7:		ptr[7] = read_debug(reg, 7);			\
+			/* Fall through */				\
 	case 6:		ptr[6] = read_debug(reg, 6);			\
+			/* Fall through */				\
 	case 5:		ptr[5] = read_debug(reg, 5);			\
+			/* Fall through */				\
 	case 4:		ptr[4] = read_debug(reg, 4);			\
+			/* Fall through */				\
 	case 3:		ptr[3] = read_debug(reg, 3);			\
+			/* Fall through */				\
 	case 2:		ptr[2] = read_debug(reg, 2);			\
+			/* Fall through */				\
 	case 1:		ptr[1] = read_debug(reg, 1);			\
+			/* Fall through */				\
 	default:	ptr[0] = read_debug(reg, 0);			\
 	}
 
 #define restore_debug(ptr,reg,nr)					\
 	switch (nr) {							\
 	case 15:	write_debug(ptr[15], reg, 15);			\
+			/* Fall through */				\
 	case 14:	write_debug(ptr[14], reg, 14);			\
+			/* Fall through */				\
 	case 13:	write_debug(ptr[13], reg, 13);			\
+			/* Fall through */				\
 	case 12:	write_debug(ptr[12], reg, 12);			\
+			/* Fall through */				\
 	case 11:	write_debug(ptr[11], reg, 11);			\
+			/* Fall through */				\
 	case 10:	write_debug(ptr[10], reg, 10);			\
+			/* Fall through */				\
 	case 9:		write_debug(ptr[9], reg, 9);			\
+			/* Fall through */				\
 	case 8:		write_debug(ptr[8], reg, 8);			\
+			/* Fall through */				\
 	case 7:		write_debug(ptr[7], reg, 7);			\
+			/* Fall through */				\
 	case 6:		write_debug(ptr[6], reg, 6);			\
+			/* Fall through */				\
 	case 5:		write_debug(ptr[5], reg, 5);			\
+			/* Fall through */				\
 	case 4:		write_debug(ptr[4], reg, 4);			\
+			/* Fall through */				\
 	case 3:		write_debug(ptr[3], reg, 3);			\
+			/* Fall through */				\
 	case 2:		write_debug(ptr[2], reg, 2);			\
+			/* Fall through */				\
 	case 1:		write_debug(ptr[1], reg, 1);			\
+			/* Fall through */				\
 	default:	write_debug(ptr[0], reg, 0);			\
 	}