From: Vladimír Čunát Date: Thu, 25 Jan 2018 13:24:24 +0000 (+0100) Subject: treewide: compiler warnings for printf-style functions X-Git-Tag: v2.0.0~6^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=333bce84a46c8eb252b1fae80aebe829d861e839;p=thirdparty%2Fknot-resolver.git treewide: compiler warnings for printf-style functions --- diff --git a/lib/cache.c b/lib/cache.c index 635dbf5f2..e7c814955 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -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); } diff --git a/lib/cache/entry_pkt.c b/lib/cache/entry_pkt.c index e355b2406..b6bc24ca5 100644 --- a/lib/cache/entry_pkt.c +++ b/lib/cache/entry_pkt.c @@ -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(); } diff --git a/lib/defines.h b/lib/defines.h index d36842f3f..19f085621 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -28,12 +28,14 @@ #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. */ diff --git a/lib/layer/iterate.c b/lib/layer/iterate.c index 3465cdc50..469a2a0d8 100644 --- a/lib/layer/iterate.c +++ b/lib/layer/iterate.c @@ -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(); diff --git a/lib/utils.h b/lib/utils.h index 0e05786d7..8d210728a 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -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;