]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
treewide: compiler warnings for printf-style functions
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 25 Jan 2018 13:24:24 +0000 (14:24 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 25 Jan 2018 13:53:00 +0000 (14:53 +0100)
lib/cache.c
lib/cache/entry_pkt.c
lib/defines.h
lib/layer/iterate.c
lib/utils.h

index 635dbf5f2f61b52e884a88f342e4fec324e862c1..e7c8149554db8cbad401f87e774b91026bff5a03 100644 (file)
@@ -535,7 +535,7 @@ static int cache_peek_real(kr_layer_t *ctx, knot_pkt_t *pkt)
                        /* ^^ here we use the *expanded* wildcard name */
                if (new_ttl < 0 || eh->rank < lowest_rank || eh->is_packet) {
                        /* Wildcard record with stale TTL, bad rank or packet.  */
-                       VERBOSE_MSG(qry, "=> wildcard: skipping %s, rank 0%0.2o, new TTL %d\n",
+                       VERBOSE_MSG(qry, "=> wildcard: skipping %s, rank 0%.2o, new TTL %d\n",
                                        eh->is_packet ? "packet" : "RR", eh->rank, new_ttl);
                        return ctx->state;
                }
@@ -569,7 +569,7 @@ do_soa:
                /* Check if the record is OK. */
                int32_t new_ttl = get_new_ttl(eh, qry, k->zname, KNOT_RRTYPE_SOA);
                if (new_ttl < 0 || eh->rank < lowest_rank || eh->is_packet) {
-                       VERBOSE_MSG(qry, "=> SOA unfit %s: rank 0%0.2o, new TTL %d\n",
+                       VERBOSE_MSG(qry, "=> SOA unfit %s: rank 0%.2o, new TTL %d\n",
                                        (eh->is_packet ? "packet" : "RR"),
                                        eh->rank, new_ttl);
                        return ctx->state;
@@ -871,7 +871,7 @@ static int answer_simple_hit(kr_layer_t *ctx, knot_pkt_t *pkt, uint16_t type,
        if (qry->flags.DNSSEC_INSECURE) {
                qry->flags.DNSSEC_WANT = false;
        }
-       VERBOSE_MSG(qry, "=> satisfied by exact RR or CNAME: rank 0%0.2o, new TTL %d\n",
+       VERBOSE_MSG(qry, "=> satisfied by exact RR or CNAME: rank 0%.2o, new TTL %d\n",
                        eh->rank, new_ttl);
        return kr_ok();
 }
@@ -901,7 +901,7 @@ static int found_exact_hit(kr_layer_t *ctx, knot_pkt_t *pkt, knot_db_val_t val,
                 * LATER(optim.): It's unlikely that we find a negative one,
                 * so we might theoretically skip all the cache code. */
 
-               VERBOSE_MSG(qry, "=> skipping exact %s: rank 0%0.2o (min. 0%0.2o), new TTL %d\n",
+               VERBOSE_MSG(qry, "=> skipping exact %s: rank 0%.2o (min. 0%.2o), new TTL %d\n",
                                eh->is_packet ? "packet" : "RR", eh->rank, lowest_rank, new_ttl);
                return kr_error(ENOENT);
        }
@@ -1053,7 +1053,7 @@ static knot_db_val_t closest_NS(kr_layer_t *ctx, struct key *k)
                                        const char *packet_str =
                                                eh->is_packet ? "packet" : "RR";
                                        VERBOSE_MSG(qry, "=> skipping unfit %s %s: "
-                                               "rank 0%0.2o, new TTL %d\n",
+                                               "rank 0%.2o, new TTL %d\n",
                                                type_str, packet_str,
                                                eh->rank, new_ttl);
                                }
index e355b2406118c527d6516f79f529b9e0e009c065..b6bc24ca587a55998ba870606a36bcb64a81195e 100644 (file)
@@ -161,7 +161,7 @@ void stash_pkt(const knot_pkt_t *pkt, const struct kr_query *qry,
        WITH_VERBOSE(qry) {
                auto_free char *type_str = kr_rrtype_text(pkt_type),
                        *owner_str = kr_dname_text(owner);
-               VERBOSE_MSG(qry, "=> stashed packet: rank 0%0.2o, TTL %d, "
+               VERBOSE_MSG(qry, "=> stashed packet: rank 0%.2o, TTL %d, "
                                "%s %s (%d B)\n",
                                eh->rank, eh->ttl,
                                type_str, owner_str, (int)val_new_entry.len);
@@ -232,7 +232,7 @@ int answer_from_pkt(kr_layer_t *ctx, knot_pkt_t *pkt, uint16_t type,
                qry->flags.DNSSEC_WANT = false;
        }
        qry->flags.DNSSEC_OPTOUT = eh->has_optout;
-       VERBOSE_MSG(qry, "=> satisfied by exact packet: rank 0%0.2o, new TTL %d\n",
+       VERBOSE_MSG(qry, "=> satisfied by exact packet: rank 0%.2o, new TTL %d\n",
                        eh->rank, new_ttl);
        return kr_ok();
 }
index d36842f3fda8af3d292c47691a1ceb6c98e7defa..19f0856213cc47ece9b981945d12242ad378a481 100644 (file)
 #define KR_PURE __attribute__((__pure__))
 #define KR_NORETURN __attribute__((__noreturn__))
 #define KR_COLD __attribute__((__cold__))
+#define KR_PRINTF(n) __attribute__((format (printf, n, (n+1))))
 #else
 #define KR_EXPORT
 #define KR_CONST
 #define KR_PURE
 #define KR_NORETURN
 #define KR_COLD
+#define KR_PRINTF(n)
 #endif
 
 #ifndef uint /* Redefining typedef is a C11 feature. */
index 3465cdc503b1f4cab705fe023d032d0523cb4f0a..469a2a0d86c998d9bcd99266a664979a523d2019 100644 (file)
@@ -855,7 +855,7 @@ int kr_make_query(struct kr_query *query, knot_pkt_t *pkt)
                char name_str[KNOT_DNAME_MAXLEN], type_str[16];
                knot_dname_to_str(name_str, query->sname, sizeof(name_str));
                knot_rrtype_to_string(query->stype, type_str, sizeof(type_str));
-               QVERBOSE_MSG(query, "'%s' type '%s' id was assigned, parent id %hu\n",
+               QVERBOSE_MSG(query, "'%s' type '%s' id was assigned, parent id %u\n",
                            name_str, type_str, query->parent ? query->parent->id : 0);
        }
        return kr_ok();
index 0e05786d7afc0b82eff6177a7bdd0f23c001ec70..8d210728a3d7c3bdc9f2f4d1f7ce62b6b25fb123 100644 (file)
@@ -54,7 +54,8 @@ KR_EXPORT extern bool kr_verbose_status;
 KR_EXPORT bool kr_verbose_set(bool status);
 
 /** Log a message if in --verbose mode. */
-KR_EXPORT void kr_log_verbose(const char *fmt, ...);
+KR_EXPORT KR_PRINTF(1)
+void kr_log_verbose(const char *fmt, ...);
 
 /**
  * @brief Return true if the query has request log handler installed.
@@ -68,7 +69,8 @@ KR_EXPORT void kr_log_verbose(const char *fmt, ...);
  * @param  fmt message format
  * @return true if the message was logged
  */
-KR_EXPORT bool kr_log_trace(const struct kr_query *query, const char *source, const char *fmt, ...);
+KR_EXPORT KR_PRINTF(3)
+bool kr_log_trace(const struct kr_query *query, const char *source, const char *fmt, ...);
 
 #ifdef NOVERBOSELOG
 /* Efficient compile-time disabling of verbose messages. */
@@ -349,6 +351,7 @@ static inline uint16_t kr_rrset_type_maysig(const knot_rrset_t *rr)
 }
 
 /** Printf onto the lua stack, avoiding additional copy (thin wrapper). */
+KR_PRINTF(2)
 static inline const char *lua_push_printf(lua_State *L, const char *fmt, ...)
 {
        va_list args;