qsort(): ptrdiff_t may be larger than int
This is a companion patch to e23eff8be92a2a2cb66b53deef020063cff285ed commit. The same logic, the same rationale that a comparison function that returns an int should not just compute a ptrdiff_t and return it. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Dec 8, 2005 at 17:29 UTC
2dee581667d62d113605e97de0beda6a9dbca153
1 file changed
+6
-1
server-info.c
+6
-1
@@ -140,7 +140,12 @@ static int compare_info(const void *a_, const void *b_)
140
return 1;
141
142
/* then it does not matter but at least keep the comparison stable */
143
- return (*a)->p - (*b)->p;
143
+ if ((*a)->p == (*b)->p)
144
+ return 0;
145
+ else if ((*a)->p < (*b)->p)
146
+ return -1;
147
+ else
148
+ return 1;
149
}
150
151
static void init_pack_info(const char *infofile, int force)