diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Compare repository idle times by sign
The idle-sort comparator returned a 64-bit time difference truncated
to int, which could flip sign and leave the ordering inconsistent.
Diffstat (limited to 'source')
| -rw-r--r-- | source/ui-repolist.c | 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 7 insertions, 1 deletion
diff --git a/source/ui-repolist.c b/source/ui-repolist.c index fc198e5..9c4fd6f 100644 --- a/source/ui-repolist.c +++ b/source/ui-repolist.c @@ -242,7 +242,13 @@ static int sort_idle(const void *a, const void *b) t1 = t2 = 0; get_repo_modtime(r1, &t1); get_repo_modtime(r2, &t2); - return t2 - t1; + /* Return the sign only; a truncated 64-bit time_t difference could + * flip and make the comparator inconsistent. */ + if (t2 > t1) + return 1; + if (t2 < t1) + return -1; + return 0; } static int sort_section(const void *a, const void *b) |
