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 <huaqiang.wang@intel.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Huaqiang 2019-05-10 23:21:47 +08:00 committed by Michal Privoznik
parent d55be92286
commit e34c028af1

View File

@ -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: