vlibmemory: coverity woes 46/18046/3
authorSteven Luong <sluong@cisco.com>
Wed, 6 Mar 2019 04:07:31 +0000 (20:07 -0800)
committerDamjan Marion <dmarion@me.com>
Thu, 7 Mar 2019 10:26:12 +0000 (10:26 +0000)
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 <sluong@cisco.com>
src/vlibmemory/memory_shared.c

index 7526d87..703db9d 100644 (file)
@@ -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);