From 4cf1408e0bbac8fc714b051fe420921905128efd Mon Sep 17 00:00:00 2001 From: Emanuele Torre Date: Sun, 13 Aug 2023 15:39:54 +0200 Subject: [PATCH] Cast function pointers without prototype before calling them (#2842) clang complained that this is deprecated in all versions of standard C, and unsupported in C2x. --- src/execute.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/execute.c b/src/execute.c index f1dcd105f5..ae92c37317 100644 --- a/src/execute.c +++ b/src/execute.c @@ -921,11 +921,11 @@ jv jq_next(jq_state *jq) { } struct cfunction* function = &frame_current(jq)->bc->globals->cfunctions[*pc++]; switch (function->nargs) { - case 1: top = function->fptr(jq, in[0]); break; - case 2: top = function->fptr(jq, in[0], in[1]); break; - case 3: top = function->fptr(jq, in[0], in[1], in[2]); break; - case 4: top = function->fptr(jq, in[0], in[1], in[2], in[3]); break; - case 5: top = function->fptr(jq, in[0], in[1], in[2], in[3], in[4]); break; + case 1: top = ((jv (*)(jq_state *, jv))function->fptr)(jq, in[0]); break; + case 2: top = ((jv (*)(jq_state *, jv, jv))function->fptr)(jq, in[0], in[1]); break; + case 3: top = ((jv (*)(jq_state *, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2]); break; + case 4: top = ((jv (*)(jq_state *, jv, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2], in[3]); break; + case 5: top = ((jv (*)(jq_state *, jv, jv, jv, jv, jv))function->fptr)(jq, in[0], in[1], in[2], in[3], in[4]); break; // FIXME: a) up to 7 arguments (input + 6), b) should assert // because the compiler should not generate this error. default: return jv_invalid_with_msg(jv_string("Function takes too many arguments"));