Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3452913pxb; Sun, 31 Jan 2021 16:51:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7QEtrvviOI3K7Dys9xknxbTjUWzk3t2noIrzr+D04sEFET5vo9LQobYb3TwQAtqpxx9Lx X-Received: by 2002:a17:906:8053:: with SMTP id x19mr5339730ejw.470.1612140664169; Sun, 31 Jan 2021 16:51:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612140664; cv=none; d=google.com; s=arc-20160816; b=eCoVKLAawCNgfz4S8PaxAsBatH+XKhjIiDL3CqlnU/peC/CsrQXukbmJRgGbvstPSt W0b5msbMCykVijSoIcKeJwB2b4HROREdHlC+lz8Dm9KX2pFuSDfhDa7Qfxxtluli7AG1 iOJABxov1oEWvNNzzatHshyHr4mPp8Vg5mkcav4RSVa1xHw5yXM/AVKJtMMCBbzE5Dxt esxq06/07l086y92nQ/An/T7KtgeutjPtgkFeCm3eQPq5iig3mSGIqRV7KsANq1aZLHF o35WfmFwQPcL912d6GIwqm4J8RU5I7Em5+Q41yOxJ/QtxtRMBfhBnLJrpQpGL4hHM7OS CIpQ== 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:dkim-signature; bh=8CuwOBHzoIyEuAhrPlShTM4+7MdlcWc2sDIopY3Tp2E=; b=IJYy+YEkOthn+qJsMUBwX0QPEN4uyI9yGDwtZSJv+Weu5NpJ49bTe/Hrhp3uDzHrof C79nYEfjBwcPG50tLwdnx+isbbUKY87/KQezGGEYKj7TIKu3dceHoYnpoU0KWhiPSMOZ 0GBGCrSlBpAczxwTwbjDQs2riJDCY5Gr0wl3PNlp1qNJyh3WpoYuFSFxI+BHz4kZhpF8 lRcVlaHPO9E0q27HwVIY0laHwhKuqOSUBeEG+Eujqpl5Ol0e4CEwYhE4PVTbQ6A0hieq IHg/7bQxxzKE6lvB9HkdtXRkA71o9aXHWeWgmKG4cDmHvHgXAgg4CUacn7sR/K7lqWKi Abww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KNQVvgNE; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q26si9809433eja.258.2021.01.31.16.50.31; Sun, 31 Jan 2021 16:51:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KNQVvgNE; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbhBAAtI (ORCPT + 99 others); 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-ext4@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