Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp767327img; Fri, 22 Mar 2019 08:09:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwX6scJszSlLToakUZa6W4qmWWWxDq/7qUPpIaxqg70INVtajl57Rd17aR+xUMKQoaR4zaL X-Received: by 2002:a63:d5f:: with SMTP id 31mr9347157pgn.274.1553267387392; Fri, 22 Mar 2019 08:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553267387; cv=none; d=google.com; s=arc-20160816; b=1H+VgXclxtsiqvq/Pr0eiaPe3aH/1aSbPMfzAlIc8RvEzyoIo9WpbReB9mhofDpwF2 dv/76xmblDbeehFk6Vpeg0QoTmnZBITxhKe/GRNwE4o2GlTBSjKqnkkff/H0PC//uL24 t9/EaJFVEuU2N5n4wH7XxH+C3WOdVvb00muC+jp41NXoawwE/c3wVLSarpqal9/FaZrV UF1wIZ01zeo/4RomqamLNHu0d10SbUsZcmGDVTdPq9Rv0iaQrBxhRdr+5R7POeiEnPI6 dmEtcw+3ZQ82XSr7N3J2rGQ94wOloeYfLlKPBpqoZH5ZP5CbXbHb1jYY+cr39FodoCcG r0dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=XIz+HvIjYpKoIFUvJ1nn8gRu3/Q6ehFoA4KudMPlrJ4=; b=PRY/wzC3DCuieI58Exl8F4BrDauFqk+DCmEVn4iHe1EONHQvFFjS9xd7NcGpLSyBBw kq5ZD56wHM8vlRb4St4IjPFLOLWZh74DVM/cJt7gYr201SWzAkBeM1G1+oEX2Ucao0GB z3rrq8s4WA6wZ+SPFFbSRF5Yzj/eQWGnM7g/qr3YQdQzLCd1BdNonEOLBOUI86/lp4Aw PDAcYhaeuFqV3R7M9WYVCA0643xZ4cIieGLV1lgeOwnbrqO3HMfTZVpPcgrGFjmQWhBh 3YdTPchYCY4imWX+wSIaBv1vy2qD+U1miPsco3TIj5jvmx3LLcCn5mWSmsjUZenDHT2H 78Sw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si6752291pfi.25.2019.03.22.08.09.31; Fri, 22 Mar 2019 08:09:47 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726472AbfCVPHQ (ORCPT + 99 others); Fri, 22 Mar 2019 11:07:16 -0400 Received: from smtprelay0110.hostedemail.com ([216.40.44.110]:56930 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725982AbfCVPHQ (ORCPT ); Fri, 22 Mar 2019 11:07:16 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 6EB1C181D3419; Fri, 22 Mar 2019 15:07:14 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:69:334:355:368:369:379:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:5007:6119:7903:10004:10400:10450:10455:10848:11026:11232:11473:11658:11914:12296:12740:12760:12895:13069:13161:13229:13311:13357:13439:13848:14096:14097:14181:14659:14721:19904:19999:21080:21451:21627:21740:21795:30012:30034:30051:30054:30070:30089:30090:30091,0,RBL:47.151.153.53:@perches.com:.lbl8.mailshell.net-62.14.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:82,LUA_SUMMARY:none X-HE-Tag: iron05_21f39d98df515 X-Filterd-Recvd-Size: 3047 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf01.hostedemail.com (Postfix) with ESMTPA; Fri, 22 Mar 2019 15:07:13 +0000 (UTC) Message-ID: Subject: Re: [possible PATCH] crypto: sahara - Use #ifdef DEBUG not IS_ENABLED(DEBUG) From: Joe Perches To: Ard Biesheuvel , Herbert Xu Cc: "David S. Miller" , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , LKML Date: Fri, 22 Mar 2019 08:07:12 -0700 In-Reply-To: References: <5ef0cab4dee128058a43f43c723c13924662e80d.camel@perches.com> <20190322124331.s5iu4ontsakv7he5@gondor.apana.org.au> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.1-1build1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) 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. (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