Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp827642img; Fri, 22 Mar 2019 09:22:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLI1/FXleYFsx7U51u1mOzq/lka6hRq1J0s45Fo7x9upw6eIRjf8ShBLcBKp3IW9GjOZuz X-Received: by 2002:a17:902:7044:: with SMTP id h4mr3761565plt.274.1553271736759; Fri, 22 Mar 2019 09:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553271736; cv=none; d=google.com; s=arc-20160816; b=r6BCA6XKJcc276+M5sTALtqDBpAdpU5lcuFA3KZiL23UvCyv9ZVIw2bTwDkzNN4H4m QdzqRnmDWesRDTdYUJi8kUUbhKaHZtaNxLPAZnq8nRL7AqOLZI0pv8HX8/NpHO5bUi7l y8LFODwjpGoZ7e6/rMcmatHVpsTu+kq+5eW4CcWgwXlfuDPL4geXIrB50BL6GgPhYNcN KK4wngghIBOUZNXGb9BtGzjyN9JszfErlwbtS8H7GQjC4ELykRmovR4bh9nz/bO4P6wP euA8VSMDO5GWdJn2GEshfRWs4uHwK1rEPYuOyU39nYbRGAs7kq6PN/E2Oom2CbMFKcM2 SjWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=FinR+IjhZDJgPonC4fG9bQ8oToE745baJij2yjHIuSw=; b=RmeGc2zwns/RxTpwg8xNePs/g5ZZg21ipi+/kSimpolqpzFZFUB4s/wGJsHi6LLoGu cf79Z4C4kzKhXoXzcm9MV03bz0y4k2jiNuWwKAYpb+tKm0r8XXqgQzamp5lx9Dxsyo8E JcHZFKUq6uYttgyUh9cMpGTCCR0fVH5rKRr/zm4G45LVczZG5ua3PaVeQ+RTPpTx/LgQ DiAe3Jdf2k5FA/zYLgcQ8XsrNwj9Er4l7SG/G7+BY0qLGBqJuy+qLVMfMAHMogl3bCpg VgTaVHzlD31nC0M0JVt2D5aVwOYU4MWPNE/rmixm2ozxDehIEU+sg3opyTx/+vMeqWPK YtfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yXeM6mBW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l66si7004158pgl.474.2019.03.22.09.22.01; Fri, 22 Mar 2019 09:22:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yXeM6mBW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727188AbfCVQVW (ORCPT + 99 others); Fri, 22 Mar 2019 12:21:22 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:43568 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726801AbfCVQVW (ORCPT ); Fri, 22 Mar 2019 12:21:22 -0400 Received: by mail-io1-f67.google.com with SMTP id x3so2157365iol.10 for ; Fri, 22 Mar 2019 09:21:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FinR+IjhZDJgPonC4fG9bQ8oToE745baJij2yjHIuSw=; b=yXeM6mBWjCkKz0G3Jx7TkTFp6qEugUDgoTTzWcZqjmmQo1guYtvaNro3m8PQ5yIyV6 j8GRm3pcaDDCTlo+j1rMgWFzm7D36KGzN+8UkRhvRHwnDyVgSCgO+ar33pCFtlWg9FZz N+uL2cVTBLgpFhI43ozMWZX+wA9xS1NzY/7kWC3HaBc2UDCIoPQZKq8uwTcipJ7+yqEh 08mTJ8v5+2uSRzDgF3p2P0rydcmFtRuW5khFfHuhScc1QMKEas+NcBaxzAlhnrryGt/3 eaQjuJR+qHOXDq5jZUc0pNfTukYC9YumD4eAkENBwNJayqZT8ynPYWUF4RcqVroniE+U JkMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FinR+IjhZDJgPonC4fG9bQ8oToE745baJij2yjHIuSw=; b=UKZ4aB//teqRoXe7NYla4LX/dFenn2/hk1L899v5XZrdzr2wwghlL1yrWnVC3T/jWR qBOsT4yfD6cXdIVqVhIMvuwVj6i+qC3kEmGYiaIcjkqPyjKGZfHZnZd7Huti1gzqPPCb h5sXbICJhfQTQKJAOkjMQUTe6TJEs9Ps7xsit3mhbhsAbni/U7OIu7COj8Y1wcgVa1re H0M6yHLW+cll1WCZHuQuE9viSWJYesAl4Wh7WC9Bg+NUc22VQoelOfViQjAj56mlSVFj 0w0WBydvoNrapqtQS2QindqroPxN0N/VMD/8Hrcb1v30s58bLCwlNE3rktdOfQaztVGl T1xg== X-Gm-Message-State: APjAAAWxwqxKAXr1aq/B8sOYZdKTMbCg6roRh8YoFcd1SriyWwN9oZJu vFyRmiIYBjc0jS7fV4tzvOBuOpXSN8XXMfl0ABPsXw== X-Received: by 2002:a5d:8b41:: with SMTP id c1mr7546985iot.173.1553271681269; Fri, 22 Mar 2019 09:21:21 -0700 (PDT) MIME-Version: 1.0 References: <5ef0cab4dee128058a43f43c723c13924662e80d.camel@perches.com> <20190322124331.s5iu4ontsakv7he5@gondor.apana.org.au> In-Reply-To: From: Ard Biesheuvel Date: Fri, 22 Mar 2019 17:21:10 +0100 Message-ID: Subject: Re: [possible PATCH] crypto: sahara - Use #ifdef DEBUG not IS_ENABLED(DEBUG) To: Joe Perches Cc: Herbert Xu , "David S. Miller" , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 22 Mar 2019 at 16:07, Joe Perches wrote: > > On Fri, 2019-03-22 at 15:29 +0100, Ard Biesheuvel wrote: > > On Fri, 22 Mar 2019 at 13:43, Herbert Xu wrote: > > > On Thu, Mar 07, 2019 at 04:15:55PM -0800, Joe Perches wrote: > > > > Normal use of IS_ENABLED is with a CONFIG_ and > > > > there is no -DDEBUG in the Makefile here. > > > > > > > > Replace the IS_ENABLED(DEBUG) with #ifdef DEBUG/#endif > > > > blocks. > > > > > > > > Miscellanea: > > > > > > > > o Move the sahara_state array into the function that uses it. > > > > > > > > Signed-off-by: Joe Perches > > > > --- > > > > drivers/crypto/sahara.c | 20 +++++++++----------- > > > > 1 file changed, 9 insertions(+), 11 deletions(-) > > > > > > Even if this is correct this is way too ugly. The original code > > > at least compiled everything regardless of macros. Your new code > > > won't detect compile errors in debugging code unless debugging is > > > enabled. > > > > > > > What's wrong with IS_ENABLED(DEBUG) anyway? It may not be 'normal use' > > but it works fine. > > drivers/crypto/sahara.c is the only user in the kernel tree. > So only it's abnormal use. I rather like the concept actually. > > IS_ENABLED is almost exclusively used with CONFIG_ symbols > and it could be useful to require it to be used with CONFIG_ > symbols and use some other similar mechanism for DEBUG use. > > Maybe just adding a global #define in kernel.h like > > #define IS_DEBUG_ENABLED IS_ENABLED(DEBUG) > __is_defined(DEBUG) seems to be the most appropriate here. I don't feel strongly about whether we or not should wrap it in another macro. > to isolate this in one place might be better. > > A good thing about using IS_ENABLED or the suggested IS_DEBUG_ENABLED > would be that least gcc 5+ seems to automatically elide the uses of any > unreferenced static const char * arrays like the sahara_state uses here. > Yes, that is kind of the point. If you use #ifdef, the compiler will complain about unused static variables in this case. > (I don't have gcc4 anymore so I couldn't check that version) > > So using 'if (IS_DEBUG_ENABLED)' could simplify some existing code like > the many uses of > > #ifdef DEBUG > ... > #endif > > or equivalent > > My vote would be to use __is_defined(DEBUG) in place, but if others prefer wrapping it in a macro, that is also fine with me.