diff --git a/Makefile.am b/Makefile.am index c7504e41fc..b152c92be5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,7 +20,7 @@ LIBJQ_SRC = src/builtin.c src/bytecode.c src/compile.c src/execute.c \ ### C build options AM_CFLAGS = -Wextra -Wall -Wno-unused-parameter -Wno-unused-function \ - -Woverlength-strings + -Woverlength-strings -Wstrict-prototypes if WIN32 AM_CFLAGS += -municode diff --git a/src/builtin.c b/src/builtin.c index c0aba960b0..e580993748 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -1924,7 +1924,7 @@ BINOPS // This is a hack to make last(g) yield no output values, // if g yields no output values, without using boxing. -static block gen_last_1() { +static block gen_last_1(void) { block last_var = gen_op_var_fresh(STOREV, "last"); block is_empty_var = gen_op_var_fresh(STOREV, "is_empty"); block init = BLOCK(gen_op_simple(DUP), diff --git a/src/compile.c b/src/compile.c index 0c208cad1d..618924a08a 100644 --- a/src/compile.c +++ b/src/compile.c @@ -129,7 +129,7 @@ block gen_location(location loc, struct locfile* l, block b) { return b; } -block gen_noop() { +block gen_noop(void) { block b = {0,0}; return b; } diff --git a/src/compile.h b/src/compile.h index c1512e6b87..bef46328a7 100644 --- a/src/compile.h +++ b/src/compile.h @@ -16,7 +16,7 @@ typedef struct block { block gen_location(location, struct locfile*, block); -block gen_noop(); +block gen_noop(void); int block_is_noop(block b); block gen_op_simple(opcode op); block gen_error(jv constant); diff --git a/src/jq_test.c b/src/jq_test.c index dd6920a420..df54be968f 100644 --- a/src/jq_test.c +++ b/src/jq_test.c @@ -8,11 +8,11 @@ #include "jv.h" #include "jq.h" -static void jv_test(); +static void jv_test(void); static void run_jq_tests(jv, int, FILE *, int, int); -static void run_jq_start_state_tests(); +static void run_jq_start_state_tests(void); #ifdef HAVE_PTHREAD -static void run_jq_pthread_tests(); +static void run_jq_pthread_tests(void); #endif int jq_testsuite(jv libdirs, int verbose, int argc, char* argv[]) { @@ -307,7 +307,7 @@ static void test_jq_start_resets_state(char *prog, const char *input) { jq_teardown(&jq); } -static void run_jq_start_state_tests() { +static void run_jq_start_state_tests(void) { test_jq_start_resets_state(".[]", "[1,2,3]"); test_jq_start_resets_state(".[] | if .%2 == 0 then halt_error else . end", "[1,2,3]"); } @@ -365,7 +365,7 @@ static void *test_pthread_run(void *ptr) { return NULL; } -static void run_jq_pthread_tests() { +static void run_jq_pthread_tests(void) { pthread_t threads[NUMBER_OF_THREADS]; struct test_pthread_data data[NUMBER_OF_THREADS]; int createerror; @@ -395,7 +395,7 @@ static void run_jq_pthread_tests() { #endif // HAVE_PTHREAD -static void jv_test() { +static void jv_test(void) { /// JSON parser regression tests { jv v = jv_parse("{\"a':\"12\"}"); diff --git a/src/jv.c b/src/jv.c index e7ae561975..cca63b9eb3 100644 --- a/src/jv.c +++ b/src/jv.c @@ -119,15 +119,15 @@ const jv JV_INVALID = {JVP_FLAGS_INVALID, 0, 0, 0, {0}}; const jv JV_FALSE = {JVP_FLAGS_FALSE, 0, 0, 0, {0}}; const jv JV_TRUE = {JVP_FLAGS_TRUE, 0, 0, 0, {0}}; -jv jv_true() { +jv jv_true(void) { return JV_TRUE; } -jv jv_false() { +jv jv_false(void) { return JV_FALSE; } -jv jv_null() { +jv jv_null(void) { return JV_NULL; } @@ -155,7 +155,7 @@ jv jv_invalid_with_msg(jv err) { return x; } -jv jv_invalid() { +jv jv_invalid(void) { return JV_INVALID; } @@ -495,12 +495,12 @@ static pthread_once_t dec_ctx_once = PTHREAD_ONCE_INIT; // atexit finalizer to clean up the tsd dec contexts if main() exits // without having called pthread_exit() -void jv_tsd_dec_ctx_fini() { +void jv_tsd_dec_ctx_fini(void) { jv_mem_free(pthread_getspecific(dec_ctx_key)); pthread_setspecific(dec_ctx_key, NULL); } -void jv_tsd_dec_ctx_init() { +void jv_tsd_dec_ctx_init(void) { if (pthread_key_create(&dec_ctx_key, jv_mem_free) != 0) { fprintf(stderr, "error: cannot create thread specific key"); abort(); @@ -971,7 +971,7 @@ jv jv_array_sized(int n) { return jvp_array_new(n); } -jv jv_array() { +jv jv_array(void) { return jv_array_sized(16); } @@ -1755,7 +1755,7 @@ static int jvp_object_contains(jv a, jv b) { * Objects (public interface) */ #define DEFAULT_OBJECT_SIZE 8 -jv jv_object() { +jv jv_object(void) { return jvp_object_new(8); } diff --git a/src/jv_alloc.c b/src/jv_alloc.c index 40c244c575..e84862565a 100644 --- a/src/jv_alloc.c +++ b/src/jv_alloc.c @@ -33,7 +33,7 @@ void jv_nomem_handler(jv_nomem_handler_f handler, void *data) { nomem_handler.handler = handler; } -static void memory_exhausted() { +static void memory_exhausted(void) { if (nomem_handler.handler) nomem_handler.handler(nomem_handler.data); // Maybe handler() will longjmp() to safety // Or not @@ -104,7 +104,7 @@ void jv_nomem_handler(jv_nomem_handler_f handler, void *data) { nomem_handler->data = data; } -static void memory_exhausted() { +static void memory_exhausted(void) { struct nomem_handler *nomem_handler; pthread_once(&mem_once, tsd_init); @@ -128,7 +128,7 @@ void jv_nomem_handler(jv_nomem_handler_f handler, void *data) { nomem_handler.data = data; } -static void memory_exhausted() { +static void memory_exhausted(void) { fprintf(stderr, "jq: error: cannot allocate memory\n"); abort(); } diff --git a/src/jv_dtoa_tsd.c b/src/jv_dtoa_tsd.c index 4bea31b565..c321f3db9c 100644 --- a/src/jv_dtoa_tsd.c +++ b/src/jv_dtoa_tsd.c @@ -19,7 +19,7 @@ static void tsd_dtoa_ctx_dtor(void *ctx) { #ifndef WIN32 static #endif -void jv_tsd_dtoa_ctx_fini() { +void jv_tsd_dtoa_ctx_fini(void) { struct dtoa_context *ctx = pthread_getspecific(dtoa_ctx_key); tsd_dtoa_ctx_dtor(ctx); pthread_setspecific(dtoa_ctx_key, NULL); @@ -28,7 +28,7 @@ void jv_tsd_dtoa_ctx_fini() { #ifndef WIN32 static #endif -void jv_tsd_dtoa_ctx_init() { +void jv_tsd_dtoa_ctx_init(void) { if (pthread_key_create(&dtoa_ctx_key, tsd_dtoa_ctx_dtor) != 0) { fprintf(stderr, "error: cannot create thread specific key"); abort(); @@ -36,7 +36,7 @@ void jv_tsd_dtoa_ctx_init() { atexit(jv_tsd_dtoa_ctx_fini); } -inline struct dtoa_context *tsd_dtoa_context_get() { +inline struct dtoa_context *tsd_dtoa_context_get(void) { pthread_once(&dtoa_ctx_once, jv_tsd_dtoa_ctx_init); // cannot fail struct dtoa_context *ctx = (struct dtoa_context*)pthread_getspecific(dtoa_ctx_key); if (!ctx) { diff --git a/src/jv_dtoa_tsd.h b/src/jv_dtoa_tsd.h index 2431d08e38..2af7c6deb0 100644 --- a/src/jv_dtoa_tsd.h +++ b/src/jv_dtoa_tsd.h @@ -1,4 +1,4 @@ #ifndef JV_DTOA_TSD_H #define JV_DTOA_TSD_H -struct dtoa_context *tsd_dtoa_context_get(); +struct dtoa_context *tsd_dtoa_context_get(void); #endif diff --git a/src/main.c b/src/main.c index a9a6ec54c2..7dddd26c37 100644 --- a/src/main.c +++ b/src/main.c @@ -117,7 +117,7 @@ static void usage(int code, int keep_it_short) { exit((ret < 0 && code == 0) ? 2 : code); } -static void die() { +static void die(void) { fprintf(stderr, "Use %s --help for help with command-line options,\n", progname); fprintf(stderr, "or see the jq manpage, or online docs at https://jqlang.org\n"); exit(2); diff --git a/src/util.c b/src/util.c index cfe65c4ae1..25bc5d5f88 100644 --- a/src/util.c +++ b/src/util.c @@ -98,7 +98,7 @@ jv expand_path(jv path) { return ret; } -jv get_home() { +jv get_home(void) { jv ret; char *home = getenv("HOME"); if (!home) {