[dpdk-dev] mem: fix handling return value

Message ID 1524730013-61990-1-git-send-email-jianfeng.tan@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Jianfeng Tan April 26, 2018, 8:06 a.m. UTC
  resize_hugefile() returns either 0 (which indicates success) or -1
(which indicates failure). We failed to check the success as we
use --single-file-segments option.

Fixes: 2a04139f66b4 ("eal: add single file segments option")

Cc: Anatoly Burakov <anatoly.burakov@intel.com>

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_memalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Anatoly Burakov April 26, 2018, 8:10 a.m. UTC | #1
On 26-Apr-18 9:06 AM, Jianfeng Tan wrote:
> resize_hugefile() returns either 0 (which indicates success) or -1
> (which indicates failure). We failed to check the success as we
> use --single-file-segments option.
> 
> Fixes: 2a04139f66b4 ("eal: add single file segments option")
> 
> Cc: Anatoly Burakov <anatoly.burakov@intel.com>
> 
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  
Thomas Monjalon April 27, 2018, 9:38 p.m. UTC | #2
26/04/2018 10:10, Burakov, Anatoly:
> On 26-Apr-18 9:06 AM, Jianfeng Tan wrote:
> > resize_hugefile() returns either 0 (which indicates success) or -1
> > (which indicates failure). We failed to check the success as we
> > use --single-file-segments option.
> > 
> > Fixes: 2a04139f66b4 ("eal: add single file segments option")
> > 
> > Cc: Anatoly Burakov <anatoly.burakov@intel.com>
> > 
> > Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal_memalloc.c b/lib/librte_eal/linuxapp/eal/eal_memalloc.c
index 1f553dd..301c34e 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memalloc.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memalloc.c
@@ -419,7 +419,7 @@  alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 	if (internal_config.single_file_segments) {
 		map_offset = seg_idx * alloc_sz;
 		ret = resize_hugefile(fd, map_offset, alloc_sz, true);
-		if (ret < 1)
+		if (ret < 0)
 			goto resized;
 	} else {
 		map_offset = 0;