From: Ingo Molnar <mingo@elte.hu>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: prasad@linux.vnet.ibm.com,
Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Roland McGrath <roland@redhat.com>
Subject: Re: [patch 00/11] Hardware Breakpoint interfaces
Date: Tue, 10 Mar 2009 15:54:20 +0100 [thread overview]
Message-ID: <20090310145420.GJ3850@elte.hu> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0903101019570.2962-100000@iolanthe.rowland.org>
* Alan Stern <stern@rowland.harvard.edu> wrote:
> On Tue, 10 Mar 2009, Ingo Molnar wrote:
>
> >
> > There's also a few checkpatch warnings that need to be
> > addressed:
> >
> > ERROR: do not use assignment in if condition
> > #1084: FILE: arch/x86/kernel/ptrace.c:581:
> > + else if ((thbi = alloc_thread_hw_breakpoint(tsk)) ==
> > NULL)
>
> Changing this to remove the assignment from within the "if"
> condition would make the code less readable, not more. [...]
It's not just about basic readability. We dont do assignmets
like that because it's very easy to miss them (and their side
effects) and conflating them with '=='.
It's part of a long
> series of tests; in schematic form:
>
> if (n == 4 || n == 5)
> ...
> else if (n == 6) {
> ...
> }
> else if (!tsk->thread.hw_breakpoint_info && val == 0)
> ...
> else if ((thbi = alloc_thread_hw_breakpoint(tsk)) == NULL)
> ...
> else if (n < HB_NUM) {
> ...
> }
> else
> ...
>
> If you can suggest a way to change the code without making it
> worse, I'm sure Prasad will be happy to adopt it.
The obvious solution which we use in many other places in
arch/x86 is to split out that butt-ugly if else if else if else
maze into a helper inline function that does:
if (n == 4 || n == 5) {
do stuff;
return;
}
if (n == 6) {
do stuff;
return;
}
if (!tsk->thread.hw_breakpoint_info && val == 0) {
do stuff;
return;
}
thbi = alloc_thread_hw_breakpoint(tsk);
if (!tbhi)
...
Ingo
next prev parent reply other threads:[~2009-03-10 14:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-05 4:37 [patch 00/11] Hardware Breakpoint interfaces prasad
2009-03-10 13:46 ` Ingo Molnar
2009-03-11 12:11 ` K.Prasad
2009-03-11 16:34 ` Alan Stern
2009-03-11 17:25 ` K.Prasad
2009-03-11 17:30 ` Ingo Molnar
2009-03-10 13:51 ` Ingo Molnar
2009-03-10 14:24 ` Alan Stern
2009-03-10 14:54 ` Ingo Molnar [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-03-07 5:04 [Patch 00/11] Hardware Breakpoint Interfaces prasad
2009-03-24 15:24 [Patch 00/11] Hardware Breakpoint interfaces K.Prasad
2009-03-25 19:48 ` Alan Stern
2009-03-27 22:06 ` K.Prasad
2009-04-01 16:16 ` Alan Stern
2009-04-07 8:22 ` K.Prasad
2009-04-09 20:50 ` Alan Stern
2009-03-28 8:46 ` K.Prasad
2009-04-01 16:22 ` Alan Stern
2009-04-07 8:22 ` K.Prasad
2009-04-07 6:34 K.Prasad
2009-04-16 21:19 ` Alan Stern
2009-04-17 3:12 ` K.Prasad
2009-04-17 14:37 ` Alan Stern
2009-04-24 5:56 ` K.Prasad
2009-04-24 14:16 ` Alan Stern
2009-04-24 15:57 ` K.Prasad
2009-04-24 16:16 ` Alan Stern
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=20090310145420.GJ3850@elte.hu \
--to=mingo@elte.hu \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=prasad@linux.vnet.ibm.com \
--cc=roland@redhat.com \
--cc=stern@rowland.harvard.edu \
/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