From: Andrew Morton <akpm@linux-foundation.org>
To: Yinghai Lu <yinghai@kernel.org>
Cc: mingo@elte.hu, tglx@linutronix.de, hpa@zytor.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] irq: clear kstat_irqs
Date: Fri, 6 Feb 2009 14:00:05 -0800 [thread overview]
Message-ID: <20090206140005.44b4bb50.akpm@linux-foundation.org> (raw)
In-Reply-To: <498CB0B7.8030009@kernel.org>
On Fri, 06 Feb 2009 13:50:47 -0800
Yinghai Lu <yinghai@kernel.org> wrote:
> +void clear_kstat_irqs(struct irq_desc *desc)
> +{
> + unsigned long bytes;
size_t would be more formally correct.
> + char *ptr;
> +
> + ptr = (char *)desc->kstat_irqs;
> + /* Compute how many bytes we need to clear */
> + bytes = nr_cpu_ids * sizeof(unsigned int);
This is fragile. For example, if someone changes ->kstat_irqs to long
then this code will secretly and subtly break.
If it used sizeof(*(desc->kstat_irqs)) then everything would magically
continue to work.
> + memset(ptr, 0, bytes);
> +}
The whole function could be written as
memset(desc->kstat_irqs, 0, nr_cpu_ids * sizeof(*(desc->kstat_irqs)));
next prev parent reply other threads:[~2009-02-06 22:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-06 21:50 [PATCH] irq: clear kstat_irqs Yinghai Lu
2009-02-06 22:00 ` Andrew Morton [this message]
2009-02-06 22:08 ` [PATCH] irq: clear kstat_irqs v2 Yinghai Lu
2009-02-07 7:49 ` [PATCH] irq: optimize init_kstat_irqs/init_copy_kstat_irqs Yinghai Lu
2009-02-07 8:26 ` Andrew Morton
2009-02-07 9:01 ` Yinghai Lu
2009-02-07 9:06 ` Andrew Morton
2009-02-09 8:11 ` Ingo Molnar
2009-02-09 8:19 ` Andrew Morton
2009-02-09 8:37 ` Ingo Molnar
2009-02-09 8:43 ` Andrew Morton
2009-02-09 11:34 ` Ingo Molnar
2009-02-09 8:44 ` Yinghai Lu
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=20090206140005.44b4bb50.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=yinghai@kernel.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