On 27-Jun-19 11:40 AM, Bruce Richardson wrote:
Add stats functions to track what is happening in the driver, and put
unit tests to check those.
Signed-off-by: Bruce Richardson <bruce.richard...@intel.com>
---
<snip>
+ /* allocate memory for xstats names and values */
+ nb_xstats = rte_rawdev_xstats_names_get(dev_id, NULL, 0);
+
+ snames = malloc(sizeof(*snames) * nb_xstats);
+ if (snames == NULL) {
+ printf("Error allocating xstat names memory\n");
+ return -1;
+ }
+ rte_rawdev_xstats_names_get(dev_id, snames, nb_xstats);
+
+ ids = malloc(sizeof(*ids) * nb_xstats);
+ if (ids == NULL) {
+ printf("Error allocating xstat ids memory\n");
+ return -1;
Leaking snames here.
+ }
+ for (i = 0; i < nb_xstats; i++)
+ ids[i] = i;
+
+ stats = malloc(sizeof(*stats) * nb_xstats);
+ if (stats == NULL) {
+ printf("Error allocating xstat memory\n");
+ return -1;
Leaking snames and ids here. Perhaps a goto and a ret value wouldn't hurt :)
--
Thanks,
Anatoly