From: Matthew Fernandez <matthew.fernandez@gmail.com> Date: Sat, 8 Aug 2020 00:55:45 +0000 (-0700) Subject: add an explicit format string parameter to error() and errorf() X-Git-Tag: 2.46.0~20^2^2~126^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34734e69f593e44d0791a3952ef820355e0cc3ad;p=graphviz add an explicit format string parameter to error() and errorf() --- 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