From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933448AbdCaRpQ (ORCPT ); Fri, 31 Mar 2017 13:45:16 -0400 Received: from smtprelay0036.hostedemail.com ([216.40.44.36]:41119 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933327AbdCaRpP (ORCPT ); Fri, 31 Mar 2017 13:45:15 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:1801:2194:2199:2393:2553:2559:2562:2740:2828:2911:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:4425:4605:5007:6119:7875:7903:9149:10004:10400:10848:11026:11232:11658:11914:12043:12663:12740:12760:12895:13439:14181:14659:14721:21080:21434:21451:30012:30041:30054:30069:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: fang12_2cee2729c6408 X-Filterd-Recvd-Size: 3345 Message-ID: <1490982307.27353.14.camel@perches.com> Subject: Re: [PATCH] ath6kl: Add __printf verification to ath6kl_dbg From: Joe Perches To: Steve deRosier Cc: Kalle Valo , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 31 Mar 2017 10:45:07 -0700 In-Reply-To: References: <1490981039.27353.12.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.3-0ubuntu0.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2017-03-31 at 10:34 -0700, Steve deRosier wrote: > On Fri, Mar 31, 2017 at 10:23 AM, Joe Perches wrote: > > On Fri, 2017-03-31 at 10:19 -0700, Steve deRosier wrote: > > > On Thu, Mar 30, 2017 at 3:57 PM, Joe Perches wrote: > > > > Fix fallout too. > > > > [] > > > My only question is why bother doing a format check on something > > > that's going to be compiled out anyway? > > > > To avoid introducing defects when writing new code > > and not using the debugging code path. > > > > Fair enough. And I totally agree with the defensive programming here > in that case and feel it's worth the tradeoff (if indeed there really > is any cost, I'm unsure what gcc actually does in this instance). > > For sake of discussion though - shouldn't anything not using the debug > code path in this case always be of the form that compiles out? ie > would be empty functions intended here just to make compilation work > and the code that depends on it simpler? Thus, there really should > never be a risk of introducing said defects. If any "real" code were > put in that else clause, that'd be a big red-flag in the review of > said hypothetical patch. Generically, all debugging forms should strive to avoid side-effects. For instance, look at no_printk/pr_debug in the #ifndef DEBUG paths. It uses if (0) to avoid compilation of arguments that might be function calls or volatile accesses and so might have side-effects altogether. include/linux/printk.h-/* include/linux/printk.h- * Dummy printk for disabled debugging statements to use whilst maintaining include/linux/printk.h- * gcc's format checking. include/linux/printk.h- */ include/linux/printk.h:#define no_printk(fmt, ...) \ include/linux/printk.h-({ \ include/linux/printk.h- do { \ include/linux/printk.h- if (0) \ include/linux/printk.h- printk(fmt, ##__VA_ARGS__); \ include/linux/printk.h- } while (0); \ include/linux/printk.h- 0; \ include/linux/printk.h-}) i