Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1668530ybt; Mon, 15 Jun 2020 06:32:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIaKBPOjpwHaLYKV6LsbUGZPBlEN4QF59TJLr4HpQOl2WP2gXMbF2r9KiczmuzUhgrUp4N X-Received: by 2002:a05:6402:b31:: with SMTP id bo17mr24528298edb.152.1592227937552; Mon, 15 Jun 2020 06:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592227937; cv=none; d=google.com; s=arc-20160816; b=gBRtbi2tMkO0++xKVKsy0HHDs+Xah2kQbsd18TUEZiZ8SI50W9HwUWD89kkdrlHLj8 mxrICfGDUhCQ/JPXNRfEnL4ULcS046ZKpP/iGBcj0a5MME0VUA6AUbLomj3B9XCE6Laf N4ms/Y9CJ4gEUoeNmpf9LDJ7P3jxZfGkNM7WuUYxXnYjvyBGr9FA/imtJfeLNdXtK+BZ /ismx25ECnEPwObipoEBrbDdIwl7hqCjenkPxCeyxY+SvgQFrvJyqEXznLIhz5GzqbDt JWiRsEmCvUWe9NKh/ffyAjrcc6Q8rSfrAI8DiliirgS/R0h5tIjkSndqgRtlWt32sWqK 2qzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=F5pvZRbZ2Ue1nf6jR2jOAsLu4MJ7IIYW4Ofj+syCx8U=; b=jKlLupvV57pJ8mache0M7uRiDJhU2bj1JV+QyIzmsaVmBqIbcQQc34mduLfgX68+Hi A0FOHyRDPe5SFY0cL0pvCn8NP/pOkOIQl+wvRPa5rqjNMhIFSyORlVtVrLgyXmypf0Vb 0XWuW1vbP6MaWjkGdZDYkC+gYehMepxeUMCHG/9elUt8llYAZCydPa8HBo+JiMmzJ7nM BpSk7VShecxRdIOKqzY93x9/vGk5/RHsKsLUgh3G8KOYVkz3KnH7sQUH6NiOkrmPbwBO fssv5WAB7zdBuo2mbXGAYb1uNzxepfs315FnaMeeQrASYmo2O2+rXQnT2kRTlL46iWjT sERg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 j6si9037220edp.147.2020.06.15.06.31.53; Mon, 15 Jun 2020 06:32:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730519AbgFON27 (ORCPT + 99 others); Mon, 15 Jun 2020 09:28:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:60072 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730147AbgFON26 (ORCPT ); Mon, 15 Jun 2020 09:28:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 65B3EACE1; Mon, 15 Jun 2020 13:29:01 +0000 (UTC) Date: Mon, 15 Jun 2020 15:28:56 +0200 From: Petr Mladek To: Jim Cromie Cc: jbaron@akamai.com, linux-kernel@vger.kernel.org, akpm@linuxfoundation.org, gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk Subject: Re: [PATCH v2 09/24] dyndbg: add maybe(str,"") macro to reduce code Message-ID: <20200615132856.GF31238@alley> References: <20200613155738.2249399-1-jim.cromie@gmail.com> <20200613155738.2249399-10-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200613155738.2249399-10-jim.cromie@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat 2020-06-13 09:57:23, Jim Cromie wrote: > reduce word count via macro, no actual object change. > > OTOH, maybe() could be scrubbed if printk's default printing (iirc) of > "(null)" pointers is deemed appropriate for the log-msg. > --- > lib/dynamic_debug.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c > index 31d3be30776e..20b712652ee4 100644 > --- a/lib/dynamic_debug.c > +++ b/lib/dynamic_debug.c > @@ -114,6 +114,7 @@ do { \ > #define vpr_info(fmt, ...) vnpr_info(1, fmt, ##__VA_ARGS__) > #define v2pr_info(fmt, ...) vnpr_info(2, fmt, ##__VA_ARGS__) > > +#define maybe(str, empty) ( str ? str : empty ) > static void vpr_info_dq(const struct ddebug_query *query, const char *msg) > { > /* trim any trailing newlines */ > @@ -127,10 +128,10 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) > > vpr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u\n", > msg, > - query->function ? query->function : "", > - query->filename ? query->filename : "", > - query->module ? query->module : "", > - fmtlen, query->format ? query->format : "", > + maybe(query->function, ""), > + maybe(query->filename, ""), > + maybe(query->module, ""), > + fmtlen, maybe(query->format, ""), From my POV this makes the code less readable. Open coding is much more clear than an ambiguous macro name. Best Regards, Petr