From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757608AbaISRV3 (ORCPT ); Fri, 19 Sep 2014 13:21:29 -0400 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.228]:40794 "EHLO cdptpa-oedge-vip.email.rr.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756810AbaISRV2 (ORCPT ); Fri, 19 Sep 2014 13:21:28 -0400 Date: Fri, 19 Sep 2014 13:21:23 -0400 From: Steven Rostedt To: Omar Sandoval Cc: Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, "Paul E. McKenney" , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] Return a value from printk_ratelimited Message-ID: <20140919132123.418b276f@gandalf.local.home> In-Reply-To: <3629aa32fd3e434e41e5e5f4a97ab50adb8edcdc.1411116672.git.osandov@osandov.com> References: <3629aa32fd3e434e41e5e5f4a97ab50adb8edcdc.1411116672.git.osandov@osandov.com> X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.24; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-RR-Connecting-IP: 107.14.168.118:25 X-Cloudmark-Score: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 19 Sep 2014 02:01:29 -0700 Omar Sandoval wrote: > printk returns an integer; there's no reason for printk_ratelimited to swallow > it. > > Signed-off-by: Omar Sandoval > --- > include/linux/printk.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/include/linux/printk.h b/include/linux/printk.h > index d78125f..67534bc 100644 > --- a/include/linux/printk.h > +++ b/include/linux/printk.h > @@ -343,12 +343,14 @@ extern asmlinkage void dump_stack(void) __cold; > #ifdef CONFIG_PRINTK > #define printk_ratelimited(fmt, ...) \ > ({ \ > + int __ret = 0; \ My only issues is with the "__ret" name. It's not really unique enough. If something else uses __ret and does printk_ratelimit("some fmt string %d\n", __ret); This will not print the right value. printk_ratelimit can be used almost anywhere thus using a really unique value may be worth while here. What about: int ______r ? -- Steve > static DEFINE_RATELIMIT_STATE(_rs, \ > DEFAULT_RATELIMIT_INTERVAL, \ > DEFAULT_RATELIMIT_BURST); \ > \ > if (__ratelimit(&_rs)) \ > - printk(fmt, ##__VA_ARGS__); \ > + __ret = printk(fmt, ##__VA_ARGS__); \ > + __ret; \ > }) > #else > #define printk_ratelimited(fmt, ...) \