fix "Missing break in switch" coverity reports
PATCH 1/1 fix "Missing break in switch" coverity reports
Many of these are marked as "intentional/fix required" because they just need adding a fall through comment. This is exactly what this patch does, except for target/mips/translate.c where it is easier to duplicate the code, and hw/audio/sb16.c where I consulted the DOSBox sources and decide to just remove the LOG_UNIMP before the fallthrough.
--- disas/m68k.c | 1 + hw/arm/pxa2xx.c | 2 +- hw/audio/cs4231a.c | 1 + hw/audio/gusemu_hal.c | 1 + hw/audio/sb16.c | 4 +--- hw/display/cg3.c | 1 + hw/display/cirrus_vga.c | 3 ++- hw/timer/sh_timer.c | 1 + target/arm/helper.c | 1 + target/i386/translate.c | 2 ++ target/mips/translate.c | 2 ++ 11 files changed, 14 insertions(+), 5 deletions(-)
disas/m68k.c +1 -0
@@ -1623,6 +1623,7 @@ print_insn_arg (const char *d,case 'X' : place ='8' ; +/* fall through */ case 'Y' :case 'Z' :case 'W' :
hw/arm/pxa2xx.c +1 -1
@@ -409,7 +409,7 @@ static uint64_t pxa2xx_mm_read(void *opaque, hwaddr addr, case MDCNFG ... SA1110:if ((addr &3 ) ==0 )return s->mm_regs[addr >>2 ]; - +/* fall through */ default :printf ("%s: Bad register " REG_FMT "\n" , __func__, addr);break ;
hw/audio/cs4231a.c +1 -0
@@ -305,6 +305,7 @@ static void cs_reset_voices (CSState *s, uint32_t val)case 6 : as.endianness =1 ; +/* fall through */ case 2 : as.fmt =AUD_FMT_S16 ; s->shift = as.nchannels;
hw/audio/gusemu_hal.c +1 -0
@@ -261,6 +261,7 @@ void gus_write(GUSEmuState * state, int port, int size, unsigned int data)GUSregb (IRQStatReg2x6) =0x10 ;GUS_irqrequest (state, state->gusirq,1 ); } +/* fall through */ case 0x20D :/* SB2xCd no IRQ */ GUSregb (SB2xCd) = (uint8_t ) data;break ;
hw/audio/sb16.c +1 -3
@@ -741,10 +741,8 @@ static void complete (SB16State *s)ldebug ("set time const %d\n" , s->time_const);break ; -case 0x42 :/* FT2 sets output freq with this, go figure */ -qemu_log_mask (LOG_UNIMP ,"cmd 0x42 might not do what it think it" -" should\n" );case 0x41 : +case 0x42 :/* FT2 sets output freq with this, go figure */ s->freq =dsp_get_hilo (s);ldebug ("set freq %d\n" , s->freq);break ;
hw/display/cg3.c +1 -0
@@ -232,6 +232,7 @@ static void cg3_reg_write(void *opaque, hwaddr addr, uint64_t val, s->b[s->dac_index] = regval;/* Index autoincrement */ s->dac_index = (s->dac_index +1 ) &0xff ; +/* fall through */ default : s->dac_state =0 ;break ;
hw/display/cirrus_vga.c +2 -1
@@ -1426,7 +1426,8 @@ static void cirrus_vga_write_sr(CirrusVGAState * s, uint32_t val) s->vga.hw_cursor_y = (val <<3 ) | (s->vga.sr_index >>5 );break ;case 0x07 :// Extended Sequencer Mode -cirrus_update_memory_access (s); +cirrus_update_memory_access (s); +/* fall through */ case 0x08 :// EEPROM Control case 0x09 :// Scratch Register 0 case 0x0a :// Scratch Register 1
hw/timer/sh_timer.c +1 -0
@@ -74,6 +74,7 @@ static uint32_t sh_timer_read(void *opaque, hwaddr offset)case OFFSET_TCPR :if (s->feat &TIMER_FEAT_CAPT )return s->tcpr; +/* fall through */ default :hw_error ("sh_timer_read: Bad offset %x\n" , (int )offset);return 0 ;
target/arm/helper.c +1 -0
@@ -12277,6 +12277,7 @@ int arm_rmode_to_sf(int rmode)/* FIXME: add support for TIEAWAY and ODD */ qemu_log_mask (LOG_UNIMP ,"arm: unimplemented rounding mode: %d\n" , rmode); +/* fall through for now */ case FPROUNDING_TIEEVEN :default : rmode = float_round_nearest_even;
target/i386/translate.c +2 -0
@@ -4689,6 +4689,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)case 0x82 :if (CODE64 (s)) goto illegal_op; +/* fall through */ case 0x80 :/* GRP1 */ case 0x81 :case 0x83 :
@@ -8292,6 +8293,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) case 0x10e ... 0x10f:/* 3DNow! instructions, ignore prefixes */ s->prefix &= ~(PREFIX_REPZ |PREFIX_REPNZ |PREFIX_DATA ); +/* fall through */ case 0x110 ... 0x117: case 0x128 ... 0x12f: case 0x138 ... 0x13a:
target/mips/translate.c +2 -0
@@ -19874,6 +19874,8 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)case OPC_MTHC1 :check_cp1_enabled (ctx);check_insn (ctx,ISA_MIPS32R2 ); +gen_cp1 (ctx, op1, rt, rd); +break ;case OPC_MFC1 :case OPC_CFC1 :case OPC_MTC1 :
Signature · 1 line
2.17.1
Quoted 137 lines · Paolo Bonzini
Many of these are marked as "intentional/fix required" because they just need adding a fall through comment. This is exactly what this patch does, except for
target/mips/translate.cwhere it is easier to duplicate the code, andhw/audio/sb16.cwhere I consulted the DOSBox sources and decide to just remove theLOG_UNIMPbefore the fallthrough.Signed-off-by Paolo Bonzini <[email protected]>--- disas/m68k.c | 1 + hw/arm/pxa2xx.c | 2 +- hw/audio/cs4231a.c | 1 + hw/audio/gusemu_hal.c | 1 + hw/audio/sb16.c | 4 +--- hw/display/cg3.c | 1 + hw/display/cirrus_vga.c | 3 ++- hw/timer/sh_timer.c | 1 + target/arm/helper.c | 1 + target/i386/translate.c | 2 ++ target/mips/translate.c | 2 ++ 11 files changed, 14 insertions(+), 5 deletions(-)disas/m68k.c +1
-0@@ -1623,6 +1623,7 @@ print_insn_arg (const char *d,case 'X' : place ='8' ; +/* fall through */ case 'Y' :case 'Z' :case 'W' :hw/arm/pxa2xx.c +1
-1@@ -409,7 +409,7 @@ static uint64_t pxa2xx_mm_read(void *opaque, hwaddr addr, case MDCNFG ... SA1110:if ((addr &3 ) ==0 )return s->mm_regs[addr >>2 ]; - +/* fall through */ default :printf ("%s: Bad register " REG_FMT "\n" , __func__, addr);break;hw/audio/cs4231a.c +1
-0@@ -305,6 +305,7 @@ static void cs_reset_voices (CSState *s, uint32_t val)case 6 : as.endianness =1 ; +/* fall through */ case 2 : as.fmt =AUD_FMT_S16 ; s->shift = as.nchannels;hw/audio/gusemu_hal.c +1
-0@@ -261,6 +261,7 @@ void gus_write(GUSEmuState * state, int port, int size, unsigned int data)GUSregb (IRQStatReg2x6 ) =0x10 ;GUS_irqrequest (state, state->gusirq,1 ); } +/* fall through */ case 0x20D :/* SB2xCd no IRQ */ GUSregb (SB2xCd) = (uint8_t ) data;break;hw/audio/sb16.c +0
-1@@ -741,10 +741,8 @@ static void complete (SB16State *s)ldebug ("set time const %d\n" , s->time_const);break ; -case 0x42 :/* FT2 sets output freq with this, go figure */
- qemu_log_mask(LOG_UNIMP, "cmd0x42might not do what it think
it"hw/audio/sb16.c +1
-1- " should\n");case 0x41 : +case 0x42 :/* FT2 sets output freq with this, go figure */
s->freq = dsp_get_hilo (s); ldebug ("set freq %d\n", s->freq); break;hw/display/cg3.c +1
-0@@ -232,6 +232,7 @@ static void cg3_reg_write(void *opaque, hwaddr addr,uint64_t val, s->b[s->dac_index] = regval;/* Index autoincrement */ s->dac_index = (s->dac_index +1 ) &0xff ; +/* fall through */ default : s->dac_state =0 ;break;hw/display/cirrus_vga.c +2
-1@@ -1426,7 +1426,8 @@ static void cirrus_vga_write_sr(CirrusVGAState * s, uint32_t val) s->vga.hw_cursor_y = (val << 3) | (s->vga.sr_index >> 5);break ;case 0x07 :// Extended Sequencer Mode -cirrus_update_memory_access (s); +cirrus_update_memory_access (s); +/* fall through */ case 0x08 :// EEPROM Control case 0x09 :// Scratch Register 0 case 0x0a: // Scratch Register 1hw/timer/sh_timer.c +1
-0@@ -74,6 +74,7 @@ static uint32_t sh_timer_read(void *opaque, hwaddr offset)case OFFSET_TCPR :if (s->feat &TIMER_FEAT_CAPT )return s->tcpr; +/* fall through */ default :hw_error ("sh_timer_read: Bad offset %x\n" , (int )offset);return 0;target/arm/helper.c +0
-0
target/arm/helper.c int arm_rmode_to_sf(int rmode) · line 12281
Quoted 5 lines
target/arm/helper.c +1
-0@@ -12277,6 +12277,7 @@ int arm_rmode_to_sf(int rmode)/* FIXME: add support for TIEAWAY and ODD */ qemu_log_mask (LOG_UNIMP ,"arm: unimplemented rounding mode: %d\n" , rmode); +/* fall through for now */
This one looks weird, hidden bug?
For the rest:
case FPROUNDING_TIEEVEN:
Quoted 43 lines
target/arm/helper.c +0
-0default : rmode = float_round_nearest_even;target/i386/translate.c +1
-0@@ -4689,6 +4689,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)case 0x82 :if (CODE64 (s)) goto illegal_op; +/* fall through */ case 0x80 :/* GRP1 */ case 0x81 :case 0x83:target/i386/translate.c +1
-0@@ -8292,6 +8293,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) case 0x10e ... 0x10f:/* 3DNow! instructions, ignore prefixes */ s->prefix &= ~(PREFIX_REPZ |PREFIX_REPNZ |PREFIX_DATA ); +/* fall through */ case 0x110 ... 0x117: case 0x128 ... 0x12f:case 0x138 ... 0x13a:target/mips/translate.c +2
-0@@ -19874,6 +19874,8 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)case OPC_MTHC1 :check_cp1_enabled (ctx);check_insn (ctx,ISA_MIPS32R2 ); +gen_cp1 (ctx, op1, rt, rd); +break ;case OPC_MFC1 :case OPC_CFC1 :case
OPC_MTC1:
--
2.17.1
Quoted 10 lines · Philippe Mathieu-Daudé
@@ -12277,6 +12277,7 @@ int arm_rmode_to_sf(int rmode) /* FIXME: add support for TIEAWAY and ODD */ qemu_log_mask(LOG_UNIMP, "arm: unimplemented rounding mode: %d\n", rmode); + /* fall through for now */This one looks weird, hidden bug?
There is already a FIXME comment.
Paolo
Quoted 4 lines
For the rest:
Reviewed-by Philippe Mathieu-Daudé <[email protected]<mailto:[email protected]>>
Quoted 14 lines · Paolo Bonzini
Many of these are marked as "intentional/fix required" because they just need adding a fall through comment. This is exactly what this patch does, except for
target/mips/translate.cwhere it is easier to duplicate the code, andhw/audio/sb16.cwhere I consulted the DOSBox sources and decide to just remove theLOG_UNIMPbefore the fallthrough.Signed-off-by Paolo Bonzini <[email protected]>hw/audio/sb16.c +0
-0@@ -741,10 +741,8 @@ static void complete (SB16State *s)ldebug ("set time const %d\n" , s->time_const);
hw/audio/sb16.c static void complete (SB16State *s) · line 748
Quoted 10 lines
hw/audio/sb16.c +1
-3break ; -case 0x42 :/* FT2 sets output freq with this, go figure */ -qemu_log_mask (LOG_UNIMP ,"cmd 0x42 might not do what it think it" -" should\n" );case 0x41 : +case 0x42 :/* FT2 sets output freq with this, go figure */ s->freq =dsp_get_hilo (s);ldebug ("set freq %d\n" , s->freq);break ;
I agree with the outcome; see previous discussions
https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg02081.html
https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg02079.html
and this description of what the hardware does:
http://homepages.cae.wisc.edu/~brodskye/sb16doc/sb16doc.html#SamplingRate
We could improve the somewhat cryptic comment:
/*
* 0x41 is documented as setting the output sample rate,
* and 0x42 the input sample rate, but in fact SB16 hardware
* seems to have only a single sample rate under the hood,
* and some (buggy) guest programs such as FT2 will set the
* output rate using 0x42. Compare:
* http://homepages.cae.wisc.edu/~brodskye/sb16doc/sb16doc.html#SamplingRate
*/
thanks
-- PMM
Quoted 10 lines · Peter Maydell
We could improve the somewhat cryptic comment:
/*
*0x41is documented as setting the output sample rate,
* and0x42the input sample rate, but in fact SB16 hardware
* seems to have only a single sample rate under the hood,
* and some (buggy) guest programs such as FT2 will set the
* output rate using0x42. Compare:
* http://homepages.cae.wisc.edu/~brodskye/sb16doc/sb16doc.html#SamplingRate
*/
I sometimes enjoy keeping little bits of "old-style QEMU" in these more historical devices, but your improvement is just too good, so I'll replace it. Thanks!
Paolo