Variable total, which may be zero and result in segmentation fault.
This patch fixed it.
Fixes:
9b1249d9ff69 ("app/testpmd: support dumping socket memory")
Cc: stable@dpdk.org
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
fprintf(f,
"Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
- (double)alloc * 100 / (double)total,
+ total ? ((double)alloc * 100 / (double)total) : 0,
(double)free / (1024 * 1024),
n_alloc, n_free);
if (last_allocs)