]> git.droids-corp.org - dpdk.git/commitdiff
app/procinfo: fix xstats by ID on 32-bit
authorMichal Jastrzebski <michalx.k.jastrzebski@intel.com>
Tue, 9 May 2017 05:23:29 +0000 (07:23 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 10 May 2017 16:49:59 +0000 (18:49 +0200)
Coverity reported that an argument for sizeof was used improperly.
We should allocate memory for value size that pointer points to,
instead of pointer size itself.

Coverity issue: 144523, 144521
Fixes: 7ac16a3660c0 ("app/proc-info: support xstats by ID and by name")
Signed-off-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
app/proc_info/main.c

index 17a1c87494b8516d40a5e1e409c175fb12efb509..d4f6a8236e3fd448ee313a0da28dd5756b2ae550 100644 (file)
@@ -434,7 +434,7 @@ nic_xstats_by_ids_display(uint8_t port_id, uint64_t *ids, int len)
        int ret, i;
        static const char *nic_stats_border = "########################";
 
-       values = malloc(sizeof(values) * len);
+       values = malloc(sizeof(*values) * len);
        if (values == NULL) {
                printf("Cannot allocate memory for xstats\n");
                return;
@@ -486,7 +486,7 @@ nic_xstats_display(uint8_t port_id)
                printf("Cannot get xstats count\n");
                return;
        }
-       values = malloc(sizeof(values) * len);
+       values = malloc(sizeof(*values) * len);
        if (values == NULL) {
                printf("Cannot allocate memory for xstats\n");
                return;