Skip to contentSkip to conversation

selftests: ublk: fix unused_result error

PATCH Applied Dirk Gouders 3 participants 3 messages Sep 14 – Sep 21

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: ublk: fix unused_result error

Commit 166b476b8dee (selftests/ublk: add shared memory zero-copy support in kublk, 2026-03-31) introduced a write(2), ignoring its return value and thus causing an error, when building.

Fix this by using the common workaround "(void)!" to trick the compiler the result is being used.

---
 tools/testing/selftests/ublk/kublk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ublk/kublk.c +1 -1
index 2400b4615766..5b19bfcfa8d7 100644
@@ -1589,7 +1589,7 @@ static int ublk_start_daemon(const struct dev_ctx *ctx, struct ublk_dev *dev)
 
 	/* Signal listener thread to stop and wait for it */
 	if (linfo.stop_efd >= 0) {
-		write(linfo.stop_efd, &stop_val, sizeof(stop_val));
+		(void)!write(linfo.stop_efd, &stop_val, sizeof(stop_val));
 		pthread_join(listener, NULL);
 		close(linfo.stop_efd);
 		ublk_shmem_sock_destroy(dinfo->dev_id, linfo.sock_fd);
Signature · 1 line
2.55.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Dirk Gouders

Commit 166b476b8dee (selftests/ublk: add shared memory zero-copy support in kublk, 2026-03-31) introduced a write(2), ignoring its return value and thus causing an error, when building.

Fix this by using the common workaround "(void)!" to trick the compiler the result is being used.

---
 tools/testing/selftests/ublk/kublk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ublk/kublk.c +0 -0
index 2400b4615766..5b19bfcfa8d7 100644

tools/testing/selftests/ublk/kublk.c static int ublk_start_daemon(const struct dev_ctx *ctx, struct ublk_dev *dev) · line 1595

Quoted 8 lines
tools/testing/selftests/ublk/kublk.c +1 -1
@@ -1589,7 +1589,7 @@ static int ublk_start_daemon(const struct dev_ctx *ctx, struct ublk_dev *dev)
 
        /* Signal listener thread to stop and wait for it */
        if (linfo.stop_efd >= 0) {
-               write(linfo.stop_efd, &stop_val, sizeof(stop_val));
+               (void)!write(linfo.stop_efd, &stop_val, sizeof(stop_val));
                pthread_join(listener, NULL);
                close(linfo.stop_efd);
                ublk_shmem_sock_destroy(dinfo->dev_id, linfo.sock_fd);

Thanks,
Ming Lei

maintainer Applied
#2 lore raw
In reply to Dirk Gouders
Quoted 8 lines · Dirk Gouders

Commit 166b476b8dee (selftests/ublk: add shared memory zero-copy support in kublk, 2026-03-31) introduced a write(2), ignoring its return value and thus causing an error, when building.

Fix this by using the common workaround "(void)!" to trick the compiler the result is being used.

[...]

Applied, thanks!

[1/1] selftests: ublk: fix unused_result error

      commit: 687cb38c4330d52d58dbf426a3eb523850052d10

Best regards,

Signature · 1 line
Jens Axboe