From: jeremie le-hen <le-hen_j@epita.fr>
To: lartc@vger.kernel.org
Subject: [LARTC] LIST_FIND in netfilter_ipv4/listhelp.h
Date: Mon, 06 Oct 2003 14:44:58 +0000 [thread overview]
Message-ID: <marc-lartc-106545160904735@msgid-missing> (raw)
Hi folks,
I'm currently trying to make a patch on conntrack module. While reading some
code I saw the following in include/linux/netfilter_ipv4/listhelp.h :
/* Works on circular linked list. */
#define LIST_FIND(head, cmpfn, type, args...) \
({ \
const struct list_head *__i = (head); \
\
ASSERT_READ_LOCK(head); \
do { \
__i = __i->next; \
if (__i = (head)) { \
__i = NULL; \
break; \
} \
} while (!cmpfn((const type)__i , ## args)); \
(type)__i; \
})
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 ?
Thanks in advance.
Regards,
--
Jeremie LE HEN aka TtZ/TataZ jeremie.le-hen@epita.fr
ttz@epita.fr
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
next reply other threads:[~2003-10-06 14:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-06 14:44 jeremie le-hen [this message]
2003-10-07 14:25 ` [LARTC] LIST_FIND in netfilter_ipv4/listhelp.h Thomas Graf
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-106545160904735@msgid-missing \
--to=le-hen_j@epita.fr \
--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.