From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D486B4BEE3C for ; Fri, 11 Sep 2026 22:09:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789164591; cv=none; b=D2vGZz1KD+znHrGEnOwHiEIaviP+QY8XRkwUhhsCv+olPETj4Jvsnmiy3RE0FfnkLbIH38bHg3LNxHi1vsLtbDWYh1X9UwI6j/t25g1/BpJgieAFGAR3jSKi/P73WMvLq/y3d3uBrwp2L+2jFNpqE8NJRknOeMDEqqj9JesFzGQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789164591; c=relaxed/simple; bh=kjQtnHxteuaIiLZ1zHqsTNpUgA15a6wGTrzjMzWdYYc=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=lEPy6SP6raaptCIdJiAYEl63W68kAzrxC2QFf9MvXpTysg7CGypp7nJ+YPtfGfxJKvXYGkWt/T5Mny9wMSxqflECLZE2rTlkjS3CZb+xOWX4i3q7ZvtzdfZ4uCgRk4KiyG1RF/1Aid215NM95mr+Ecljdc6VITFyLGZqfMpYndg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=l7CxAlq+; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ci1LPWWA; arc=none smtp.client-ip=202.12.124.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="l7CxAlq+"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ci1LPWWA" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.stl.internal (Postfix) with ESMTP id 27EDE1D000C8; Fri, 11 Sep 2026 18:09:49 -0400 (EDT) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-09.internal (MEProxy); Fri, 11 Sep 2026 18:09:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3; t=1789164589; x=1789250989; bh=FHt/0fDQKh7ayoS5Pn3pdEOcOKQkfuri 7HtHVZZOoHM=; b=l7CxAlq+LvQO3lHp9e8EQPafXM7g1sANUB4DmbGAkIGXiaw2 +sXjz5BugvUtzJHHHWaH28l+D24yZgDtCUvvEXEEBuQA023PRhR42Cf+lmNvA2Ss ngbpAb4WvAEBnrLuGlWO63Gd9sDjqi8AzMsBmefSO+41YvKozujhq6gYwcjmvhCD ziKtXvouuWk7QGbBLkkYWykDObCfPFjKylixavrfgo/OsTUkD7IfCN9bAXm0GGDo P3kgL9ak0i1SPRREgLe2dDbS/jgccInhha0jdeo0hZtoPGR6FTJwiWVoyLs8+6P6 NUOGmt/Yz2UT3GDEe7ImfNKN4dX+bQfgPgHBWA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1789164589; x= 1789250989; bh=FHt/0fDQKh7ayoS5Pn3pdEOcOKQkfuri7HtHVZZOoHM=; b=c i1LPWWAl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ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 11 Sep 2026 18:09:48 -0400 (EDT) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH] cocci: remove risky "if (!E) free(E)" conversion User-Agent: Gnus/5.13 (Gnus v5.13) Date: Fri, 11 Sep 2026 15:09:47 -0700 Message-ID: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain The current cocci patches try to convert if (!E) free(E); into an unconditional call to free(E), with the rationale cocci: detect useless free(3) calls Add a semantic patch for removing checks that cause free(3) to only be called with a NULL pointer, as that must be a programming mistake. which came from ec6cd14c7a (cocci: detect useless free(3) calls, 2017-02-11). Leaving _something_ in ALL.patch output to draw programmers' attention is a good thing, but this changes a piece of code that is originally a no-op to do something else, which may be even worse. We could change it to if (!E) BUG("free(E) is certainly not what we meant to write"); to force programmers to think. But it probably is safer to just rewrite one form of no-op into a simpler form of no-op. Signed-off-by: Junio C Hamano --- tools/coccinelle/free.cocci | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tools/coccinelle/free.cocci b/tools/coccinelle/free.cocci index 03799e1908..3dfaae9dd8 100644 --- a/tools/coccinelle/free.cocci +++ b/tools/coccinelle/free.cocci @@ -8,16 +8,6 @@ expression E; commit_list_free(E); ) -@@ -expression E; -@@ -- if (!E) -( - free(E); -| - commit_list_free(E); -) - @@ expression E; @@ -- 2.56.0-rc0-143-g1fea62d0ca