gcc7: comments for falling through a switch case

GCC 7 adds a warning -Wimplicit-fallthrough to catch when falling
through a switch statement without a break. Since we actually want that
behaviour sometimes, we can add a comment so the compiler knows we
intended the fallthrough.
This commit is contained in:
Matthew Barr 2017-04-10 13:25:07 +10:00
parent 055ff7391c
commit 221229f71c
3 changed files with 22 additions and 15 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015-2016, Intel Corporation * Copyright (c) 2015-2017, Intel Corporation
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -117,9 +117,9 @@ hwlm_error_t scanSingleShort(const u8 *buf, size_t len, const u8 *key,
if (l < 4) { if (l < 4) {
u8 *vp = (u8*)&v; u8 *vp = (u8*)&v;
switch (l) { switch (l) {
case 3: vp[2] = d[2]; case 3: vp[2] = d[2]; // fallthrough
case 2: vp[1] = d[1]; case 2: vp[1] = d[1]; // fallthrough
case 1: vp[0] = d[0]; case 1: vp[0] = d[0]; // fallthrough
} }
} else { } else {
v = masked_move256_len(d, l); v = masked_move256_len(d, l);
@ -157,9 +157,9 @@ hwlm_error_t scanDoubleShort(const u8 *buf, size_t len, const u8 *key,
if (l < 4) { if (l < 4) {
u8 *vp = (u8*)&v; u8 *vp = (u8*)&v;
switch (l) { switch (l) {
case 3: vp[2] = d[2]; case 3: vp[2] = d[2]; // fallthrough
case 2: vp[1] = d[1]; case 2: vp[1] = d[1]; // fallthrough
case 1: vp[0] = d[0]; case 1: vp[0] = d[0]; // fallthrough
} }
} else { } else {
v = masked_move256_len(d, l); v = masked_move256_len(d, l);

View File

@ -173,25 +173,32 @@ size_t RUN_ACCEL_FN(const STATE_T s, UNUSED const STATE_T accelMask,
switch (limex_m->shiftCount) { \ switch (limex_m->shiftCount) { \
case 8: \ case 8: \
succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 7)); \ succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 7)); \
/* fallthrough */ \
case 7: \ case 7: \
succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 6)); \ succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 6)); \
/* fallthrough */ \
case 6: \ case 6: \
succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 5)); \ succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 5)); \
/* fallthrough */ \
case 5: \ case 5: \
succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 4)); \ succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 4)); \
/* fallthrough */ \
case 4: \ case 4: \
succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 3)); \ succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 3)); \
/* fallthrough */ \
case 3: \ case 3: \
succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 2)); \ succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 2)); \
/* fallthrough */ \
case 2: \ case 2: \
succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 1)); \ succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 1)); \
/* fallthrough */ \
case 1: \ case 1: \
/* fallthrough */ \
case 0: \ case 0: \
; \ ; \
} \ } \
} while (0) } while (0)
/** /**
* \brief LimEx NFAS inner loop without accel. * \brief LimEx NFAS inner loop without accel.
* *

View File

@ -288,19 +288,19 @@ u32 doSheng(const struct mcsheng *m, const u8 **c_inout, const u8 *soft_c_end,
assert(soft_c_end - c < SHENG_CHUNK); assert(soft_c_end - c < SHENG_CHUNK);
switch (soft_c_end - c) { switch (soft_c_end - c) {
case 7: case 7:
SHENG_SINGLE_ITER; SHENG_SINGLE_ITER; // fallthrough
case 6: case 6:
SHENG_SINGLE_ITER; SHENG_SINGLE_ITER; // fallthrough
case 5: case 5:
SHENG_SINGLE_ITER; SHENG_SINGLE_ITER; // fallthrough
case 4: case 4:
SHENG_SINGLE_ITER; SHENG_SINGLE_ITER; // fallthrough
case 3: case 3:
SHENG_SINGLE_ITER; SHENG_SINGLE_ITER; // fallthrough
case 2: case 2:
SHENG_SINGLE_ITER; SHENG_SINGLE_ITER; // fallthrough
case 1: case 1:
SHENG_SINGLE_ITER; SHENG_SINGLE_ITER; // fallthrough
} }
} }