diff options
author | Steven Luong <sluong@cisco.com> | 2024-06-29 16:26:54 -0700 |
---|---|---|
committer | Steven Luong <sluong@cisco.com> | 2024-06-29 16:29:15 -0700 |
commit | 1b8cef111b694dc4e84673aa73a13b050ae6dc80 (patch) | |
tree | 4dcf36da280d048afa82e4c1a136454a532bca06 /src/plugins | |
parent | d2d41bc34e1663803037fc0a6c7bda9078cef2b6 (diff) |
unittest: coverity woe
check return value after strstr()
Type: fix
Change-Id: Ib6eb82b6a52c7e08785f6deb73e6cc7a10e7f61b
Signed-off-by: Steven Luong <sluong@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/unittest/session_test.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/unittest/session_test.c b/src/plugins/unittest/session_test.c index 33649662e5e..12d000bd46f 100644 --- a/src/plugins/unittest/session_test.c +++ b/src/plugins/unittest/session_test.c @@ -2079,11 +2079,14 @@ session_get_memory_usage (void) clib_mem_heap_t *heap = clib_mem_get_per_cpu_heap (); u8 *s = 0; char *ss; - f32 used; + f32 used = 0.0; s = format (s, "%U\n", format_clib_mem_heap, heap, 0); ss = strstr ((char *) s, "used:"); - sscanf (ss, "used: %f", &used); + if (ss) + sscanf (ss, "used: %f", &used); + else + clib_warning ("substring 'used:' not found from show memory"); vec_free (s); return (used); } |