From 34734e69f593e44d0791a3952ef820355e0cc3ad Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 7 Aug 2020 17:55:45 -0700 Subject: [PATCH] add an explicit format string parameter to error() and errorf() --- lib/ast/error.c | 12 ++++-------- lib/ast/error.h | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/ast/error.c b/lib/ast/error.c index 983938255..6f3e9df9c 100644 --- a/lib/ast/error.c +++ b/lib/ast/error.c @@ -87,24 +87,20 @@ void errorv(const char *id, int level, const char *s, va_list ap) exit(level - ERROR_FATAL + 1); } -void error(int level, ...) +void error(int level, const char *s, ...) { va_list ap; - const char *s; - va_start(ap, level); - s = va_arg(ap, char *); + va_start(ap, s); errorv(NiL, level, s, ap); va_end(ap); } -void errorf(void *handle, void *discipline, int level, ...) +void errorf(void *handle, void *discipline, int level, const char *s, ...) { va_list ap; - const char *s; - va_start(ap, level); - s = va_arg(ap, char *); + va_start(ap, s); errorv((discipline && handle) ? *((char **) handle) : (char *) handle, level, s, ap); va_end(ap); diff --git a/lib/ast/error.h b/lib/ast/error.h index 47b0a681c..8de5b62cd 100644 --- a/lib/ast/error.h +++ b/lib/ast/error.h @@ -62,8 +62,8 @@ extern "C" { extern void setErrorErrors (int); extern int getErrorErrors (void); - extern void error(int, ...); - extern void errorf(void *, void *, int, ...); + extern void error(int, const char *, ...); + extern void errorf(void *, void *, int, const char *, ...); extern void errorv(const char *, int, const char *, va_list); #endif -- 2.50.1