mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>,
	Don Mullis <don.mullis@gmail.com>,
	Dave Chinner <david@fromorbit.com>
Cc: linux-kernel@vger.kernel.org
Subject: list sort
Date: Wed, 27 Jul 2011 14:23:34 +0100	[thread overview]
Message-ID: <1311773014.2801.23.camel@menhir> (raw)

Hi,

There seems to be an issue with list_sort trying to compare an object to
itself. I spotted it first in a list for which I knew that I had unique
keys, so had put a BUG() in the cmp function if the keys being compared
were equal. While investigating I discovered that the objects themselves
were equal (and hence the keys, also). The following addition to the
list_sort test also triggers twice during the self test:

diff --git a/lib/list_sort.c b/lib/list_sort.c
index d7325c6..afa4a97 100644
--- a/lib/list_sort.c
+++ b/lib/list_sort.c
@@ -198,6 +198,8 @@ static int __init cmp(void *priv, struct list_head *a, struct list_head *b)
 {
 	struct debug_el *ela, *elb;
 
+	WARN_ON(a == b);
+
 	ela = container_of(a, struct debug_el, list);
 	elb = container_of(b, struct debug_el, list);
 

While it appears generally harmless, since the list does appear to be
correctly sorted, it is doing extra work needlessly.

I couldn't find a listing in the maintainers' file for list_sort, so
I used git to find those who'd worked on it recently,

Steve.




             reply	other threads:[~2011-07-27 13:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27 13:23 Steven Whitehouse [this message]
2011-07-27 14:45 ` Clemens Ladisch
2011-07-27 15:04   ` Steven Whitehouse

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=1311773014.2801.23.camel@menhir \
    --to=swhiteho@redhat.com \
    --cc=Artem.Bityutskiy@nokia.com \
    --cc=david@fromorbit.com \
    --cc=don.mullis@gmail.com \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®