[dpdk-dev] librte_vhost: Fix compilation issue

Message ID 1414564778-25056-1-git-send-email-changchun.ouyang@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Ouyang Changchun Oct. 29, 2014, 6:39 a.m. UTC
  It fixes this compilation complain: "error: ignoring return value of 'realpath', 
declared with attribute warn_unused_result [-Werror=unused-result]"

Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
---
 lib/librte_vhost/virtio-net.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
  

Comments

Thomas Monjalon Oct. 29, 2014, 11:21 p.m. UTC | #1
2014-10-29 14:39, Ouyang Changchun:
> It fixes this compilation complain: "error: ignoring return value of 'realpath', 
> declared with attribute warn_unused_result [-Werror=unused-result]"
> 
> Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>

Applied

Curiosity: how did you see this issue?

Thanks
  
Ouyang Changchun Oct. 30, 2014, 12:33 a.m. UTC | #2
Hi Thomas, 

Thanks for applying it.

This issue is reported by a customer.
We can reproduce it in Ubuntu14, on that environment, gcc will check any unused result of function.

Thanks and regards,
Changchun

-----Original Message-----
From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] 
Sent: Thursday, October 30, 2014 7:21 AM
To: Ouyang, Changchun
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] librte_vhost: Fix compilation issue

2014-10-29 14:39, Ouyang Changchun:
> It fixes this compilation complain: "error: ignoring return value of 
> 'realpath', declared with attribute warn_unused_result [-Werror=unused-result]"
> 
> Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>

Applied

Curiosity: how did you see this issue?

Thanks
--
Thomas
  

Patch

diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index 27ba175..8015dd8 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -133,6 +133,7 @@  host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,
 	char mapfile[PATH_MAX];
 	char procdir[PATH_MAX];
 	char resolved_path[PATH_MAX];
+	char *path = NULL;
 	FILE		*fmap;
 	void		*map;
 	uint8_t		found = 0;
@@ -235,9 +236,11 @@  host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,
 	while (NULL != (dptr = readdir(dp))) {
 		snprintf(memfile, PATH_MAX, "/proc/%u/fd/%s",
 				pid, dptr->d_name);
-	    realpath(memfile, resolved_path);
-		if (resolved_path == NULL) {
-			RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") Failed to resolve fd directory\n", dev->device_fh);
+		path = realpath(memfile, resolved_path);
+		if (path == NULL) {
+			RTE_LOG(ERR, VHOST_CONFIG,
+				"(%"PRIu64") Failed to resolve fd directory\n",
+				dev->device_fh);
 			closedir(dp);
 			return -1;
 		}