[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141124214939.GA6671@potion.brq.redhat.com>
Date: Mon, 24 Nov 2014 22:49:40 +0100
From: Radim Krčmář <rkrcmar@...hat.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Jan Kiszka <jan.kiszka@...mens.com>,
Paolo Bonzini <pbonzini@...hat.com>,
nick <xerofoify@...il.com>, gleb@...nel.org, tglx@...utronix.de,
mingo@...hat.com, hpa@...or.com, x86@...nel.org,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: Another Obsolete Fix me in trace.h?
2014-11-24 16:19-0500, Steven Rostedt:
> On Mon, 24 Nov 2014 22:00:01 +0100
> Radim Krčmář <rkrcmar@...hat.com> wrote:
>
> > 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].
> >
> > The raw result would look like
> >
> > #define __print(fmt, args...) ({ \
> > const char *buf_start = trace_seq_buffer_ptr(p); \
> > trace_seq_printf(p, fmt, args); \
> > trace_seq_putc(p, '\0'); \
> > buf_start; \
> > })
> >
> > TP_printk("%s%s", [...],
> > __entry->has_error ? __print("(0x%x)", __entry->error_code) : "")
> >
> > and would be acceptable if something __print-like made it into a ftrace
> > helper[4]. (Userspace won't be able to nicely print it otherwise.)
>
> You mean if we add something like a __print_conditional(cond, fmt, ...);
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:
>
> TP_printk("%s%s", [...],
> __print_conditional(__entry->has_error, " (0x%x)", __entry->error_code));
>
> Where __print_conditional() will return "" when "cond" is false, and
> will return the formatted string otherwise.
(This might introduce 'const char empty[] = ""'.)
> That wouldn't be too hard to implement.
I'll look at the patch tommorrow.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists