]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Workaround MSVC warning C4477
authorOndřej Surý <ondrej@isc.org>
Wed, 15 Apr 2020 10:36:12 +0000 (12:36 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 15 Apr 2020 10:47:42 +0000 (12:47 +0200)
Due to a way the stdatomic.h shim is implemented on Windows, the MSVC
always things that the outside type is the largest - atomic_(u)int_fast64_t.
This can lead to false positives as this one:

  lib\dns\adb.c(3678): warning C4477: 'fprintf' : format string '%u' requires an argument of type 'unsigned int', but variadic argument 2 has type 'unsigned __int64'

We workaround the issue by loading the value in a scoped local variable
with correct type first.

lib/dns/adb.c

index 5d0a5d6dcf9bae389f085fa96d6973a4ab9e13d3..a2800226d1fdd7c9873e69c374e6b5d23e29a649 100644 (file)
@@ -3675,8 +3675,9 @@ dump_entry(FILE *f, dns_adb_t *adb, dns_adbentry_t *entry, bool debug,
        }
 
        if (adb != NULL && adb->quota != 0 && adb->atr_freq != 0) {
+               uint_fast32_t quota = atomic_load_relaxed(&entry->quota);
                fprintf(f, " [atr %0.2f] [quota %" PRIuFAST32 "]", entry->atr,
-                       atomic_load_relaxed(&entry->quota));
+                       quota);
        }
 
        fprintf(f, "\n");