1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

Add JQ_FALLTHROUGH and use it to quiet warnings

This commit is contained in:
Nicolas Williams
2023-07-10 18:28:33 -05:00
committed by Emanuele Torre
parent a6eb055c47
commit c8b30dff4a
4 changed files with 22 additions and 2 deletions

View File

@@ -575,6 +575,7 @@ jv jq_next(jq_state *jq) {
case STOREVN:
stack_save(jq, pc - 1, stack_get_pos(jq));
JQ_FALLTHROUGH;
case STOREV: {
uint16_t level = *pc++;
uint16_t v = *pc++;
@@ -742,7 +743,7 @@ jv jq_next(jq_state *jq) {
}
stack_push(jq, container);
stack_push(jq, jv_number(-1));
// fallthrough
JQ_FALLTHROUGH;
}
case ON_BACKTRACK(EACH):
case ON_BACKTRACK(EACH_OPT): {

View File

@@ -1222,7 +1222,9 @@ static uint32_t jvp_string_hash(jv jstr) {
switch(len & 3) {
case 3: k1 ^= tail[2] << 16;
JQ_FALLTHROUGH;
case 2: k1 ^= tail[1] << 8;
JQ_FALLTHROUGH;
case 1: k1 ^= tail[0];
k1 *= c1; k1 = rotl32(k1,15); k1 *= c2; h1 ^= k1;
}

View File

@@ -5,6 +5,13 @@
#include <stdint.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 {
JV_KIND_INVALID,
JV_KIND_NULL,

View File

@@ -195,6 +195,7 @@
#include "jv_dtoa.h"
#include "jv_alloc.h"
#include "jv.h"
#define MALLOC jv_mem_alloc
#define FREE jv_mem_free
@@ -1723,6 +1724,7 @@ gethex(struct dtoa_context* C, CONST char **sp, U *rvp, int rounding, int sign)
case '-':
esign = 1;
/* no break */
JQ_FALLTHROUGH;
case '+':
s++;
}
@@ -2327,7 +2329,10 @@ retlow1:
jvp_strtod
(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;
CONST char *s, *s0, *s1;
double aadj, aadj1;
@@ -2367,10 +2372,12 @@ jvp_strtod
case '-':
sign = 1;
/* no break */
JQ_FALLTHROUGH;
case '+':
if (*++s)
goto break2;
/* no break */
JQ_FALLTHROUGH;
case 0:
goto ret0;
case '\t':
@@ -2478,6 +2485,7 @@ jvp_strtod
switch(c = *++s) {
case '-':
esign = 1;
JQ_FALLTHROUGH;
case '+':
c = *++s;
}
@@ -3699,6 +3707,7 @@ jvp_dtoa
case 2:
leftright = 0;
/* no break */
JQ_FALLTHROUGH;
case 4:
if (ndigits <= 0)
ndigits = 1;
@@ -3707,6 +3716,7 @@ jvp_dtoa
case 3:
leftright = 0;
/* no break */
JQ_FALLTHROUGH;
case 5:
i = ndigits + k + 1;
ilim = i;