stats: check if stats vector entry is empty
When a stats entry is removed it is marked empty. The stats client did not check for that and returned an empty string. This resulted in blank lines in vpp_get_stats. Fix by returning null instead and checking value. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I08a39ba3ef4421bf275747a6300f97fe36791b50
This commit is contained in:

committed by
Andrew Yourtchenko

parent
003330c55a
commit
22ca0d03db
@ -512,6 +512,11 @@ stat_segment_index_to_name_r (uint32_t index, stat_client_main_t * sm)
|
|||||||
return 0;
|
return 0;
|
||||||
vec = get_stat_vector_r (sm);
|
vec = get_stat_vector_r (sm);
|
||||||
ep = vec_elt_at_index (vec, index);
|
ep = vec_elt_at_index (vec, index);
|
||||||
|
if (ep->type == STAT_DIR_TYPE_EMPTY)
|
||||||
|
{
|
||||||
|
stat_segment_access_end (&sa, sm);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!stat_segment_access_end (&sa, sm))
|
if (!stat_segment_access_end (&sa, sm))
|
||||||
return 0;
|
return 0;
|
||||||
return strdup (ep->name);
|
return strdup (ep->name);
|
||||||
|
@ -179,6 +179,8 @@ reconnect:
|
|||||||
for (i = 0; i < vec_len (dir); i++)
|
for (i = 0; i < vec_len (dir); i++)
|
||||||
{
|
{
|
||||||
char *n = stat_segment_index_to_name (dir[i]);
|
char *n = stat_segment_index_to_name (dir[i]);
|
||||||
|
if (!n)
|
||||||
|
continue;
|
||||||
printf ("%s\n", n);
|
printf ("%s\n", n);
|
||||||
free (n);
|
free (n);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user