From e1715c33bbe078246d2b9dead50170f9cf111587 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 24 Sep 2025 02:07:48 +0300 Subject: [PATCH] Fix warn_unused_result on write/read in nbd and ublk --- src/client/nbd_proxy.cpp | 8 ++++---- src/client/ublk_server.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client/nbd_proxy.cpp b/src/client/nbd_proxy.cpp index 8587e074..2f090c5f 100644 --- a/src/client/nbd_proxy.cpp +++ b/src/client/nbd_proxy.cpp @@ -912,7 +912,7 @@ protected: int r, nbd = open(path, O_RDWR), qd_fd; if (nbd < 0) { - write(notifyfd[1], &errno, sizeof(errno)); + (void)write(notifyfd[1], &errno, sizeof(errno)); exit(1); } r = ioctl(nbd, NBD_SET_SOCK, sockfd[1]); @@ -954,7 +954,7 @@ protected: close(qd_fd); // Notify parent errno = 0; - write(notifyfd[1], &errno, sizeof(errno)); + (void)write(notifyfd[1], &errno, sizeof(errno)); close(notifyfd[1]); close(sockfd[0]); if (bg) @@ -971,11 +971,11 @@ protected: ioctl(nbd, NBD_CLEAR_SOCK); exit(0); end_close: - write(notifyfd[1], &errno, sizeof(errno)); + (void)write(notifyfd[1], &errno, sizeof(errno)); close(nbd); exit(2); end_unmap: - write(notifyfd[1], &errno, sizeof(errno)); + (void)write(notifyfd[1], &errno, sizeof(errno)); ioctl(nbd, NBD_CLEAR_SOCK); close(nbd); exit(3); diff --git a/src/client/ublk_server.cpp b/src/client/ublk_server.cpp index 04d0bd57..c3779865 100644 --- a/src/client/ublk_server.cpp +++ b/src/client/ublk_server.cpp @@ -335,7 +335,7 @@ help: { daemonize_reopen_stdio(); int ok = 0; - write(notifyfd[1], &ok, sizeof(ok)); + (void)write(notifyfd[1], &ok, sizeof(ok)); close(notifyfd[1]); } else @@ -377,7 +377,7 @@ help: // Parent - check status close(notifyfd[1]); int child_errno = 1; - read(notifyfd[0], &child_errno, sizeof(child_errno)); + (void)read(notifyfd[0], &child_errno, sizeof(child_errno)); if (!child_errno) printf("/dev/ublkb%d\n", ublk_dev.dev_id); exit(child_errno);