From e34c028af1080720f2c5cca7ea1c88af5cc5c49f Mon Sep 17 00:00:00 2001 From: Huaqiang Date: Fri, 10 May 2019 23:21:47 +0800 Subject: [PATCH] virresctrl: Sort resctrl array correctly in virResctrlMonitorGetStats() The qsort element is a pointer of virResctrlMonitorStats, and the comparing function's arguments have a type of pointer of virResctrlMonitorStatsPtr. Signed-off-by: Huaqiang Signed-off-by: Michal Privoznik --- src/util/virresctrl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index b845f366f0..90532cf1cc 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2659,8 +2659,8 @@ static int virResctrlMonitorStatsSorter(const void *a, const void *b) { - return ((virResctrlMonitorStatsPtr)a)->id - - ((virResctrlMonitorStatsPtr)b)->id; + return (*(virResctrlMonitorStatsPtr *)a)->id + - (*(virResctrlMonitorStatsPtr *)b)->id; } @@ -2758,7 +2758,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor, /* Sort in id's ascending order */ if (*nstats) - qsort(*stats, *nstats, sizeof(*stat), virResctrlMonitorStatsSorter); + qsort(*stats, *nstats, sizeof(**stats), virResctrlMonitorStatsSorter); ret = 0; cleanup: