summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/qsort.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdlib/qsort.c')
-rw-r--r--lib/libc/stdlib/qsort.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c
index 65e038c05d75..3687b0579ffd 100644
--- a/lib/libc/stdlib/qsort.c
+++ b/lib/libc/stdlib/qsort.c
@@ -111,7 +111,9 @@ qsort(void *a, size_t n, size_t es, cmp_t *cmp)
#endif
{
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
- int d, r, swaptype, swap_cnt;
+ size_t d, r;
+ int cmp_result;
+ int swaptype, swap_cnt;
loop: SWAPINIT(a, es);
swap_cnt = 0;
@@ -140,16 +142,16 @@ loop: SWAPINIT(a, es);
pc = pd = (char *)a + (n - 1) * es;
for (;;) {
- while (pb <= pc && (r = CMP(thunk, pb, a)) <= 0) {
- if (r == 0) {
+ while (pb <= pc && (cmp_result = CMP(thunk, pb, a)) <= 0) {
+ if (cmp_result == 0) {
swap_cnt = 1;
swap(pa, pb);
pa += es;
}
pb += es;
}
- while (pb <= pc && (r = CMP(thunk, pc, a)) >= 0) {
- if (r == 0) {
+ while (pb <= pc && (cmp_result = CMP(thunk, pc, a)) >= 0) {
+ if (cmp_result == 0) {
swap_cnt = 1;
swap(pc, pd);
pd -= es;