util/cbmem: Fix compare function for qsort
compare_timestamp_entries will fail for entries that are different by at least 2^32 since entry_stamp is 64-bit and the return for compare is 32-bit. This change fixes compare_timestamps by actually comparing the entries to return 1, -1 or 0 instead of doing math on them. TEST=Verified that "cbmem -t" sorts entries correctly on previously failing entries. Change-Id: I67c3c4d1761715ecbf259935fabb22ce37c3966e Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/26357 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
549080b8b3
commit
8f567320ba
|
@ -589,7 +589,12 @@ static int compare_timestamp_entries(const void *a, const void *b)
|
||||||
const struct timestamp_entry *tse_a = (struct timestamp_entry *)a;
|
const struct timestamp_entry *tse_a = (struct timestamp_entry *)a;
|
||||||
const struct timestamp_entry *tse_b = (struct timestamp_entry *)b;
|
const struct timestamp_entry *tse_b = (struct timestamp_entry *)b;
|
||||||
|
|
||||||
return tse_a->entry_stamp - tse_b->entry_stamp;
|
if (tse_a->entry_stamp > tse_b->entry_stamp)
|
||||||
|
return 1;
|
||||||
|
else if (tse_a->entry_stamp < tse_b->entry_stamp)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dump the timestamp table */
|
/* dump the timestamp table */
|
||||||
|
|
Loading…
Reference in New Issue