From: Pekka Paalanen <pq@iki.fi>
To: linux-kernel@vger.kernel.org
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
mingo@elte.hu, rostedt@goodmis.org
Subject: A style question: repeated return value check
Date: Mon, 29 Sep 2008 22:14:39 +0300 [thread overview]
Message-ID: <20080929221439.547d65ec@daedalus.pq.iki.fi> (raw)
In-Reply-To: <48E11BFA.1070503@gmail.com>
On Mon, 29 Sep 2008 20:18:34 +0200
Frederic Weisbecker <fweisbec@gmail.com> wrote:
> We need a kind of disambiguation when a print_line callback
> returns 0.
>
> _There is not enough space to print all the entry.
> Please flush the seq and retry.
> _I can't handle this type of entry
>
> This patch changes the type of this callback for better information.
>
> Also some changes have been made in this V2.
>
> _ Only relay to default functions after the print_line callback fails.
> _ This patch doesn't fix the issue with the broken pipe (see patch 2/4 for that)
>
> Some things are still in discussion:
>
> _ Find better names for the enum print_line_t values
> _ Change the type of print_trace_line into boolean.
>
> Patches to change that can be sent later.
>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> ---
> kernel/trace/trace.c | 77 ++++++++++++++++++++++++++-----------------------
> kernel/trace/trace.h | 10 ++++++-
> 2 files changed, 50 insertions(+), 37 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 6ada059..61f33da 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
[...]
> @@ -1633,24 +1633,24 @@ static int print_trace_fmt(struct trace_iterator *iter)
>
> ret = trace_seq_printf(s, "%16s-%-5d ", comm, field->pid);
> if (!ret)
> - return 0;
> + return TRACE_TYPE_PARTIAL_LINE;
> ret = trace_seq_printf(s, "[%03d] ", iter->cpu);
> if (!ret)
> - return 0;
> + return TRACE_TYPE_PARTIAL_LINE;
> ret = trace_seq_printf(s, "%5lu.%06lu: ", secs, usec_rem);
> if (!ret)
> - return 0;
> + return TRACE_TYPE_PARTIAL_LINE;
Off-thread style question: Would it be better or worse to write the
above as
ret = trace_seq_printf(s, "%16s-%-5d ", comm, field->pid);
ret = ret && trace_seq_printf(s, "[%03d] ", iter->cpu);
ret = ret && trace_seq_printf(s, "%5lu.%06lu: ", secs, usec_rem);
if (!ret)
return TRACE_TYPE_PARTIAL_LINE;
which would do exactly the same, but is more compact.
Good or bad style?
Well, it could be rolled into a single trace_seq_printf() call, too.
--
Pekka Paalanen
http://www.iki.fi/pq/
next prev parent reply other threads:[~2008-09-29 19:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-29 18:18 [PATCH V2 -tip 1/4] Tracing/ftrace: Change the type of the print_line callback Frederic Weisbecker
2008-09-29 19:14 ` Pekka Paalanen [this message]
2008-09-30 8:33 ` A style question: repeated return value check Ingo Molnar
2008-09-30 8:48 ` Frédéric Weisbecker
2008-09-30 8:50 ` Frédéric Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080929221439.547d65ec@daedalus.pq.iki.fi \
--to=pq@iki.fi \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®