Date: Wed, 20 Jan 2021 10:37:45 GMT From: Alex Richardson <arichardson@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: cef194271162 - main - libc: Fix null pointer arithmetic warning in mergesort Message-ID: <202101201037.10KAbjT8093451@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=cef1942711624c6cf1d237118531cfad9ade05ac commit cef1942711624c6cf1d237118531cfad9ade05ac Author: Alex Richardson <arichardson@FreeBSD.org> AuthorDate: 2021-01-20 09:56:01 +0000 Commit: Alex Richardson <arichardson@FreeBSD.org> CommitDate: 2021-01-20 09:56:01 +0000 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 --- lib/libc/stdlib/merge.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c index 3a47e424e4da..853d6ae93fcb 100644 --- a/lib/libc/stdlib/merge.c +++ b/lib/libc/stdlib/merge.c @@ -52,7 +52,7 @@ __FBSDID("$FreeBSD$"); * (The default is pairwise merging.) */ -#include <sys/types.h> +#include <sys/param.h> #include <errno.h> #include <stdlib.h> @@ -97,9 +97,7 @@ static void insertionsort(u_char *, size_t, size_t, cmp_t); * boundaries. */ /* Assumption: PSIZE is a power of 2. */ -#define EVAL(p) (u_char **) \ - ((u_char *)0 + \ - (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1))) +#define EVAL(p) (u_char **)roundup2((uintptr_t)p, PSIZE) #ifdef I_AM_MERGESORT_B int mergesort_b(void *, size_t, size_t, cmp_t);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101201037.10KAbjT8093451>