mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>, Greg KH <gregkh@suse.de>,
	Ingo Molnar <mingo@elte.hu>, Len Brown <lenb@kernel.org>,
	"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-acpi <linux-acpi@vger.kernel.org>
Subject: Re: acpi_cpu_freq_init warning...
Date: Wed, 07 May 2008 04:02:53 +0900	[thread overview]
Message-ID: <87skwvcl2a.fsf@duaron.myhome.or.jp> (raw)
In-Reply-To: <alpine.LFD.1.10.0805060741290.32269@woody.linux-foundation.org> (Linus Torvalds's message of "Tue, 6 May 2008 07:47:18 -0700 (PDT)")

Linus Torvalds <torvalds@linux-foundation.org> writes:

> 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.

Whoops, sorry. You are right.

diff -puN drivers/base/sys.c~fix-sys-bogus-warning drivers/base/sys.c
--- linux-2.6/drivers/base/sys.c~fix-sys-bogus-warning	2008-05-07 03:51:00.000000000 +0900
+++ linux-2.6-hirofumi/drivers/base/sys.c	2008-05-07 04:01:14.000000000 +0900
@@ -175,8 +175,7 @@ int sysdev_driver_register(struct sysdev
 	}
 
 	/* Check whether this driver has already been added to a class. */
-	if ((drv->entry.next != drv->entry.prev) ||
-	    (drv->entry.next != NULL)) {
+	if (drv->entry.next && !list_empty(&drv->entry)) {
 		printk(KERN_WARNING "sysdev: class %s: driver (%p) has already"
 			" been registered to a class, something is wrong, but "
 			"will forge on!\n", cls->name, drv);
_
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

  reply	other threads:[~2008-05-06 19:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-06  2:51 Yinghai Lu
2008-05-06  6:29 ` OGAWA Hirofumi
2008-05-06  6:47   ` Greg KH
2008-05-06  7:13     ` OGAWA Hirofumi
2008-05-06 14:47   ` Linus Torvalds
2008-05-06 19:02     ` OGAWA Hirofumi [this message]
2008-05-06 20:20       ` Greg KH
2008-05-06 20:27         ` Linus Torvalds
2008-05-06 21:38           ` Greg KH
2008-05-06 15:44   ` Thomas Renninger

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=87skwvcl2a.fsf@duaron.myhome.or.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=gregkh@suse.de \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@linux-foundation.org \
    --cc=yhlu.kernel@gmail.com \
    /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

all inboxes | Powered by JetHome®