aboutsummaryrefslogtreecommitdiff
path: root/util/cbmem
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2018-05-17 15:08:03 -0700
committerAaron Durbin <adurbin@chromium.org>2018-05-18 20:13:47 +0000
commit8f567320ba85f1cddbb6770b1033961c3d7486ff (patch)
tree5e3bd362654ffb9827e80a4a01b537b461fcb5b1 /util/cbmem
parent549080b8b3ba67ab43f7232e03727899210a6a92 (diff)
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>
Diffstat (limited to 'util/cbmem')
-rw-r--r--util/cbmem/cbmem.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c
index 21da71b24f..42761dc846 100644
--- a/util/cbmem/cbmem.c
+++ b/util/cbmem/cbmem.c
@@ -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_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 */