libc: Fix null pointer arithmetic warning in mergesort

This file has other questionable code and "optimizations" (such as copying
one int at a time) that are probably no longer useful, so it might make
sense to replace it with a different implementation at some point.

Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D28134
This commit is contained in:
Alex Richardson 2021-01-20 09:56:01 +00:00
parent 7e99c034f7
commit cef1942711

View File

@ -52,7 +52,7 @@ __FBSDID("$FreeBSD$");
* (The default is pairwise merging.) * (The default is pairwise merging.)
*/ */
#include <sys/types.h> #include <sys/param.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
@ -97,9 +97,7 @@ static void insertionsort(u_char *, size_t, size_t, cmp_t);
* boundaries. * boundaries.
*/ */
/* Assumption: PSIZE is a power of 2. */ /* Assumption: PSIZE is a power of 2. */
#define EVAL(p) (u_char **) \ #define EVAL(p) (u_char **)roundup2((uintptr_t)p, PSIZE)
((u_char *)0 + \
(((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1)))
#ifdef I_AM_MERGESORT_B #ifdef I_AM_MERGESORT_B
int mergesort_b(void *, size_t, size_t, cmp_t); int mergesort_b(void *, size_t, size_t, cmp_t);