bitrate: fix unchecked return value
authorAndrius Sirvys <andrius.sirvys@intel.com>
Thu, 18 Apr 2019 08:52:06 +0000 (09:52 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 22 Apr 2019 22:19:06 +0000 (00:19 +0200)
Checking the return value of rte_metrics_update_values, if failed
returning that value.
Coverity had picked up that that the return value wasn't being checked.

Coverity issue: 336863
Fixes: 2ad7ba9a6567 ("bitrate: add bitrate statistics library")
Cc: stable@dpdk.org
Signed-off-by: Andrius Sirvys <andrius.sirvys@intel.com>
Acked-by: Rami Rosen <ramirose@gmail.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
lib/librte_bitratestats/rte_bitrate.c

index c4b28f6..639e475 100644 (file)
@@ -67,6 +67,7 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,
        int64_t delta;
        const int64_t alpha_percent = 20;
        uint64_t values[6];
+       int ret;
 
        if (bitrate_data == NULL)
                return -EINVAL;
@@ -124,7 +125,10 @@ rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,
        values[3] = port_data->mean_obits;
        values[4] = port_data->peak_ibits;
        values[5] = port_data->peak_obits;
-       rte_metrics_update_values(port_id, bitrate_data->id_stats_set,
+       ret = rte_metrics_update_values(port_id, bitrate_data->id_stats_set,
                values, ARRAY_SIZE(values));
+       if (ret < 0)
+               return ret;
+
        return 0;
 }