DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: fix build issue caused by unchecked returned values
@ 2018-03-30 15:16 Maxime Coquelin
  2018-03-30 15:18 ` Andrew Rybchenko
  2018-03-30 15:31 ` Ferruh Yigit
  0 siblings, 2 replies; 5+ messages in thread
From: Maxime Coquelin @ 2018-03-30 15:16 UTC (permalink / raw)
  To: dev, xiangxia.m.yue, ferruh.yigit, thomas, tredaelli, arybchenko
  Cc: Maxime Coquelin

This patch fixes below build issue seen with some compilers
or build options:

lib/librte_vhost/fd_man.c: In function ‘fdset_pipe_read_cb’:
lib/librte_vhost/fd_man.c:284:2: error: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Werror=unused-result]
  read(readfd, charbuf, sizeof(charbuf));
  ^
lib/librte_vhost/fd_man.c: In function ‘fdset_pipe_notify’:
lib/librte_vhost/fd_man.c:324:2: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
  write(fdset->u.writefd, "1", 1);
  ^

Reported-by: Andrew Rybchenko <arybchenko@solarflare.com>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/librte_vhost/fd_man.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/librte_vhost/fd_man.c b/lib/librte_vhost/fd_man.c
index ca1ba2622..1f9e22f96 100644
--- a/lib/librte_vhost/fd_man.c
+++ b/lib/librte_vhost/fd_man.c
@@ -281,7 +281,13 @@ fdset_pipe_read_cb(int readfd, void *dat __rte_unused,
 		   int *remove __rte_unused)
 {
 	char charbuf[16];
-	read(readfd, charbuf, sizeof(charbuf));
+	int r = read(readfd, charbuf, sizeof(charbuf));
+	/*
+	 * Just an optimization, we don't care if read() failed
+	 * so ignore explicitly its return value to make the
+	 * compiler happy
+	 */
+	RTE_SET_USED(r);
 }
 
 void
@@ -321,5 +327,12 @@ fdset_pipe_init(struct fdset *fdset)
 void
 fdset_pipe_notify(struct fdset *fdset)
 {
-	write(fdset->u.writefd, "1", 1);
+	int r = write(fdset->u.writefd, "1", 1);
+	/*
+	 * Just an optimization, we don't care if read() failed
+	 * so ignore explicitly its return value to make the
+	 * compiler happy
+	 */
+	RTE_SET_USED(r);
+
 }
-- 
2.14.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-30 15:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-30 15:16 [dpdk-dev] [PATCH] vhost: fix build issue caused by unchecked returned values Maxime Coquelin
2018-03-30 15:18 ` Andrew Rybchenko
2018-03-30 15:21   ` Ferruh Yigit
2018-03-30 15:26     ` Maxime Coquelin
2018-03-30 15:31 ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).