Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: KVM: hyp: debug-sr: Mark expected switch fall-through

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 'Fall through' comment where the compiler warned
about fall-through, hence silencing the warning.

Fixes: d93512ef0f0e ("Makefile: Globally enable fall-through warning")
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
[maz: fixed commit message]
Signed-off-by: Marc Zyngier <maz@kernel.org>

authored by

Anders Roxell and committed by
Marc Zyngier
cdb2d3ee 6701c619

+30
+30
arch/arm64/kvm/hyp/debug-sr.c
··· 18 18 #define save_debug(ptr,reg,nr) \ 19 19 switch (nr) { \ 20 20 case 15: ptr[15] = read_debug(reg, 15); \ 21 + /* Fall through */ \ 21 22 case 14: ptr[14] = read_debug(reg, 14); \ 23 + /* Fall through */ \ 22 24 case 13: ptr[13] = read_debug(reg, 13); \ 25 + /* Fall through */ \ 23 26 case 12: ptr[12] = read_debug(reg, 12); \ 27 + /* Fall through */ \ 24 28 case 11: ptr[11] = read_debug(reg, 11); \ 29 + /* Fall through */ \ 25 30 case 10: ptr[10] = read_debug(reg, 10); \ 31 + /* Fall through */ \ 26 32 case 9: ptr[9] = read_debug(reg, 9); \ 33 + /* Fall through */ \ 27 34 case 8: ptr[8] = read_debug(reg, 8); \ 35 + /* Fall through */ \ 28 36 case 7: ptr[7] = read_debug(reg, 7); \ 37 + /* Fall through */ \ 29 38 case 6: ptr[6] = read_debug(reg, 6); \ 39 + /* Fall through */ \ 30 40 case 5: ptr[5] = read_debug(reg, 5); \ 41 + /* Fall through */ \ 31 42 case 4: ptr[4] = read_debug(reg, 4); \ 43 + /* Fall through */ \ 32 44 case 3: ptr[3] = read_debug(reg, 3); \ 45 + /* Fall through */ \ 33 46 case 2: ptr[2] = read_debug(reg, 2); \ 47 + /* Fall through */ \ 34 48 case 1: ptr[1] = read_debug(reg, 1); \ 49 + /* Fall through */ \ 35 50 default: ptr[0] = read_debug(reg, 0); \ 36 51 } 37 52 38 53 #define restore_debug(ptr,reg,nr) \ 39 54 switch (nr) { \ 40 55 case 15: write_debug(ptr[15], reg, 15); \ 56 + /* Fall through */ \ 41 57 case 14: write_debug(ptr[14], reg, 14); \ 58 + /* Fall through */ \ 42 59 case 13: write_debug(ptr[13], reg, 13); \ 60 + /* Fall through */ \ 43 61 case 12: write_debug(ptr[12], reg, 12); \ 62 + /* Fall through */ \ 44 63 case 11: write_debug(ptr[11], reg, 11); \ 64 + /* Fall through */ \ 45 65 case 10: write_debug(ptr[10], reg, 10); \ 66 + /* Fall through */ \ 46 67 case 9: write_debug(ptr[9], reg, 9); \ 68 + /* Fall through */ \ 47 69 case 8: write_debug(ptr[8], reg, 8); \ 70 + /* Fall through */ \ 48 71 case 7: write_debug(ptr[7], reg, 7); \ 72 + /* Fall through */ \ 49 73 case 6: write_debug(ptr[6], reg, 6); \ 74 + /* Fall through */ \ 50 75 case 5: write_debug(ptr[5], reg, 5); \ 76 + /* Fall through */ \ 51 77 case 4: write_debug(ptr[4], reg, 4); \ 78 + /* Fall through */ \ 52 79 case 3: write_debug(ptr[3], reg, 3); \ 80 + /* Fall through */ \ 53 81 case 2: write_debug(ptr[2], reg, 2); \ 82 + /* Fall through */ \ 54 83 case 1: write_debug(ptr[1], reg, 1); \ 84 + /* Fall through */ \ 55 85 default: write_debug(ptr[0], reg, 0); \ 56 86 } 57 87