From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: Another Obsolete Fix me in trace.h? Date: Mon, 24 Nov 2014 22:49:40 +0100 Message-ID: <20141124214939.GA6671@potion.brq.redhat.com> References: <5472B5B5.5090201@gmail.com> <54730475.9040000@redhat.com> <54730B33.1080101@siemens.com> <20141124210000.GB6795@potion.brq.redhat.com> <20141124161901.6266925c@gandalf.local.home> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Jan Kiszka , Paolo Bonzini , nick , gleb@kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: Steven Rostedt Return-path: Content-Disposition: inline In-Reply-To: <20141124161901.6266925c@gandalf.local.home> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 2014-11-24 16:19-0500, Steven Rostedt: > On Mon, 24 Nov 2014 22:00:01 +0100 > Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: >=20 > > 2014-11-24 11:40+0100, Jan Kiszka: > > The format string has to be a string literal[1]; we could change it= to > > allow expressions[2], but what we want is almost possible through a > > direct call to trace_seq_printf()[3]. > >=20 > > The raw result would look like > >=20 > > #define __print(fmt, args...) ({ \ > > const char *buf_start =3D trace_seq_buffer_ptr(p); \ > > trace_seq_printf(p, fmt, args); \ > > trace_seq_putc(p, '\0'); \ > > buf_start; \ > > }) > >=20 > > TP_printk("%s%s", [...], > > __entry->has_error ? __print("(0x%x)", __entry->error_c= ode) : "") > >=20 > > and would be acceptable if something __print-like made it into a ft= race > > helper[4]. (Userspace won't be able to nicely print it otherwise.) >=20 > You mean if we add something like a __print_conditional(cond, fmt, ..= =2E); The benefit of _conditional is cleaner code? (_conditional would be possible as a #define on top of generic print, the ternary seems to be parsed correctly.) > For this case you would have: >=20 > TP_printk("%s%s", [...], > __print_conditional(__entry->has_error, " (0x%x)", __entry->error_co= de)); >=20 > Where __print_conditional() will return "" when "cond" is false, and > will return the formatted string otherwise. (This might introduce 'const char empty[] =3D ""'.) > That wouldn't be too hard to implement. I'll look at the patch tommorrow. Thanks.