1
0
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:
Stephen Dolan
2012-09-17 22:04:32 +01:00
parent eab9c4e587
commit cbdeddbab8
6 changed files with 7 additions and 8 deletions

View File

@@ -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
all: parsertest

View File

@@ -190,7 +190,7 @@ static bytecoded_builtin bytecoded_builtins[] = {
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);
}
return gen_cbinding(&builtins, b);

View File

@@ -332,10 +332,9 @@ jv jq_next() {
int idx = jv_number_value(stack_pop().value);
stackval container = stack_pop();
int is_array, keep_going;
int keep_going;
jv key, value;
if (jv_get_kind(container.value) == JV_KIND_ARRAY) {
is_array = 1;
if (opcode == EACH) idx = 0;
else idx = idx + 1;
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);
}
} else if (jv_get_kind(container.value) == JV_KIND_OBJECT) {
is_array = 0;
if (opcode == EACH) idx = jv_object_iter(container.value);
else idx = jv_object_iter_next(container.value, idx);
keep_going = jv_object_iter_valid(container.value, idx);

View File

@@ -53,7 +53,8 @@ static void forkable_stack_free(struct forkable_stack* s) {
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);
int curr = s->pos < s->savedlimit ? s->pos : s->savedlimit;
if (curr - size < 0) {

View File

@@ -5,7 +5,7 @@ mask = lambda n: (1 << n) - 1
def print_table(type, name, t):
assert len(t) == 256
print "const static",type, name+"[]", "="
print "static const",type, name+"[]", "="
first = True
for i in range(0,len(t),16):
print (" {" if i == 0 else " ") +\

2
c/jv.c
View File

@@ -387,8 +387,8 @@ static uint32_t jvp_string_length(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);
assert(r >= 0);
return r;
}