Add JQ_FALLTHROUGH and use it to quiet warnings

This commit is contained in:
Nicolas Williams authored and Emanuele Torre committed 2023-07-30 04:25:54 +02:00
1 parent a6eb055c47
commit c8b30dff4a
4 files changed
+22 -2

No files matched your search

+2 -1
View File
@@ -575,6 +575,7 @@ jv jq_next(jq_state *jq) {
case STOREVN: case STOREVN:
stack_save(jq, pc - 1, stack_get_pos(jq)); stack_save(jq, pc - 1, stack_get_pos(jq));
JQ_FALLTHROUGH;
case STOREV: { case STOREV: {
uint16_t level = *pc++; uint16_t level = *pc++;
uint16_t v = *pc++; uint16_t v = *pc++;
@@ -742,7 +743,7 @@ jv jq_next(jq_state *jq) {
} }
stack_push(jq, container); stack_push(jq, container);
stack_push(jq, jv_number(-1)); stack_push(jq, jv_number(-1));
// fallthrough JQ_FALLTHROUGH;
} }
case ON_BACKTRACK(EACH): case ON_BACKTRACK(EACH):
case ON_BACKTRACK(EACH_OPT): { case ON_BACKTRACK(EACH_OPT): {
+2
View File
@@ -1222,7 +1222,9 @@ static uint32_t jvp_string_hash(jv jstr) {
switch(len & 3) { switch(len & 3) {
case 3: k1 ^= tail[2] << 16; case 3: k1 ^= tail[2] << 16;
JQ_FALLTHROUGH;
case 2: k1 ^= tail[1] << 8; case 2: k1 ^= tail[1] << 8;
JQ_FALLTHROUGH;
case 1: k1 ^= tail[0]; case 1: k1 ^= tail[0];
k1 *= c1; k1 = rotl32(k1,15); k1 *= c2; h1 ^= k1; k1 *= c1; k1 = rotl32(k1,15); k1 *= c2; h1 ^= k1;
} }
+7
View File
@@ -5,6 +5,13 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#if (defined(__GNUC__) && __GNUC__ >= 7) || \
(defined(__clang__) && __clang_major__ >= 10)
# define JQ_FALLTHROUGH __attribute__((fallthrough))
#else
# define JQ_FALLTHROUGH do {} while (0) /* fallthrough */
#endif
typedef enum { typedef enum {
JV_KIND_INVALID, JV_KIND_INVALID,
JV_KIND_NULL, JV_KIND_NULL,
+11 -1
View File
@@ -195,6 +195,7 @@
#include "jv_dtoa.h" #include "jv_dtoa.h"
#include "jv_alloc.h" #include "jv_alloc.h"
#include "jv.h"
#define MALLOC jv_mem_alloc #define MALLOC jv_mem_alloc
#define FREE jv_mem_free #define FREE jv_mem_free
@@ -1723,6 +1724,7 @@ gethex(struct dtoa_context* C, CONST char **sp, U *rvp, int rounding, int sign)
case '-': case '-':
esign = 1; esign = 1;
/* no break */ /* no break */
JQ_FALLTHROUGH;
case '+': case '+':
s++; s++;
} }
@@ -2327,7 +2329,10 @@ retlow1:
jvp_strtod jvp_strtod
(struct dtoa_context* C, const char *s00, char **se) (struct dtoa_context* C, const char *s00, char **se)
{ {
int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1, test_scale; int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1;
#ifdef Honor_FLT_ROUNDS
int test_scale;
#endif
int esign, i, j, k, nd, nd0, nf, nz, nz0, nz1, sign; int esign, i, j, k, nd, nd0, nf, nz, nz0, nz1, sign;
CONST char *s, *s0, *s1; CONST char *s, *s0, *s1;
double aadj, aadj1; double aadj, aadj1;
@@ -2367,10 +2372,12 @@ jvp_strtod
case '-': case '-':
sign = 1; sign = 1;
/* no break */ /* no break */
JQ_FALLTHROUGH;
case '+': case '+':
if (*++s) if (*++s)
goto break2; goto break2;
/* no break */ /* no break */
JQ_FALLTHROUGH;
case 0: case 0:
goto ret0; goto ret0;
case '\t': case '\t':
@@ -2478,6 +2485,7 @@ jvp_strtod
switch(c = *++s) { switch(c = *++s) {
case '-': case '-':
esign = 1; esign = 1;
JQ_FALLTHROUGH;
case '+': case '+':
c = *++s; c = *++s;
} }
@@ -3699,6 +3707,7 @@ jvp_dtoa
case 2: case 2:
leftright = 0; leftright = 0;
/* no break */ /* no break */
JQ_FALLTHROUGH;
case 4: case 4:
if (ndigits <= 0) if (ndigits <= 0)
ndigits = 1; ndigits = 1;
@@ -3707,6 +3716,7 @@ jvp_dtoa
case 3: case 3:
leftright = 0; leftright = 0;
/* no break */ /* no break */
JQ_FALLTHROUGH;
case 5: case 5:
i = ndigits + k + 1; i = ndigits + k + 1;
ilim = i; ilim = i;