[9.18] fix: dev: Add and use __attribute__((nonnull)) in dnssec-signzone.c

Clang 20 was spuriously warning about the possibility of passing a NULL file pointer
to `fprintf()`, which uses the 'nonnull' attribute. To silence the warning, the functions
calling `fprintf()` have been marked with the same attribute to assure that NULL can't be
passed to them in the first place.

Close #5487

Backport of MR !10888

Merge branch 'backport-5487-mark-passed-file-pointer-as-nonnull-in-dnssec-signzone-9.18' into 'bind-9.18'

See merge request isc-projects/bind9!10914
This commit is contained in:
Ondřej Surý 2025-08-28 17:02:56 +02:00
commit 48c30cfcd0
2 changed files with 11 additions and 0 deletions

View file

@ -3199,6 +3199,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);
@ -3215,6 +3217,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) {
@ -4021,6 +4025,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);
}

View file

@ -82,3 +82,9 @@
#endif /* HAVE_FUNC_ATTRIBUTE_MALLOC */
#define ISC_ATTR_UNUSED __attribute__((__unused__))
#if __has_attribute(__nonnull__)
#define ISC_ATTR_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
#else
#define ISC_ATTR_NONNULL(...)
#endif