aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwelinder@anemone.rentec.com <welinder@anemone.rentec.com>2004-09-26 15:07:09 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:03:23 -0700
commit1c849c0c3a50b115a58975431cd3dd876265bed6 (patch)
tree1ccafd0d2ef957fa6ba595e170bd4af9d57b25e1 /expand.c
parentThis file uses NULL, so include stdlib.h (diff)
downloadsparse-1c849c0c3a50b115a58975431cd3dd876265bed6.tar.gz
sparse-1c849c0c3a50b115a58975431cd3dd876265bed6.tar.bz2
sparse-1c849c0c3a50b115a58975431cd3dd876265bed6.zip
Make sure sort does not degenerate.
Diffstat (limited to 'expand.c')
-rw-r--r--expand.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/expand.c b/expand.c
index a9215dd..99efb94 100644
--- a/expand.c
+++ b/expand.c
@@ -758,23 +758,23 @@ static int compare_expressions(const void *_a, const void *_b)
{
const struct expression *a = _a;
const struct expression *b = _b;
+ int r;
+
+ r = (b->type != EXPR_POS) - (a->type != EXPR_POS);
+ if (r) return r;
- if (a->type != EXPR_POS)
- return 1;
- if (b->type != EXPR_POS)
- return -1;
if (a->init_offset < b->init_offset)
- return 1;
- if (a->init_offset > b->init_offset)
return -1;
+ if (a->init_offset > b->init_offset)
+ return +1;
/* Check bitfield offset.. */
a = a->init_expr;
b = b->init_expr;
if (a && b) {
if (a->ctype && b->ctype) {
if (a->ctype->bit_offset < b->ctype->bit_offset)
- return 1;
- return -1;
+ return -1;
+ return +1;
}
}
return 0;