From cbdeddbab8cd1206a04cab33fab50d1c9b55eaf7 Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Mon, 17 Sep 2012 22:04:32 +0100 Subject: [PATCH] Make the code compile with warnings-as-errors. -Wextra found a bona-fide bug: signed/unsigned comparison in a stack overflow check. --- c/Makefile | 2 +- c/builtin.c | 2 +- c/execute.c | 4 +--- c/forkable_stack.h | 3 ++- c/gen_utf8_tables.py | 2 +- c/jv.c | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/c/Makefile b/c/Makefile index c80642d..ddd49ae 100644 --- a/c/Makefile +++ b/c/Makefile @@ -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 diff --git a/c/builtin.c b/c/builtin.c index ddac58f..8695189 100644 --- a/c/builtin.c +++ b/c/builtin.c @@ -190,7 +190,7 @@ static bytecoded_builtin bytecoded_builtins[] = { block builtins_bind(block b) { - for (int i=0; istk = 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) { diff --git a/c/gen_utf8_tables.py b/c/gen_utf8_tables.py index 9d8dc3c..2179222 100644 --- a/c/gen_utf8_tables.py +++ b/c/gen_utf8_tables.py @@ -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 " ") +\ diff --git a/c/jv.c b/c/jv.c index 5107063..2d91366 100644 --- a/c/jv.c +++ b/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) { + assert(s->alloc_length >= jvp_string_length(s)); uint32_t r = s->alloc_length - jvp_string_length(s); - assert(r >= 0); return r; } -- 2.40.0