🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3382

Re: [PATCH] CodingGuidelines: !! is not all that exotic

#3382
From: Phillip Wood
Date: Thu, 19 Nov 2026 10:44
39 lines
12419 bytes
Hi Junio

On 18/11/2026 18:31, Junio C Hamano wrote:
> Remove the clause against "clever tricks" that cites !!value that is
> a standard technique to normalize a value to 0/1 boolean.  We could
> resurrect it if we can come up with a truly exotic example that we
> would want to avoid, but this is not a good enough justification for
> this rule.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>   * I think we saw a good example that !! was used in a recent review
>     thread, and the idea to remove this rule was floated back then,
>     but without following through.

Yes, its come up a couple of times recently, thanks for putting a patch 
together.

Phillip

>   Documentation/CodingGuidelines | 4 ----
>   1 file changed, 4 deletions(-)
> 
> diff --git c/Documentation/CodingGuidelines w/Documentation/CodingGuidelines
> index 3c8d6c7dd3..4bfa615bac 100644
> --- c/Documentation/CodingGuidelines
> +++ w/Documentation/CodingGuidelines
> @@ -522,10 +522,6 @@ For C programs:
>   	    that_is_used_in + a_very_long_expression) {
>   		...
>   
> - - Some clever tricks, like using the !! operator with arithmetic
> -   constructs, can be extremely confusing to others.  Avoid them,
> -   unless there is a compelling reason to use them.
> -
>    - Use the API.  No, really.  We have a strbuf (variable length
>      string), several arrays with the ALLOC_GROW() macro, a
>      string_list for sorted string lists, a hash map (mapping struct
Technical Details
Message-ID: <ebcf98af-a633-4e51-97f0-099084beeef5@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75804-linux-kernel-git=dewy.ru
References: <xmqq33sy6lgb.fsf@gitster.g>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75804-linux-kernel-git=dewy.ru
From: phillip.wood123@gmail.com (Phillip Wood)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] CodingGuidelines: !! is not all that exotic
Date: Thu, 19 Nov 2026 10:44:12 +0000
Organization: Usenet Network
Message-ID: <ebcf98af-a633-4e51-97f0-099084beeef5@gmail.com>
References: <xmqq33sy6lgb.fsf@gitster.g>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2851608"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:83FOmyIJpgyq8WxDDstNms0ujA4= sha256:3mddS/ppNjYEWmB+WFUr6krYtIJyBUbRsoc7yi9tX5c=
	sha1:u7/vrh+VaOJ6gwBEl5fhFPNoXvw= sha256:qIBHZ7gpuf1iDi2/T0J2Jf51o/hZ76mFqVFAEuj20+s=
Content-Language: en-US
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 619181155C5; Thu, 19 Nov 2026 13:44:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id RCP8busZZ0rm;
	Thu, 19 Nov 2026 13:44:27 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=git+bounces-75804-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id B01F21155B5; Thu, 19 Nov 2026 13:44:19 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id CCEB1689402; Thu, 19 Nov 2026 10:44:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795085058;
	b=LYiEcJ7qEmMtEp3jBNeygVhb1nNQAxJ6NkZ0VkowEZvM3ZcASnhpRxaRH41Ih0kDqZ3Q
	 tc9OAUOcTRp+6B7qmmeaEbVvr3lb2QxYORIoFjEHLbcxrfsmUuNhPthf3VB5sKQjSosew
	 qeJXAvOBnubkTqvnTtTYWZbEE6McIVpTlIej3xs+sjQdONUoSUTd4VsvcW7RbPbGbvJSO
	 DZRr080qNRxl1IweFVJkw6OePWVQbmlvmZ1xpxuk9G3lMDzxoEmu1V4R9MOW5AQlhKjec
	 VesNZo9vgpAbOfobY0VZp5Hlviqrua4aRugyvCN78glLvP7ZZgFnFtx3Yd4VCq4FBZA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795085058;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:Message-ID:Date:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:User-Agent:Reply-To:Subject:To:References:
	 Content-Language:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=HL4vYVHCSKGHhDc7A7KE2aWNWSjFIYqCjZmmX7dPs4E=;
	b=AvB+Tkl8goKzhCrB1ga65fymPK5vhMcjvLlKHAmwQsFjT2Fe/4mbMKLGpT0ocTZLAjYB
	 hwN5D0Lx0JEAfz6rYAcB5Y7WdXVYD63EtA0V3Xppzyar+7Us/ICagh+K1fvvATiH62x7Y
	 69iIq6bGPzpQC9nHFJwA7HEk1U1fgY35/stJmBck4GEjwnOtgAzdJfAtYHAcC8L8lCvs8
	 Ny25hqcs7S1k08y++tR6xF+0whpa3d36Of/tcGiAxtEp/J2aH4F3luD7QDCa/ZDIfqSRj
	 qR4nNAKJJMM8mwMoOrdKhlO5wotl+srLc1qouJj4Pl3EmPa7NBLPY+A/dIGzWHbvX4A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xRj9vHn3;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 14E3B606A32F;
	Thu, 19 Nov 2026 10:44:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xRj9vHn3
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795085057;
	b=MRKJa9FMDa/8Pvk6c27L9FL5c7os5MFdBGNzsq7y/7SrsJnWHtnX9a6p/L3yY21JGSRS
	 dUtDmWc4sIvAkV7ZQPGkkL0g0UMxPmaULuqbE5FP3zzN4DWUWaNifUMRZuG67NmMg0/D7
	 azOVbC7zgfVSvHxRDDWIgYnWTT+LxoGRIpO5zwT5tJCvJRJdM1Fe+Scut9vT4nvEeGjuY
	 sxmKzAunqvis0hCspqPzAm0/mT8nKUUC0Yq48msN5esZyodJCTxr72HCAFF4zUAAkminH
	 cV8aJKPE/FbdAXhZpctkox3fOiBAHS1+vpCHf2A2bD5tVdmMbgCek63pBKVSSdHJkZw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795085057;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 Message-ID:Date:MIME-Version:User-Agent:Reply-To:Subject:To:
	 References:Content-Language:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=HL4vYVHCSKGHhDc7A7KE2aWNWSjFIYqCjZmmX7dPs4E=;
	b=AOhV9kBd/xNBWFh9P20875GqRsVYzaYahxKYqcMIQUrwJTvoaD3ZXkbcLsdml7paP5ia
	 /CZ3pCSmaohE8WJR0jwb34Mw+SQzUvzNf3B2ZQhK3PtF3oJ5nTenQFcRZaqbb0RZzJgE1
	 k0o6VYyuWrCCW7juUEQ4ZlDQ3IQ9WxeiXHmFUmTetzcOHrbLxH84p41wItJXhfsMsFHEM
	 EjiPUjmiYvzLUR4XHLQVWl5bslY8Ov82WO3tIFODJH6rydI5ytWCDpQy0fYZ2Vhxdbqz1
	 Zo/ixx9TIaJqS3yau0UtCAKlGjLMuzr9+S0RNChIIuKF8sK1LO9pECXzx7rs0FyICEg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xRj9vHn3;
	arc=none smtp.remote-ip=209.85.128.51
X-Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1079606A324
	for <git@vger.kernel.org>; Thu, 19 Nov 2026 10:44:16 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D1079606A324
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4bb69f5b161so13109105e9.0
        for <git@vger.kernel.org>; Thu, 19 Nov 2026 02:44:16 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1795085055; x=1795689855; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:to:subject:reply-to:user-agent
         :mime-version:date:message-id:from:to:cc:subject:date:message-id
         :reply-to:content-type;
        bh=HL4vYVHCSKGHhDc7A7KE2aWNWSjFIYqCjZmmX7dPs4E=;
        b=xRj9vHn3edMlo58o3PwE4qF5FjsmxWY+7oiuN92CeODH+8zaKcnkcEqivvpqBn0UmM
         kVdjVVs8BZdmZwV6Is6CFMm4H/WT7rZ7pDFXG/vO4n/HslFtn/lWIKyfs46tfOU48POU
         6RhhS5Nc6qMG5GTHD9fFscIs2lhO7FZtnrQSzbQCJvjSOD2P8zNI8jE5gzV5cH4ZDA2H
         6aLyzlWs6T/ehvGb1l3JVKhng9hVAo9GxT6EkwPOBZMpeaoGCwjoZnrsx0owrQCUdkgk
         pq6bZm0dhfrRpyI1v61UvQJwHlYy/sb84OrvqFrn6L+46oywMi/UqKp0Lv5n2l5ZeEHE
         IbRg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795085055; x=1795689855;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:to:subject:reply-to:user-agent
         :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to:content-type;
        bh=HL4vYVHCSKGHhDc7A7KE2aWNWSjFIYqCjZmmX7dPs4E=;
        b=mTg4dq6H/IoWdVfA36yNb49+DabYUMv2RKSlRajFVLqMVUiPB9cnxUr3MNIPeTYhDI
         IVNNL/sokRpDbSNgiOjHkgsp3AL8tkTTQVaqQTDUqvsyjmqiwDzDTtpqHXHMMHIPEH09
         oDx9zeHlF5qi7cIvlwwazg+TNPSdzrwnJmrpsFn534ZfSZaRNXzwibqIzo2942UCOz0l
         0MkbKksJZSILvvHb15hvs475YvRV03QvQJxfHj4g18gKuNf9DPlea1AAByDLyRpAxUU4
         +d8uI5DsEud5k5yF5STgIITpp6dQAO9DkbhwwOd/WPsPMg3EEQH8KfPuJZnMeu0P0ctp
         HPGw==
X-Forwarded-Encrypted: i=1; AL+hErFPbjKyPGPAI7JId82B6f3Hg58bRRhrCxRbDwSE1l7Lko8f9RzIQRixaAvjwjUQOEXNZk8=@vger.kernel.org
X-Gm-Message-State: APuU4Z+YIPrAod05AZKuJ5X+2xqdH1r0cmWhVB84ENzq/Vf9hWhaBbh9
	legUHrZ06LcxdfG7X7zHQqGYKcvf0EQ3njK+6LQ0mvnmHLhySFTxw+RW
X-Gm-Gg: AYBFou1HecY3oWHXN3WKHRT5iZMh3wwIiotqbcHohKrHaQR1QQOiKhM1TFgbx1mOZdp
	VDTLu1Yq2ZIX7jHESk7IrvPW1qCqV02q9VfgSYZOazb4jYaUaggrgkmRynsfsYDAtMgiQRnU+DI
	9/Jnw2witfNaEvzhkkpDsPJ0RjwJLwgPpjKy55fN8bt6vnR1tOmg/2htMEsFnhmnCYfmaU109WE
	qiPzFIWn3esLYoom9SwHQHJjet0phrRpaW02LHdFp5NRwpk6qO7oICh6UdjwJhieXkzty6W150v
	kXx3PlyvfdIJIGNIoMAS+RIcTCn2M75BkVYoAAoAhrEa5uoWDTF/Aing19XYRbqDZ0LxKWKRdw/
	Gk1DhKsO0ORu2ourcfAYw5OWFuC++hch0e81AMeYG/HFU97qFLAiXbn+bpyHVGhh/C8edMWENjc
	PeFmfmx/sY72tzAsqcH47EoVitY0lSn5hl558rU3uktxvKE6Gb//Q2EOe1t8uW//XhqJTmT6qpA
	W843o54E7J9ahTUWsb/QJoHfwndML+q4NUD9pQpnOdA0Ihx42SeJsOvqIgZTOQJtl9xtfT/itmG
	t4WOFtFVXymXT+2pDwko78nG6HAJKyQ0Qhbr1VgjtzlifXQikEpGv92OOW87GwbzZ+TkO1EEjtq
	nx/gosxBxnODvYgcr5wSyaOx4Nlzm
X-Received: by 2002:a05:600c:470a:b0:4bb:6fd3:5ac0 with SMTP id 5b1f17b1804b1-4bb7da2b98fmr108924215e9.28.1795085055143;
        Thu, 19 Nov 2026 02:44:15 -0800 (PST)
X-Received: from ?IPV6:2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f? ([2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f])
        by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853a9846sm32491475e9.11.2026.11.19.02.44.14
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Thu, 19 Nov 2026 02:44:14 -0800 (PST)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-Reply-To: phillip.wood@dunelm.org.uk
X-In-Reply-To: <xmqq33sy6lgb.fsf@gitster.g>