Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4126477pxb; Mon, 1 Feb 2021 13:11:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCtzWakRqO6ILjRE+xKPrHR4YIfad/w6mlhYesT90VX7xJr2yXyuxXgkZqM+LZZ9+uIDSp X-Received: by 2002:a17:906:7cd8:: with SMTP id h24mr19214447ejp.511.1612213902875; Mon, 01 Feb 2021 13:11:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612213902; cv=none; d=google.com; s=arc-20160816; b=p5NXXukLjc/UQa1AEQ/q2zH/hs1o5E1gAtXpG/rRXHwD0Efz5PUVRSh6/H1O7KIfKG yQ/4AkkNSVnPYxciGmjbv0Cq7aUyZvlk+In9jkEAivuzRwj4unPfmmd+xxOiFmjLgXCB 34G4u/aRG8Rqp53LYKu7H7wIcQRFFXd0w7niV4+P8+KN/VHHe9SGJFtE8TW2kwwUbF0p umDJ5nYSVIXYLTIwHVqLmHRkpbpnq85IlHziFsvJlsDGJKV2WwlJa2ZprkEtrcvF6Pnh lipFbr1+t7hsX1b+HF03vsieZmlgyFFo8+rm2lkLBlP9CisNiHMsD0dAUIL+Dnzzqz5u QhxQ== 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=wvdjku1jU3apltEWVwsSxTU3erYxBwg3twWjnZTS+mk=; b=qJElw6ubPTNsbOLjAeT/lLkjusT2+t9vDgRfsqRvBfR17GyVRElBAe1Gj3ycJZb+MN +f2HBykEEYrQuzRpX3TJvKVJNZyzS0S3+IMvLqJv3qtZDWrhBxBlZekPUac1/B/T4xbl Oh0jqI++61fKTbQIOsN3L3/d2LC+13T5neWOJ9cPSon0bZp+1TFbYmzE2cleSfR/cYIz Bh3QCTON/XFVkPiNh/HmuugERw1N85nhPctoBCu+RJjJX16s6I44EXQIx4wQEWrn/Z4l 7Bo7LW77gb/gIvuMVHYmjbiLjIW6mX7WWMxRTsApuswE0c+PgM1i0sB72zzLqOGNzVE3 kkEA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g25si3138168edr.526.2021.02.01.13.11.13; Mon, 01 Feb 2021 13:11:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbhBAVKo (ORCPT + 99 others); Mon, 1 Feb 2021 16:10:44 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:53180 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229831AbhBAVKo (ORCPT ); Mon, 1 Feb 2021 16:10:44 -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 111L9m86014210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 1 Feb 2021 16:09:49 -0500 Received: by cwcc.thunk.org (Postfix, from userid 15806) id B1BCD15C39E2; Mon, 1 Feb 2021 16:09:48 -0500 (EST) Date: Mon, 1 Feb 2021 16:09:48 -0500 From: "Theodore Ts'o" To: Vinicius Tinti Cc: Christoph Hellwig , Andreas Dilger , Nathan Chancellor , 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: 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-ext4@vger.kernel.org On Mon, Feb 01, 2021 at 03:41:50PM -0300, Vinicius Tinti wrote: > > My goal is to avoid having a dead code. Three options come to mind. > > The first would be to add another #ifdef SOMETHING (suggest a name). > But this doesn't remove the code and someone could enable it by accident. I *really* don't see the point of having the compiler whine about "dead code", so I'm not terribly fond of -Wunreachable-code-aggressive. There may be times where depending on how things are compiled, we *want* the compiler to remove code block, and it makes the code less ugly than having #ifdef ... #endif breaking up the code. If turning that on requires uglifying many places in the kernel code, maybe the right answer is... don't. That being said, I have no problem of replacing if (0) { ... } with #ifdef DX_DEBUG ... #endif In this particular place. But before we go there, I want to register my extreme skepticsm about -Wunreachable-code-aggressive. How much other places where it is ***obvious*** that the maintainer really knew what they are doing, and it's just the compiler whining about a false positive? > > However, if there *is* a bug, having an early detection that the > > representation invariant of the data structure has been violated can > > be useful in root causing a bug. This would probably be clearer if > > the code was pulled out into a separate function with comments > > explaining that this is a rep invariant check. > > Good idea. I will do that too. If you want to do that, and do something like #ifdef DX_DEBUG static inline htree_rep_invariant_Check(...) { ... } #else static inline htree_rep_invariant_check(...) { } #endif I'm not going to complain. That's actually a better way to go, since there may be other places in the code where a developer might want to introduce a rep invariant check. So that's actually improving the code, as opposed to making a pointless change just to suppress a compiler warning. Of course, then someone will try enabling a -W flag which causes the compiler to whine about empty function bodies.... - Ted