All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Graf <tgr@reeler.org>
To: lartc@vger.kernel.org
Subject: Re: [LARTC] LIST_FIND in netfilter_ipv4/listhelp.h
Date: Tue, 07 Oct 2003 14:25:08 +0000	[thread overview]
Message-ID: <marc-lartc-106553681118337@msgid-missing> (raw)
In-Reply-To: <marc-lartc-106545160904735@msgid-missing>

Hi

* jeremie le-hen <20031006144458.GD24864@carpediem.epita.fr> 2003-10-06 16:44

> Unless I really drank too much yesterday evening, I'm pretty sure this
> algorithm will fail if the list has only one element, returning NULL
> immediately without even trying to compare the element.
> On the other hand, it seems to work pretty well for months, since it is
> widely used accross the NetFilter conntrack code. So where am I wrong ?

The code is correct.

Check include/linux/list.h, it's a cyclic list:
head->next points to first element
head->prev points to last element

the list iteration code will make it clear:
#define __list_for_each(pos, head) \
    for (pos = (head)->next; pos != (head); pos = pos->next)

Regards

-- 
Thomas GRAF <tgraf@suug.ch>
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

      reply	other threads:[~2003-10-07 14:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-06 14:44 [LARTC] LIST_FIND in netfilter_ipv4/listhelp.h jeremie le-hen
2003-10-07 14:25 ` Thomas Graf [this message]

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=marc-lartc-106553681118337@msgid-missing \
    --to=tgr@reeler.org \
    --cc=lartc@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.