From owner-dev-commits-src-main@freebsd.org Wed Jan 20 10:37:45 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A39534F148E; Wed, 20 Jan 2021 10:37:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DLMRY2zqXz4X79; Wed, 20 Jan 2021 10:37:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4F3EB17CBF; Wed, 20 Jan 2021 10:37:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10KAbjl1093452; Wed, 20 Jan 2021 10:37:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10KAbjT8093451; Wed, 20 Jan 2021 10:37:45 GMT (envelope-from git) Date: Wed, 20 Jan 2021 10:37:45 GMT Message-Id: <202101201037.10KAbjT8093451@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alex Richardson Subject: git: cef194271162 - main - libc: Fix null pointer arithmetic warning in mergesort MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cef1942711624c6cf1d237118531cfad9ade05ac Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jan 2021 10:37:46 -0000 The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=cef1942711624c6cf1d237118531cfad9ade05ac commit cef1942711624c6cf1d237118531cfad9ade05ac Author: Alex Richardson AuthorDate: 2021-01-20 09:56:01 +0000 Commit: Alex Richardson 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 +#include #include #include @@ -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);