]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
gcc7: comments for falling through a switch case
authorMatthew Barr <matthew.barr@intel.com>
Mon, 10 Apr 2017 03:25:07 +0000 (13:25 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Tue, 30 May 2017 03:59:48 +0000 (13:59 +1000)
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.

src/hwlm/noodle_engine_avx2.c
src/nfa/limex_runtime_impl.h
src/nfa/mcsheng.c

index 14d0eab540257959a311c5414fe3421573ef928a..a3f46047e0c636c14878b2321ace334738749948 100644 (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
  * 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) {
         u8 *vp = (u8*)&v;
         switch (l) {
-            case 3: vp[2] = d[2];
-            case 2: vp[1] = d[1];
-            case 1: vp[0] = d[0];
+            case 3: vp[2] = d[2]; // fallthrough
+            case 2: vp[1] = d[1]; // fallthrough
+            case 1: vp[0] = d[0]; // fallthrough
         }
     } else {
         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) {
         u8 *vp = (u8*)&v;
         switch (l) {
-            case 3: vp[2] = d[2];
-            case 2: vp[1] = d[1];
-            case 1: vp[0] = d[0];
+            case 3: vp[2] = d[2]; // fallthrough
+            case 2: vp[1] = d[1]; // fallthrough
+            case 1: vp[0] = d[0]; // fallthrough
         }
     } else {
         v = masked_move256_len(d, l);
index 2c9647d0a14c29fcb973d0b19b3eee6f3daf1e89..7b89182bea6d89abe11a91a67d4f9370589b47d8 100644 (file)
@@ -173,25 +173,32 @@ size_t RUN_ACCEL_FN(const STATE_T s, UNUSED const STATE_T accelMask,
         switch (limex_m->shiftCount) {                                         \
         case 8:                                                                \
             succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 7)); \
+            /* fallthrough */                                                  \
         case 7:                                                                \
             succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 6)); \
+            /* fallthrough */                                                  \
         case 6:                                                                \
             succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 5)); \
+            /* fallthrough */                                                  \
         case 5:                                                                \
             succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 4)); \
+            /* fallthrough */                                                  \
         case 4:                                                                \
             succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 3)); \
+            /* fallthrough */                                                  \
         case 3:                                                                \
             succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 2)); \
+            /* fallthrough */                                                  \
         case 2:                                                                \
             succ_m = OR_STATE(succ_m, NFA_EXEC_LIM_SHIFT(limex_m, curr_m, 1)); \
+            /* fallthrough */                                                  \
         case 1:                                                                \
+            /* fallthrough */                                                  \
         case 0:                                                                \
             ;                                                                  \
         }                                                                      \
     } while (0)
 
-
 /**
  * \brief LimEx NFAS inner loop without accel.
  *
index 8130173d277dcf343299e771e6d76c05a0139aa0..9722fd676e1966c5ce6fdb469be8a025d5af115f 100644 (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);
         switch (soft_c_end - c) {
         case 7:
-            SHENG_SINGLE_ITER;
+            SHENG_SINGLE_ITER; // fallthrough
         case 6:
-            SHENG_SINGLE_ITER;
+            SHENG_SINGLE_ITER; // fallthrough
         case 5:
-            SHENG_SINGLE_ITER;
+            SHENG_SINGLE_ITER; // fallthrough
         case 4:
-            SHENG_SINGLE_ITER;
+            SHENG_SINGLE_ITER; // fallthrough
         case 3:
-            SHENG_SINGLE_ITER;
+            SHENG_SINGLE_ITER; // fallthrough
         case 2:
-            SHENG_SINGLE_ITER;
+            SHENG_SINGLE_ITER; // fallthrough
         case 1:
-            SHENG_SINGLE_ITER;
+            SHENG_SINGLE_ITER; // fallthrough
         }
     }