<p>Furquan Shaikh has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/26357">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">util/cbmem: Fix compare function for qsort<br><br>compare_timestamp_entries will fail for entries that are different by<br>at least 2^32 since entry_stamp is 64-bit and the return for compare<br>is 32-bit. This change fixes compare_timestamps by actually comparing<br>the entries to return 1, -1 or 0 instead of doing math on them.<br><br>TEST=Verified that "cbmem -t" sorts entries correctly on previously<br>failing entries.<br><br>Change-Id: I67c3c4d1761715ecbf259935fabb22ce37c3966e<br>Signed-off-by: Furquan Shaikh <furquan@google.com><br>---<br>M util/cbmem/cbmem.c<br>1 file changed, 5 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/57/26357/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c</span><br><span>index 21da71b..60a3d1d 100644</span><br><span>--- a/util/cbmem/cbmem.c</span><br><span>+++ b/util/cbmem/cbmem.c</span><br><span>@@ -589,7 +589,11 @@</span><br><span>         const struct timestamp_entry *tse_a = (struct timestamp_entry *)a;</span><br><span>   const struct timestamp_entry *tse_b = (struct timestamp_entry *)b;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  return tse_a->entry_stamp - tse_b->entry_stamp;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (tse_a->entry_stamp > tse_b->entry_stamp)</span><br><span style="color: hsl(120, 100%, 40%);">+         return 1;</span><br><span style="color: hsl(120, 100%, 40%);">+     else if (tse_a->entry_stamp < tse_b->entry_stamp)</span><br><span style="color: hsl(120, 100%, 40%);">+            return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    return 0;</span><br><span> }</span><br><span> </span><br><span> /* dump the timestamp table */</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/26357">change 26357</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/26357"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I67c3c4d1761715ecbf259935fabb22ce37c3966e </div>
<div style="display:none"> Gerrit-Change-Number: 26357 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Furquan Shaikh <furquan@google.com> </div>