From eb36c35ccf83ea94d46a3bcb282c01ceeaeb3bab Mon Sep 17 00:00:00 2001 From: Christos Margiolis Date: Tue, 27 Oct 2026 12:27:32 +0100 Subject: [PATCH] sound tests: Check the return value of close(2) While here, remove two munmap(2) calls on mappings the tests require to have failed, since they are practically dead. MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D60800 --- tests/sys/sound/mmap.c | 8 ++------ tests/sys/sound/polling.c | 10 +++++----- tests/sys/sound/sndstat.c | 4 ++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/tests/sys/sound/mmap.c b/tests/sys/sound/mmap.c index 95ed9a483274..e14405e1b4e5 100644 --- a/tests/sys/sound/mmap.c +++ b/tests/sys/sound/mmap.c @@ -40,9 +40,7 @@ ATF_TC_BODY(mmap_offset_overflow, tc) buf = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, off); ATF_REQUIRE_MSG(buf == MAP_FAILED, FMT_ERR("mmap")); - munmap(buf, len); - - close(fd); + ATF_REQUIRE(close(fd) == 0); } /* @@ -124,9 +122,7 @@ ATF_TC_BODY(mmap_reject_prot_exec, tc) fd, 0); ATF_REQUIRE_MSG(buf == MAP_FAILED, FMT_ERR("mmap")); - munmap(buf, len); - - close(fd); + ATF_REQUIRE(close(fd) == 0); } /* diff --git a/tests/sys/sound/polling.c b/tests/sys/sound/polling.c index b7a328d13d4c..0f18c96e087c 100644 --- a/tests/sys/sound/polling.c +++ b/tests/sys/sound/polling.c @@ -98,7 +98,7 @@ ATF_TC_BODY(poll_kqueue, tc) ATF_REQUIRE_MSG(read(fd, buf, sizeof(buf)) > 0, FMT_ERR("read")); EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0); - close(kq); + ATF_REQUIRE(close(kq) == 0); kq = kqueue(); ATF_REQUIRE_MSG(kq >= 0, FMT_ERR("kqueue")); @@ -113,9 +113,9 @@ ATF_TC_BODY(poll_kqueue, tc) ATF_REQUIRE_MSG(write(fd, buf, sizeof(buf)) > 0, FMT_ERR("write")); EV_SET(&ev, fd, EVFILT_WRITE, EV_DELETE, 0, 0, 0); - close(kq); + ATF_REQUIRE(close(kq) == 0); - close(fd); + ATF_REQUIRE(close(fd) == 0); } ATF_TC(poll_poll); @@ -154,7 +154,7 @@ ATF_TC_BODY(poll_poll, tc) wr = true; } } - close(fd); + ATF_REQUIRE(close(fd) == 0); } ATF_TC(poll_select); @@ -192,7 +192,7 @@ ATF_TC_BODY(poll_select, tc) wr = true; } } - close(fd); + ATF_REQUIRE(close(fd) == 0); } ATF_TP_ADD_TCS(tp) diff --git a/tests/sys/sound/sndstat.c b/tests/sys/sound/sndstat.c index bbf18aca2824..db8c9a9f5a0c 100644 --- a/tests/sys/sound/sndstat.c +++ b/tests/sys/sound/sndstat.c @@ -196,7 +196,7 @@ ATF_TC_BODY(sndstat_nv, tc) free(arg.buf); nvlist_destroy(nvl); - close(fd); + ATF_REQUIRE(close(fd) == 0); } #define UDEV_PROVIDER "sndstat_udev" @@ -374,7 +374,7 @@ ATF_TC_BODY(sndstat_udev, tc) free(arg.buf); nvlist_destroy(nvl); - close(fd); + ATF_REQUIRE(close(fd) == 0); } ATF_TP_ADD_TCS(tp)