From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51821C433DB for ; Mon, 1 Feb 2021 00:49:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E2EC64E09 for ; Mon, 1 Feb 2021 00:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbhBAAtI (ORCPT ); Sun, 31 Jan 2021 19:49:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:50390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbhBAAtD (ORCPT ); Sun, 31 Jan 2021 19:49:03 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CF70364E09; Mon, 1 Feb 2021 00:48:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612140503; bh=UiySlPbagcPbnKf+65+enUICXrYYE5z7ajBqABAZRtI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KNQVvgNEo5AHuTHkyqKFg+huyKQuigJnpXOdaRG4xPPQu6vDXVJIPRTj1gra2y9HZ qg/NWHLb1oihyk4/upE97ogHLcgonrB6qh4eOiAW1jeEHx0L7VAUwqUstWsXYFtDB4 uMJu51X+2HU98kpgLtRNr61buysRRWEHwSGQnkd5hVVJ1ZlNkQdPZZRvtt0VF1gjTx 6NSU8Y4wxMKTUwdA4TkI55BsIM+59k6hXpQyfEzaMOYF1S+WjOOU5s2AYteVPrdqD4 p3bLZMpmrXB7KneRhX2FEAJvWIHw+1Gllm79XVsMsrh1OcPQ3j4ZLZ9Ekf0fIPp1o1 V1G2UhZcI7mgg== Date: Sun, 31 Jan 2021 17:48:20 -0700 From: Nathan Chancellor To: Vinicius Tinti Cc: Andreas Dilger , Nathan Chancellor , Theodore Ts'o , Nick Desaulniers , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH v2] ext4: Enable code path when DX_DEBUG is set Message-ID: <20210201004820.GA26230@localhost> References: <20210201003125.90257-1-viniciustinti@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210201003125.90257-1-viniciustinti@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 01, 2021 at 12:31:25AM +0000, Vinicius Tinti wrote: > By enabling -Wunreachable-code-aggressive on Clang the following code > paths are unreachable. > > This has been present since commit ac27a0ec112a ("[PATCH] ext4: initial > copy of files from ext3") and fs/ext3 had it present at the beginning of > git history. It has not been changed since. > > Clang warns: > > fs/ext4/namei.c:831:17: warning: code will never be executed > [-Wunreachable-code] > unsigned n = count - 1; > ^~~~~ > fs/ext4/namei.c:830:7: note: silence by adding parentheses to mark code as > explicitly dead > if (0) { // linear search cross check > ^ > /* DISABLES CODE */ ( ) > > Signed-off-by: Vinicius Tinti > --- > fs/ext4/namei.c | 23 ++++++++++++----------- > 1 file changed, 12 insertions(+), 11 deletions(-) > > diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c > index cf652ba3e74d..46ae6a4e4be5 100644 > --- a/fs/ext4/namei.c > +++ b/fs/ext4/namei.c > @@ -827,20 +827,21 @@ dx_probe(struct ext4_filename *fname, struct inode *dir, > p = m + 1; > } > > - if (0) { // linear search cross check > - unsigned n = count - 1; > - at = entries; > - while (n--) > +#ifdef DX_DEBUG > + // linear search cross check > + unsigned n = count - 1; You are going to introduce an instance of -Wdeclaration-after-statement here. fs/ext4/namei.c:834:12: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement] unsigned n = count - 1; ^ 1 warning generated. The quick hack would be changing the if (0) { to #ifdef DX_DEBUG if (1) { but that seems kind of ugly. Other options would be turning DX_DEBUG into a proper Kconfig symbol so that IS_ENABLED could be used or maybe combine it into CONFIG_EXT4_DEBUG. Cheers, Nathan