From: Josh Triplett <josh@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Richard Knutsson <ricknu-0@student.ltu.se>,
linux-kernel@vger.kernel.org,
"Paul E. McKenney" <paulmck@us.ibm.com>
Subject: Re: [PATCH 3/3] rcutorture: Remove redundant assignment to cur_ops in for loop
Date: Wed, 07 Feb 2007 17:42:40 -0800 [thread overview]
Message-ID: <45CA8010.70803@kernel.org> (raw)
In-Reply-To: <20070207162410.581bcc98.akpm@linux-foundation.org>
Andrew Morton wrote:
> On Wed, 7 Feb 2007 16:22:28 -0800
> Andrew Morton <akpm@linux-foundation.org> wrote:
>> I suspect we can do better than that...
[...]
Much better; please go ahead and replace my patch with this one.
Signed-off-by: Josh Triplett <josh@kernel.org>
- Josh Triplett
> --- a/kernel/rcutorture.c~rcutorture-remove-redundant-assignment-to-cur_ops-in
> +++ a/kernel/rcutorture.c
> @@ -569,10 +569,6 @@ static struct rcu_torture_ops sched_ops
> .name = "sched"
> };
>
> -static struct rcu_torture_ops *torture_ops[] =
> - { &rcu_ops, &rcu_sync_ops, &rcu_bh_ops, &rcu_bh_sync_ops,
> - &srcu_ops, &qrcu_ops, &sched_ops, NULL };
> -
> /*
> * RCU torture writer kthread. Repeatedly substitutes a new structure
> * for that pointed to by rcu_torture_current, freeing the old structure
> @@ -939,16 +935,17 @@ rcu_torture_init(void)
> int i;
> int cpu;
> int firsterr = 0;
> + static struct rcu_torture_ops *torture_ops[] =
> + { &rcu_ops, &rcu_sync_ops, &rcu_bh_ops, &rcu_bh_sync_ops,
> + &srcu_ops, &qrcu_ops, &sched_ops, };
>
> /* Process args and tell the world that the torturer is on the job. */
> -
> - for (i = 0; cur_ops = torture_ops[i], cur_ops; i++) {
> + for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
> cur_ops = torture_ops[i];
> - if (strcmp(torture_type, cur_ops->name) == 0) {
> + if (strcmp(torture_type, cur_ops->name) == 0)
> break;
> - }
> }
> - if (cur_ops == NULL) {
> + if (i == ARRAY_SIZE(torture_ops)) {
> printk(KERN_ALERT "rcutorture: invalid torture type: \"%s\"\n",
> torture_type);
> return (-EINVAL);
> _
>
>
>
prev parent reply other threads:[~2007-02-08 1:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-07 18:54 [PATCH 1/3] rcutorture: Use ARRAY_SIZE macro when appropriate Josh Triplett
2007-02-07 18:56 ` [PATCH 2/3] rcutorture: style cleanup: avoid != NULL in boolean tests Josh Triplett
2007-02-07 18:57 ` [PATCH 3/3] rcutorture: Remove redundant assignment to cur_ops in for loop Josh Triplett
2007-02-07 23:56 ` Richard Knutsson
2007-02-08 0:22 ` Andrew Morton
2007-02-08 0:24 ` Andrew Morton
2007-02-08 1:42 ` Josh Triplett [this message]
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=45CA8010.70803@kernel.org \
--to=josh@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@us.ibm.com \
--cc=ricknu-0@student.ltu.se \
/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