Message ID | 1402334881-19310-3-git-send-email-imammedo@redhat.com |
---|---|
State | New |
Headers | show |
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 9f091c6..8c26568 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -73,8 +73,14 @@ static gint pc_dimm_addr_sort(gconstpointer a, gconstpointer b) { PCDIMMDevice *x = PC_DIMM(a); PCDIMMDevice *y = PC_DIMM(b); + Int128 diff = int128_sub(int128_make64(x->addr), int128_make64(y->addr)); - return x->addr - y->addr; + if (int128_lt(diff, int128_zero())) { + return -1; + } else if (int128_gt(diff, int128_zero())) { + return 1; + } + return 0; } static int pc_dimm_built_list(Object *obj, void *opaque)
GCompareFunc(a, b) used by g_slist_insert_sorted() return 'gint', however it might be too small to fit difference between 2 addresses. So use 128bit calculate difference and normalize result to -1/0/1 return values. Reported-By: Andrey Korolyov <andrey@xdel.ru> Signed-off-by: Igor Mammedov <imammedo@redhat.com> --- hw/mem/pc-dimm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)