From: Steven Luong Date: Wed, 6 Mar 2019 04:07:31 +0000 (-0800) Subject: vlibmemory: coverity woes X-Git-Tag: v19.04-rc1~293 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=8905347d815a9ca0a7453351dbee7c94ebb14e49;p=vpp.git vlibmemory: coverity woes Coverity complains about resource leak after open when fd gets 0 with below warning. off_by_one: Testing whether handle tfd is strictly greater than zero is suspicious. tfd leaks when it is zero. It is right. 0 is a valid fd. -1 is not. Change-Id: I22c2eb75b99bb6209921b9f874190cbbdf10e6ce Signed-off-by: Steven Luong --- diff --git a/src/vlibmemory/memory_shared.c b/src/vlibmemory/memory_shared.c index 7526d87eb4b..703db9da4ec 100644 --- a/src/vlibmemory/memory_shared.c +++ b/src/vlibmemory/memory_shared.c @@ -552,7 +552,7 @@ vl_map_shmem (const char *region_name, int is_vlib) while (nanosleep (&ts, &tsrem) < 0) ts = tsrem; tfd = open ((char *) api_name, O_RDWR); - if (tfd > 0) + if (tfd >= 0) break; } vec_free (api_name);