Re: [PATCH] irq: clear kstat_irqs
From: Andrew Morton
Date: Fri Feb 06 2009 - 17:00:39 EST
On Fri, 06 Feb 2009 13:50:47 -0800
Yinghai Lu <yinghai@xxxxxxxxxx> 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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/