]> granicus.if.org Git - graphviz/commitdiff
exerror/exwarn: allow GNU-compatible compilers to detect misuse
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 9 Oct 2021 19:05:37 +0000 (12:05 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 15 Oct 2021 14:47:01 +0000 (07:47 -0700)
This lets compilers like GCC and Clang notice when these functions are called
with a format string that is inconsistent with the remaining arguments and issue
a warning. This detects problems like those fixed in the prior commit.

lib/expr/expr.h

index 4c3630687e0bc014f63d4066f68e27823bd57fa1..9c4e91233204fda7c04c5248f62bf0bf290588a4 100644 (file)
@@ -271,7 +271,13 @@ extern void                exclose(Expr_t*, int);
 extern int             excomp(Expr_t*, const char*, int, const char*, Sfio_t*);
 extern char*           excontext(Expr_t*, char*, int);
 extern int             exdump(Expr_t*, Exnode_t*, Sfio_t*);
+#ifdef __GNUC__
+__attribute__((format(printf, 1, 2)))
+#endif
 extern void            exerror(const char*, ...);
+#ifdef __GNUC__
+__attribute__((format(printf, 1, 2)))
+#endif
 extern void            exwarn(const char *, ...);
 extern Extype_t                exeval(Expr_t*, Exnode_t*, void*);
 extern Exnode_t*       exexpr(Expr_t*, const char*, Exid_t*, int);