aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2020-12-04 07:22:01 +0000
committerOle Tr�an <otroan@employees.org>2020-12-04 08:41:38 +0000
commit86ffb6b232d5ebce03cf53249fa1514384f31cce (patch)
tree69081f9176200f415753d3da3870f48a28266078
parent068ad25c1ac1215761e1436abfc2033a6bb71b64 (diff)
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>
-rw-r--r--src/vpp/stats/stat_segment.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/vpp/stats/stat_segment.c b/src/vpp/stats/stat_segment.c
index 4244acb1dd0..0b5ea3048d5 100644
--- a/src/vpp/stats/stat_segment.c
+++ b/src/vpp/stats/stat_segment.c
@@ -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);