stats: fix coverity issues

Usage of the possibly negative value with subsequent check on it
makes coverity very unhappy, so put the check before use.

Change-Id: I731fbe6246f9e4212d546fd9277bc1ddcd3c2ec1
Type: fix
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
This commit is contained in:
Andrew Yourtchenko
2020-12-04 07:22:01 +00:00
committed by Ole Tr�an
parent 068ad25c1a
commit 86ffb6b232

View File

@ -330,13 +330,12 @@ vlib_map_stat_segment_init (void)
mfd = clib_mem_vm_create_fd (sm->log2_page_sz, mem_name);
/* Set size */
if ((ftruncate (mfd, memory_size)) == -1)
return clib_error_return (0, "stat segment ftruncate failure");
if (mfd == -1)
return clib_error_return (0, "stat segment memory fd failure: %U",
format_clib_error, clib_mem_get_last_error ());
/* Set size */
if ((ftruncate (mfd, memory_size)) == -1)
return clib_error_return (0, "stat segment ftruncate failure");
memaddr = clib_mem_vm_map_shared (0, memory_size, mfd, 0, mem_name);