Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4178098pxb; Mon, 1 Feb 2021 14:51:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxsAG2Be2E+GZUbteA+uW9N1pU6jn+9hY9o7I3nsWc1toq8bMpopvJaY3tnyzvgkLMZiCGo X-Received: by 2002:aa7:c3c4:: with SMTP id l4mr20765111edr.255.1612219887123; Mon, 01 Feb 2021 14:51:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612219887; cv=none; d=google.com; s=arc-20160816; b=TQuK9zcLQN4AtGAw9PHAvNVIIKf9R5z1juuvoFH8T2sh8sRAG8lmAjd9vbvU8Q8YXg OJ61GFVEy2p8h/mtoQmuXCwqhNYMTce48yXgF1kCi9qzyyym2NnJTUnbKPbDFNbBPJ9+ sBDbTBmYPh38OHe9GK3YfTAY7SN4+Fr1k/F3xVE/418wPofE2oCQmqoNRczjmTvDyQ15 HEHzsTSVfxocXsZoV+3mXvcSmUGsIZKHimHiGtkNVnhfN8vkEQUbf6sxTOeMeb2yl+gc DWw7c2qIMBUOk5ieCdfWPC5+x01dwX5R9ekycsQ8GT+wdtK8+UkrFwV94sWp9BZsV+KZ vLkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=In96SOn+e2n4Oq3c81+ayFQgIekKDyUDXIMt4HMVvTI=; b=pF1TjysqXwnzg/ViHIWbZOU8rOTjLCA5KGfmkdafi+zZUToZCJEWIbbPrjHGMsy9Hm ybOERKBUuD2gTVNGKH1aWYN+yXoEUwYlxXj8oHLapOonYH+WhZPtPcOrbXl0TwvC83mt hpmfTVFk7L+rEsOTtgJsP38SFhxDQx7PHxVLJMDIXkTSKr9d3W6gIfj6rYMd56bU0zpm vVHZJGOYCIW3WZz1GDviNz7CvTUPCqieq6MOeO4bZrcVFhhH1v2in6qjBkbTmt9OSOAi NZoniOXxh4EyTaS3fOWFmE+SPnWD/HCTEhRjXQnc1KNH77H6ThU5PvgP7V8aDDEtC/pU 7jZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si12537649ejo.123.2021.02.01.14.51.02; Mon, 01 Feb 2021 14:51:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230033AbhBAWtw (ORCPT + 99 others); Mon, 1 Feb 2021 17:49:52 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:43439 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229753AbhBAWtv (ORCPT ); Mon, 1 Feb 2021 17:49:51 -0500 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 111MmsZW027971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 1 Feb 2021 17:48:54 -0500 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 4C73615C39E2; Mon, 1 Feb 2021 17:48:54 -0500 (EST) Date: Mon, 1 Feb 2021 17:48:54 -0500 From: "Theodore Ts'o" To: Vinicius Tinti Cc: Nick Desaulniers , Christoph Hellwig , Andreas Dilger , Nathan Chancellor , Ext4 Developers List , LKML , clang-built-linux Subject: Re: [PATCH v2] ext4: Enable code path when DX_DEBUG is set Message-ID: References: <20210201003125.90257-1-viniciustinti@gmail.com> <20210201124924.GA3284018@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 01, 2021 at 07:05:11PM -0300, Vinicius Tinti wrote: > > The goal is to try to detect real bugs. In this instance specifically I > suggested to remove the "if (0) {...}" because it sounded like an > unused code. > > If it is useful it is fine to keep. The trick was that it was unused code, but it was pretty obviously deliberate, which should have implied that at some point, it was considered useful. :-) It was the fact that you were so determined to find a way to suppress the warning, suggesting multiple tactics, which made me wonder.... why were you going through so much effort to silence the warning if the goal was *not* to turn it on unconditionally everywhere? I suspect the much more useful thing to consider is how can we suggest hueristics to the Clang folks to make the warning more helpful. For example, Coverity will warn about the following: void test_func(unsigned int arg) { if (arg < 0) { printf("Hello, world\n") } } This is an example of dead code that is pretty clearly unintended --- and it's something that "clang -Wall" or "gcc -Wall" doesn't pick up on, but Coverity does. So in cases where the code is explicitly doing "if (0)" or "if (IS_ENABLED(xxx))" where IS_ENABLED resolves down to zero due to preprocessor magic, arguably, that's not a useful compiler warning because it almost *certainly* is intentional. But in the case of an unsigned int being compared to see if it is less than, or greater than or equal to 0, that's almost certainly a bug --- and yes, Coverity has found a real bug (tm) in my code due to that kind of static code analysis. So it would actually be quite nice if there was a compiler warning (either gcc or clang, I don't really care which) which would reliably call that out without having the maintainer submit the code to Coverity for analysis. Cheers, - Ted P.S. If anyone wants to file a feature request bug with the Clang developers, feel free. :-)