lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 30 Sep 2008 10:33:52 +0200 From: Ingo Molnar <mingo@...e.hu> To: Pekka Paalanen <pq@....fi> Cc: linux-kernel@...r.kernel.org, Frederic Weisbecker <fweisbec@...il.com>, rostedt@...dmis.org Subject: Re: A style question: repeated return value check * Pekka Paalanen <pq@....fi> wrote: > > 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? in this particular case it's marginally worse style i think, even considering that it makes the code more compact. The reason is that it makes the code a tiny bit less obvious: the flow looks a bit unusual and when skimming it i'd have to look once more to understand its purpose. With the returns its more verbose but also plain obvious. YMMV. Ingo -- 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