[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090206140005.44b4bb50.akpm@linux-foundation.org>
Date: Fri, 6 Feb 2009 14:00:05 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Yinghai Lu <yinghai@...nel.org>
Cc: mingo@...e.hu, tglx@...utronix.de, hpa@...or.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] irq: clear kstat_irqs
On Fri, 06 Feb 2009 13:50:47 -0800
Yinghai Lu <yinghai@...nel.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)));
--
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