From nobody Fri Feb 24 20:50:01 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PNmHk6lNdz3v4WB; Fri, 24 Feb 2023 23:26:42 +0000 (UTC) (envelope-from steffen@sdaoden.eu) Received: from sdaoden.eu (sdaoden.eu [217.144.132.164]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4PNmHk495wz4J6G; Fri, 24 Feb 2023 23:26:42 +0000 (UTC) (envelope-from steffen@sdaoden.eu) Authentication-Results: mx1.freebsd.org; none Date: Fri, 24 Feb 2023 21:50:01 +0100 Author: Steffen Nurpmeso From: Steffen Nurpmeso To: Ed Maste Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 2c709ee70ade - main - libc: handle zero alignment in memalign() Message-ID: <20230224205001.Fbn1A%steffen@sdaoden.eu> In-Reply-To: <202302241821.31OIL4ux075893@gitrepo.freebsd.org> References: <202302241821.31OIL4ux075893@gitrepo.freebsd.org> Mail-Followup-To: Ed Maste , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org User-Agent: s-nail v14.9.24-418-gbf8954aec4 OpenPGP: id=EE19E1C1F2F7054F8D3954D8308964B51883A0DD; url=https://ftp.sdaoden.eu/steffen.asc; preference=signencrypt BlahBlahBlah: Any stupid boy can crush a beetle. But all the professors in the world can make no bugs. X-Rspamd-Queue-Id: 4PNmHk495wz4J6G X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15987, ipnet:217.144.128.0/20, country:DE] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org Ed Maste wrote in <202302241821.31OIL4ux075893@gitrepo.freebsd.org>: |URL: https://cgit.FreeBSD.org/src/commit/?id=2c709ee70ade9fd8f77b37917a4\ |169d667dda41d ... |commit 2c709ee70ade9fd8f77b37917a4169d667dda41d |Author: Paul Floyd |AuthorDate: 2023-02-24 16:29:01 +0000 |Commit: Ed Maste |CommitDate: 2023-02-24 18:19:06 +0000 | | libc: handle zero alignment in memalign() | | For compatibility with glibc. The previous code would trigger a \ | division | by zero in roundup() and terminate. Instead, just pass through to | malloc() for align == 0. ... |- return (aligned_alloc(align, roundup(size, align))); |+ /* |+ * glibc allows align == 0, but that is not valid for roundup. |+ * Just pass through to malloc in that case. |+ */ |+ if (align != 0) |+ return (aligned_alloc(align, roundup(size, align))); |+ else |+ return (malloc(size)); Just out of interest. Why not 1? Or "if(align==0)align=1;"? (Which is what i always did, as "allocating nothing" is merely a debug concern, which, for better memory pools like OpenBSD (i would presume), or during ASAN, causes better (even upon read).) (The machine language would also be smaller, would it.) Thank you. --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)