Re: acpi_cpu_freq_init warning...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Tue, 6 May 2008, OGAWA Hirofumi wrote:
> -	if ((drv->entry.next != drv->entry.prev) ||
> +	if ((drv->entry.next != drv->entry.prev) &&
>  	    (drv->entry.next != NULL)) {

Umm. That code still makes no sense.

The "drv->entry.next == drv->entry.prev" condition will trigger under 
*three* different circumstances:

 - next/prev == NULL (uninitialized). Checked for by the explicit check 
   against NULL.

 - list empty (both next/prev point back to itself), which I assume the 
   check was *meant* for.

 - list has only *one* entry, when next/prev both point to the list head.

and I'm pretty damn sure that whoever wrote that code didn't mean that 
last one, but who knows..

The fact is, looking at next/prev this way is a sure way to have bugs.

What is that PoS *trying* to test for? I assume it is meant to test for

	/* Is the list initialized and non-empty? */
	if (drv->entry.next && !list_empty(&drv->entry)) {
		...

and dammit, just doing it that way is shorter and simpler.

				Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux