From a5d7c8f7db6ff5d658ff1380d1e0dde6f233ab79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 21 Aug 2025 23:51:38 +0200 Subject: [PATCH] Add and use __attribute__((nonnull)) in dnssec-signzone.c Clang 20 is complaining about passing NULL to an argument with 'nonnull' attribute. Mark these two functions with the same attribute to assure that these two function also don't accept NULL as an argument. (cherry picked from commit 9e350c177403ead4c8a6630a08f36f304b04484c) --- bin/dnssec/dnssec-signzone.c | 5 +++++ lib/isc/include/isc/attributes.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 2c9b843df5..49d013afef 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -3204,6 +3204,8 @@ writeset(const char *prefix, dns_rdatatype_t type) { dns_db_detach(&db); } +static void +print_time(FILE *fp) ISC_ATTR_NONNULL(1); static void print_time(FILE *fp) { time_t currenttime = time(NULL); @@ -3220,6 +3222,8 @@ print_time(FILE *fp) { fprintf(fp, "; File written on %s\n", timebuf); } +static void +print_version(FILE *fp) ISC_ATTR_NONNULL(1); static void print_version(FILE *fp) { if (outputformat != dns_masterformat_text) { @@ -4058,6 +4062,7 @@ main(int argc, char *argv[]) { fatal("failed to open temporary output file: %s", isc_result_totext(result)); } + INSIST(outfp != NULL); removefile = true; setfatalcallback(&removetempfile); } diff --git a/lib/isc/include/isc/attributes.h b/lib/isc/include/isc/attributes.h index cdc2700016..aab0629c45 100644 --- a/lib/isc/include/isc/attributes.h +++ b/lib/isc/include/isc/attributes.h @@ -110,3 +110,9 @@ #else #define ISC_CONSTEXPR static const #endif + +#if __has_attribute(__nonnull__) +#define ISC_ATTR_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__))) +#else +#define ISC_ATTR_NONNULL(...) +#endif