mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
Make the code compile with warnings-as-errors.
-Wextra found a bona-fide bug: signed/unsigned comparison in a stack overflow check.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
CC=gcc -Wall -std=gnu99 -ggdb -Wno-unused-function
|
CC=gcc -Werror -Wextra -Wall -Wno-unused-parameter -std=gnu99 -ggdb -Wno-unused-function
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
all: parsertest
|
all: parsertest
|
||||||
|
@@ -190,7 +190,7 @@ static bytecoded_builtin bytecoded_builtins[] = {
|
|||||||
|
|
||||||
|
|
||||||
block builtins_bind(block b) {
|
block builtins_bind(block b) {
|
||||||
for (int i=0; i<sizeof(bytecoded_builtins)/sizeof(bytecoded_builtins[0]); i++) {
|
for (unsigned i=0; i<sizeof(bytecoded_builtins)/sizeof(bytecoded_builtins[0]); i++) {
|
||||||
b = block_bind(bytecoded_builtins[i](), b, OP_IS_CALL_PSEUDO);
|
b = block_bind(bytecoded_builtins[i](), b, OP_IS_CALL_PSEUDO);
|
||||||
}
|
}
|
||||||
return gen_cbinding(&builtins, b);
|
return gen_cbinding(&builtins, b);
|
||||||
|
@@ -332,10 +332,9 @@ jv jq_next() {
|
|||||||
int idx = jv_number_value(stack_pop().value);
|
int idx = jv_number_value(stack_pop().value);
|
||||||
stackval container = stack_pop();
|
stackval container = stack_pop();
|
||||||
|
|
||||||
int is_array, keep_going;
|
int keep_going;
|
||||||
jv key, value;
|
jv key, value;
|
||||||
if (jv_get_kind(container.value) == JV_KIND_ARRAY) {
|
if (jv_get_kind(container.value) == JV_KIND_ARRAY) {
|
||||||
is_array = 1;
|
|
||||||
if (opcode == EACH) idx = 0;
|
if (opcode == EACH) idx = 0;
|
||||||
else idx = idx + 1;
|
else idx = idx + 1;
|
||||||
keep_going = idx < jv_array_length(jv_copy(container.value));
|
keep_going = idx < jv_array_length(jv_copy(container.value));
|
||||||
@@ -344,7 +343,6 @@ jv jq_next() {
|
|||||||
value = jv_array_get(jv_copy(container.value), idx);
|
value = jv_array_get(jv_copy(container.value), idx);
|
||||||
}
|
}
|
||||||
} else if (jv_get_kind(container.value) == JV_KIND_OBJECT) {
|
} else if (jv_get_kind(container.value) == JV_KIND_OBJECT) {
|
||||||
is_array = 0;
|
|
||||||
if (opcode == EACH) idx = jv_object_iter(container.value);
|
if (opcode == EACH) idx = jv_object_iter(container.value);
|
||||||
else idx = jv_object_iter_next(container.value, idx);
|
else idx = jv_object_iter_next(container.value, idx);
|
||||||
keep_going = jv_object_iter_valid(container.value, idx);
|
keep_going = jv_object_iter_valid(container.value, idx);
|
||||||
|
@@ -53,7 +53,8 @@ static void forkable_stack_free(struct forkable_stack* s) {
|
|||||||
s->stk = 0;
|
s->stk = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* forkable_stack_push(struct forkable_stack* s, size_t size) {
|
static void* forkable_stack_push(struct forkable_stack* s, size_t sz_size) {
|
||||||
|
int size = (int)sz_size;
|
||||||
forkable_stack_check(s);
|
forkable_stack_check(s);
|
||||||
int curr = s->pos < s->savedlimit ? s->pos : s->savedlimit;
|
int curr = s->pos < s->savedlimit ? s->pos : s->savedlimit;
|
||||||
if (curr - size < 0) {
|
if (curr - size < 0) {
|
||||||
|
@@ -5,7 +5,7 @@ mask = lambda n: (1 << n) - 1
|
|||||||
|
|
||||||
def print_table(type, name, t):
|
def print_table(type, name, t):
|
||||||
assert len(t) == 256
|
assert len(t) == 256
|
||||||
print "const static",type, name+"[]", "="
|
print "static const",type, name+"[]", "="
|
||||||
first = True
|
first = True
|
||||||
for i in range(0,len(t),16):
|
for i in range(0,len(t),16):
|
||||||
print (" {" if i == 0 else " ") +\
|
print (" {" if i == 0 else " ") +\
|
||||||
|
2
c/jv.c
2
c/jv.c
@@ -387,8 +387,8 @@ static uint32_t jvp_string_length(jvp_string* s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t jvp_string_remaining_space(jvp_string* s) {
|
static uint32_t jvp_string_remaining_space(jvp_string* s) {
|
||||||
|
assert(s->alloc_length >= jvp_string_length(s));
|
||||||
uint32_t r = s->alloc_length - jvp_string_length(s);
|
uint32_t r = s->alloc_length - jvp_string_length(s);
|
||||||
assert(r >= 0);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user