From ebe2bbe76c44c0fa90c5f3cce03cea416dd97bed Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 6 Jul 2026 22:31:11 +0200 Subject: [PATCH] Document handle_close failures --- cmdline/check.c | 4 ++++ cmdline/dry.c | 5 +++++ cmdline/scrub.c | 4 ++++ cmdline/sync.c | 8 ++++++++ 4 files changed, 21 insertions(+) diff --git a/cmdline/check.c b/cmdline/check.c index 70cf88c9..17af6ce8 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -2004,6 +2004,10 @@ bail: ret = handle_close(&handle[j]); if (ret == -1) { /* LCOV_EXCL_START */ + /* + * If handle_close fails, the handle was open (f != -1), which + * guarantees that both file and disk pointers are valid. + */ log_tag("%s:%" PRIu64 ":%s:%s: Close error. %s.\n", es(errno), blockmax, disk->name, esc_tag(file->sub), strerror(errno)); log_fatal_errno(errno, disk->name); diff --git a/cmdline/dry.c b/cmdline/dry.c index 8ea55991..04343764 100644 --- a/cmdline/dry.c +++ b/cmdline/dry.c @@ -60,6 +60,7 @@ static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task ret = handle_close(handle); if (ret == -1) { /* LCOV_EXCL_START */ + /* * This one is really an unexpected error, because we are only reading * and closing a descriptor should never fail @@ -368,6 +369,10 @@ bail: ret = handle_close(&handle[j]); if (ret == -1) { /* LCOV_EXCL_START */ + /* + * If handle_close fails, the handle was open (f != -1), which + * guarantees that both file and disk pointers are valid. + */ log_tag("%s:%" PRIu64 ":%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno)); log_fatal_errno(errno, disk->name); diff --git a/cmdline/scrub.c b/cmdline/scrub.c index 5c536745..951b610a 100644 --- a/cmdline/scrub.c +++ b/cmdline/scrub.c @@ -720,6 +720,10 @@ bail: ret = handle_close(&handle[j]); if (ret == -1) { /* LCOV_EXCL_START */ + /* + * If handle_close fails, the handle was open (f != -1), which + * guarantees that both file and disk pointers are valid. + */ log_tag("%s:%" PRIu64 ":%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno)); log_fatal_errno(errno, disk->name); diff --git a/cmdline/sync.c b/cmdline/sync.c index e5f16631..2e7fb3cd 100644 --- a/cmdline/sync.c +++ b/cmdline/sync.c @@ -354,6 +354,10 @@ bail: ret = handle_close(&handle[j]); if (ret == -1) { /* LCOV_EXCL_START */ + /* + * If handle_close fails, the handle was open (f != -1), which + * guarantees that both file and disk pointers are valid. + */ log_tag("%s:%" PRIu64 ":%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno)); log_fatal_errno(errno, disk->name); @@ -1485,6 +1489,10 @@ bail: ret = handle_close(&handle[j]); if (ret == -1) { /* LCOV_EXCL_START */ + /* + * If handle_close fails, the handle was open (f != -1), which + * guarantees that both file and disk pointers are valid. + */ log_tag("%s:%" PRIu64 ":%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno)); log_fatal_errno(errno, disk->name);