From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.154 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796200710; b=wPT2aefwmsMaWD6w4bY5YKLcwBhbZ7PF0ZmkbjWObx3zowmFiaGEZa3p7RmKdOEEIxS1 sQHS2+KVgUNEvTkV8yrG/CdtwrENVbH154uMfQLWGBCKbW6qtJZZoz3WV6PzUBj/KuFhw PuIK/IQ0Qo+ho0OGlwjCLPmvgTkjQrZwfuVFZRST+WBy/Dq5k7WEgtS06EmjQLZu8xsRl D4m1fMoVqhn2cfMtXpKsKGMbLc1qQxvOY0eQ0CuniFOofdEtAjCTs19245T3+ZKNj6iSi U+nbAYzzLYv1ZS6Rq4N/l9WSWGjl6fn2oDG3VkS6zTYylw1Cy3/xRDCSLRY6ywPjAEw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796200710; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=9aCW8/xzFQugjwC31LE74jqs492qyMbfzeUT/L5Cl1s=; b=zWM1qAz0qS9WbqEMuVTp6gcWl8yiCbxG4Tv3FOLJgSakQ7I+jhGWGSo5AV2UKwW5bY67 2up3u1RpkHbm0yylb/E8tjyskN6fniMX1NoIj8rX7R+KcwrjC+fMvx7/WK3fnu4QZ+zfP /EPiq383rEdBjtX7mY5Z2CnAZI2T6Gfm2zPc2PwKi+P/j+RAPjnA+w0sRkXt+WtL/DeVF UDvCX2jNZnyIkULjfSXhCvofMVXBsrDEapb4b8yfmrji+BGmfM8Oh3OvQ5bfabKUt1KDR 6Fpm5fXo9cotWu0Z/jVtB+9KT8039yxvlQMgj8A60Eq0P/lP17pjTKAwNEpOIiDn07Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=MkEP0qKI; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=K1ZEFTdX; arc=none smtp.remote-ip=103.168.172.154 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D79FE606A31A for ; Wed, 2 Dec 2026 08:38:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D79FE606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=MkEP0qKI; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=K1ZEFTdX Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id 0563714001BF for ; Wed, 2 Dec 2026 03:38:29 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Wed, 02 Dec 2026 03:38:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1796200708; x=1796287108; bh=9aCW8/xzFQ ugjwC31LE74jqs492qyMbfzeUT/L5Cl1s=; b=MkEP0qKICIi4iKVf1v4qcLn4km FjbA16dNHAmrvtyrVoJBe/8iV2dWo1qrMlDXK6S/IgDr5R3m7WzvDIeg4PC6hAhT T0kHFdAT5zCdR1YgLw/oDjQGfhBwX+QiXq70HeTbmCZovJKonJJTXHZK7YhTIQmW Nms91/6U5/b6lN9kfYtF8EE/o2zOXtyNdRXgC0d6CiDlXNuYHPAAALQVhhpnCy5Q KM/Oiq285IAaKjcbBekCmT1+9NCb0qpL8xO9Ij9ggqFev2YNMexN2CIrsRtxeUMe yjGif1SM+T11jVCfu0AM8NjI6PfFBI2Kxbb0zOjt1g6OFbRAONFyZIo4uueQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1796200708; x=1796287108; bh=9aCW8/xzFQugjwC31LE74jqs492qyMbfzeU T/L5Cl1s=; b=K1ZEFTdXOA0zCe4RK9/mhJceX7oX2uvnTeBa/dRere+7ihzEzYl wjJYt5sJm3a2wLJ4FCLfMIKxN47T2Anzt2rAGaKuWzLd3YCEQpSZMRZ0sveBtau1 LmE1l2EZNShclgF+BfNEDhVNyCiMhElcdus7pppTpNSK6EmCpbarc5Bs/nE+87K0 i2UUjOifT3/i8mJhy3hPUqYpqzQc7m7FM8xSsbB/img7U7yU/r1RbSiFSmQyLyTx r6RVuUld6rT8F4Vb/IEvtqKjiWXXbNluDLna8CzNT1N6OnBMIQQl6BEtbameFDhg ns5cjcg/pL9nuHxATQyuc0qS6LiKe/3luaw== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pks.im a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796200708; d=pks.im; mf=PHBzQHBrcy5pbT4=; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:g05jXXfXBxp8aoRhdzbWzq3uTkLBMXNko9X1mEMjiT+uKMy DZNOuT6G8b6T9XB4X6uOSrORuuxRewdIEIUxsYaJRX/0Rqk1ZOII9XCU8j06TUYC h619U8o8GRO7NW9TQazZxtTdrd6kTT/PDQ44C2eyMaNWPcAQnTFHQvlQm4qhDOli KL9ZoVdTUCHxh0RuIXeMFWBnILmkbjCQSVgBqDo/dlmgMp/yh1a25+4nFgvBixOQ epHMD8KPC7IHMyL7Q3hxbtEE22gwzIHRcRESmnV+8tbeo1+i57IsN3qUjjwrbMB0 ck+cUy30p75b6jsk68X8Y/0ZPHcUil+Feluiqdg==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:+JzgItek9K27WP7JEZTK/S7OQmyNdNRZjEMHcHoyUUg=:A+ZIGATSlXAQ8ZzT4RHcH4nXDh95u2OIjbnSwf1tvbE=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFKBX1ukCQLKJo3eQStYP1Iunz0BZceg70k2VcoVbrSYSJI7oFh+VOb8IEAvaOjyO xPtiPzI0l6fLnfpqtV1UoD167LhemhXNnQU5hqcrnvO499rZxHOdSM+UGmMZYdqtZYOAAa couuYbz22aj/5+Uh22/qv+5DFmZNgI26rQ6tTBFexcBQh3081SgPRK45HVI3sFemFtRCUH MQCuDsy1SvwxSSkFwzqIAtozXmoQy612y00bAyLuQY/xyf9lWcVf+YGWAB/jCKPp05kRX/ uDj49liDSR5OkEh8ThZgfw20S8RkmwchlhQpcHbGGd/f9sLkrj6oBjoUdUuHi08oe2xkUX eJUBqkjGlNE1SchSe8Ck/ZOJJblGLUKDXONZsXhF2XvkjkU+oc9sWbq7r7+cnIYtBJCEec kmEjDC6zCMqOIgw8qjCpZeOSzcleLGnJ09+klI4Rs5hk7bgJS+6vUG1mP9Eu9KyydavAGN lgDaL2uJs4RymzMfAFCIReap4rVcleYkIcfGHUoOlBWLPS2GaZHIoboMbLzF2Wkjt7R6jX xEfii0j0gAjB99c8HXDqyZunlKbGxO+qsq8yEoc6dreEcqyNCYyPhgc+A+3iGkbCDzlZ31 pFpNo2fU5nuVwyS/KJBuY3aF4/q0DCsjfCOd8WAW3ijDvgg3Zbk2uWh95gTA X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 2 Dec 2026 03:38:28 -0500 (EST) Received: by mail (OpenSMTPD) with ESMTPSA id 08003f78 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 2 Dec 2026 08:38:27 +0000 (UTC) Date: Wed, 2 Dec 2026 09:38:25 +0100 From: Patrick Steinhardt To: Junio C Hamano Cc: Toon Claes , git@vger.kernel.org Subject: Re: [PATCH 4/6] packfile: introduce function to free a packfile Message-ID: References: <20261120-pks-packfile-global-statistics-v1-0-19beb83b145f@pks.im> <20261120-pks-packfile-global-statistics-v1-4-19beb83b145f@pks.im> <87ik1jsmt8.fsf@dev.null.iotcl.com.invalid> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Nov 26, 2026 at 12:41:29PM -0800, Junio C Hamano wrote: > Toon Claes writes: > > >> It seems that we have three kinds of free()-like functions in our > >> system. > >> > >> - Ones that make it the responsibility of the caller not to pass NULL > >> (this one falls into this category). > >> > >> - Ones that allows the caller to pass NULL. > >> > >> - Ones that not just frees, but clears the pointer the caller has to > >> prevent future headaches coming from use-after-free (the caller must > >> pass a pointer to the pointer pointing at the resource being freed). > >> > >> It seems all the callsites never passes NULL to this function, so this > >> is fine as-is, but I wonder if we want to move it to the second category > >> by guarding against NULL, making it behave similar to free(NULL)? > > > > Yeah, I was wondering about that as well, because there are a few > > callsites doing `if (X) _free(X);`. Having the _free() function > > NULL-safe would simplify them. > > > > For what it's worth, the pattern isn't described in CodingGuidelines, so > > technically speaking it's fine. But I wouldn't mind extending the > > guidelines to adopt the second kind. > > Yeah. Helpers that are file-scope static may not matter, but we may > want to standardise public helpers like this one, especially the ones > named TYPEOFTHETHING_free(). Agreed. We nowadays already have coding guidelines around how to name such functions (release vs clear vs free), and we already document expected semantics there. It would make sense to extend that and document that a free function should work alright with a NULL pointer. Patrick