From 26fbd5209795eb4a71debbae3ce9dc73ccbe28d9 Mon Sep 17 00:00:00 2001 From: Charlie Gordon Date: Fri, 12 Aug 2022 11:48:55 +0200 Subject: [PATCH] Fix compilation warnings - add explicit cast on snprintf to prevent -Wsuggest-attribute=format warning - always declare init_all_modules() --- qe.h | 4 ++-- qescript.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qe.h b/qe.h index 309aea3..445aa60 100644 --- a/qe.h +++ b/qe.h @@ -1340,6 +1340,8 @@ void eb_delete_properties(EditBuffer *b, int offset, int offset2); #else /* QE_MODULE */ +void init_all_modules(void); + #if (defined(__GNUC__) || defined(__TINYC__)) && defined(CONFIG_INIT_CALLS) #if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 3) /* same method as the linux kernel... */ @@ -1367,8 +1369,6 @@ void eb_delete_properties(EditBuffer *b, int offset, int offset2); #define qe_module_exit(fn) -void init_all_modules(void); - #endif #endif /* QE_MODULE */ diff --git a/qescript.c b/qescript.c index 806ae08..3076a7e 100644 --- a/qescript.c +++ b/qescript.c @@ -429,8 +429,9 @@ static int qe_cfg_append(QEmacsDataSource *ds, QEValue *sp, const char *p, size_ static int qe_cfg_format(QEmacsDataSource *ds, QEValue *sp) { char buf[256]; char fmt[16]; - /* prevent warning on variable format */ - int (*fun)(char *buf, size_t size, const char *fmt, ...) = snprintf; + /* Use function pointer and cast to prevent warning on variable format */ + int (*fun)(char *buf, size_t size, const char *fmt, ...) = + (int (*)(char *buf, size_t size, const char *fmt, ...))snprintf; char *start, *p; int c, len;