[evince/gnome-3-36] backends: Annotate functions that wraps formatting strings



commit 45466f74815f48bd1edc24e0a2616db3f7a672d3
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Sat May 30 10:50:19 2020 -0400

    backends: Annotate functions that wraps formatting strings
    
    clang is stricter than gcc when compiling with -Wformat-nonliteral
    and requires annotate the function parameters when passing an
    argument to a va_list that contains these arguments.
    
    Fixes #1410

 backend/dvi/mdvi-lib/dviread.c | 3 +++
 backend/dvi/mdvi-lib/util.c    | 7 +++++++
 2 files changed, 10 insertions(+)
---
diff --git a/backend/dvi/mdvi-lib/dviread.c b/backend/dvi/mdvi-lib/dviread.c
index b33ad9a1..0c2634b7 100644
--- a/backend/dvi/mdvi-lib/dviread.c
+++ b/backend/dvi/mdvi-lib/dviread.c
@@ -169,6 +169,7 @@ static void dummy_dev_set_color(void *a, Ulong b, Ulong c)
 }
 
 /* functions to report errors */
+__attribute__((__format__ (__printf__, 2, 3)))
 static void dvierr(DviContext *dvi, const char *format, ...)
 {
        va_list ap;
@@ -180,6 +181,7 @@ static void dvierr(DviContext *dvi, const char *format, ...)
        va_end(ap);
 }
 
+__attribute__((__format__ (__printf__, 2, 3)))
 static void dviwarn(DviContext *dvi, const char *format, ...)
 {
        va_list ap;
@@ -317,6 +319,7 @@ static void dreset(DviContext *dvi)
 #define duget4(d)      dugetn((d), 4)
 
 #ifndef NODEBUG
+__attribute__((__format__ (__printf__, 4, 5)))
 static void dviprint(DviContext *dvi, const char *command, int sub, const char *fmt, ...)
 {
        int     i;
diff --git a/backend/dvi/mdvi-lib/util.c b/backend/dvi/mdvi-lib/util.c
index 349d273a..67c65250 100644
--- a/backend/dvi/mdvi-lib/util.c
+++ b/backend/dvi/mdvi-lib/util.c
@@ -48,6 +48,7 @@ int mdvi_set_logfile(const char *filename);
 int mdvi_set_logstream(FILE *file);
 int mdvi_set_loglevel(int level);
 
+__attribute__((__format__ (__printf__, 3, 0)))
 static void vputlog(int level, const char *head, const char *format, va_list ap)
 {
        if(logfile != NULL && _mdvi_log_level >= level) {
@@ -93,6 +94,7 @@ int mdvi_set_loglevel(int level)
 #ifndef NODEBUG
 Uint32 _mdvi_debug_mask = 0;
 
+__attribute__((__format__ (__printf__, 2, 3)))
 void   __debug(int mask, const char *format, ...)
 {
        va_list ap;
@@ -115,6 +117,7 @@ void        __debug(int mask, const char *format, ...)
 }
 #endif
 
+__attribute__((__format__ (__printf__, 1, 2)))
 void   mdvi_message(const char *format, ...)
 {
        va_list ap;
@@ -132,6 +135,7 @@ void        mdvi_message(const char *format, ...)
        va_end(ap);
 }
 
+__attribute__((__format__ (__printf__, 1, 2)))
 void   mdvi_crash(const char *format, ...)
 {
        va_list ap;
@@ -151,6 +155,7 @@ void        mdvi_crash(const char *format, ...)
        abort();
 }
 
+__attribute__((__format__ (__printf__, 1, 2)))
 void   mdvi_error(const char *format, ...)
 {
        va_list ap;
@@ -167,6 +172,7 @@ void        mdvi_error(const char *format, ...)
        va_end(ap);
 }
 
+__attribute__((__format__ (__printf__, 1, 2)))
 void   mdvi_warning(const char *format, ...)
 {
        va_list ap;
@@ -183,6 +189,7 @@ void        mdvi_warning(const char *format, ...)
        va_end(ap);
 }
 
+__attribute__((__format__ (__printf__, 1, 2)))
 void   mdvi_fatal(const char *format, ...)
 {
        va_list ap;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]