Skip to contentSkip to conversation

Remove unnecessary break statements

PATCH Applied Stefan Weil 5 participants 6 messages May 24, 2013 – May 25, 2013 Arm Samsung Exynos

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove unnecessary break statements

Fix these warnings from cppcheck:

hw/display/cirrus_vga.c:2603:
hw/sd/sd.c:348:
hw/timer/exynos4210_mct.c:1033:
target-arm/translate.c:9886:
target-s390x/mem_helper.c:518:
target-unicore32/translate.c:1936:
style: Consecutive return, break, continue, goto or throw statements are unnecessary.

---
 hw/display/cirrus_vga.c      |    1 -
 hw/timer/exynos4210_mct.c    |    1 -
 target-arm/translate.c       |    1 -
 target-s390x/mem_helper.c    |    1 -
 target-unicore32/translate.c |    1 -
 5 files changed, 5 deletions(-)
hw/display/cirrus_vga.c +0 -1
index 64bfe2b..a5dbc39 100644
@@ -2600,7 +2600,6 @@ static void cirrus_vga_ioport_write(void *opaque, hwaddr addr, uint64_t val,
 #endif
 	cirrus_vga_write_sr(c, val);
         break;
-	break;
     case 0x3c6:
 	cirrus_write_hidden_dac(c, val);
 	break;
hw/timer/exynos4210_mct.c +0 -1
index 87ce75b..38dcc1a 100644
@@ -1030,7 +1030,6 @@ static uint64_t exynos4210_mct_read(void *opaque, hwaddr offset,
     case G_INT_ENB:
         value = s->g_timer.reg.int_enb;
         break;
-        break;
     case G_WSTAT:
         value = s->g_timer.reg.wstat;
         break;
target-arm/translate.c +0 -1
index a1b7b8c..053d2f2 100644
@@ -9883,7 +9883,6 @@ static inline void gen_intermediate_code_internal(CPUARMState *env,
                        invalidate this TB.  */
                     dc->pc += 2;
                     goto done_generating;
-                    break;
                 }
             }
         }
target-s390x/mem_helper.c +0 -1
index 02bc432..1422ae9 100644
@@ -515,7 +515,6 @@ uint32_t HELPER(ex)(CPUS390XState *env, uint32_t cc, uint64_t v1,
             break;
         default:
             goto abort;
-            break;
         }
     } else if ((insn & 0xff00) == 0x0a00) {
         /* supervisor call */
target-unicore32/translate.c +0 -1
index 151e35e..3dc7856 100644
@@ -1933,7 +1933,6 @@ static inline void gen_intermediate_code_internal(CPUUniCore32State *env,
                        invalidate this TB.  */
                     dc->pc += 2; /* FIXME */
                     goto done_generating;
-                    break;
                 }
             }
         }
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Stefan Weil

Fix these warnings from cppcheck:

hw/display/cirrus_vga.c:2603:
hw/sd/sd.c:348:
hw/timer/exynos4210_mct.c:1033:
target-arm/translate.c:9886:
target-s390x/mem_helper.c:518:
target-unicore32/translate.c:1936:
style: Consecutive return, break, continue, goto or throw statements are unnecessary.

-- PMM

Reviewed-by on v1 1/1
#2 lore raw
In reply to Stefan Weil

Am 24.05.2013 12:19, schrieb Stefan Weil:

Quoted 11 lines

Fix these warnings from cppcheck:

hw/display/cirrus_vga.c:2603:
hw/sd/sd.c:348:
hw/timer/exynos4210_mct.c:1033:
target-arm/translate.c:9886:
target-s390x/mem_helper.c:518:
target-unicore32/translate.c:1936:
style: Consecutive return, break, continue, goto or throw statements are unnecessary.

Also removes a tab while at it. :)

Thanks,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw
In reply to Stefan Weil
Quoted 9 lines · Stefan Weil

Fix these warnings from cppcheck:

hw/display/cirrus_vga.c:2603:
hw/sd/sd.c:348:
hw/timer/exynos4210_mct.c:1033:
target-arm/translate.c:9886:
target-s390x/mem_helper.c:518:
target-unicore32/translate.c:1936:
style: Consecutive return, break, continue, goto or throw statements are unnecessary.

I'm not sure what cppcheck does, but I spotted an unnecessary break statement in the watchdog code a few days ago:

http://git.qemu.org/?p=qemu.git;a=blob;f=hw/watchdog/watchdog.c;h=cb4e1f9e479f934532fcd4d07528feccba812b79;hb=HEAD#l131
(line 131)

So it's obviously not finding them all :-(

Rich.

Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
#4 lore raw

Am 24.05.2013 14:33, schrieb Richard W.M. Jones:

Quoted 13 lines · Stefan Weil
Quoted 9 lines

Fix these warnings from cppcheck:

hw/display/cirrus_vga.c:2603:
hw/sd/sd.c:348:
hw/timer/exynos4210_mct.c:1033:
target-arm/translate.c:9886:
target-s390x/mem_helper.c:518:
target-unicore32/translate.c:1936:
style: Consecutive return, break, continue, goto or throw statements are unnecessary.

I'm not sure what cppcheck does, but I spotted an unnecessary break statement in the watchdog code a few days ago:

Quoted 6 lines

http://git.qemu.org/?p=qemu.git;a=blob;f=hw/watchdog/watchdog.c;h=cb4e1f9e479f934532fcd4d07528feccba812b79;hb=HEAD#l131
(line 131)

So it's obviously not finding them all :-(

Rich.

Yes, cppcheck knows functions with attribute noreturn, but does not check for statements after such functions. That's a missing feature (or a bug).

Stefan