From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Graf Date: Tue, 07 Oct 2003 14:25:08 +0000 Subject: Re: [LARTC] LIST_FIND in netfilter_ipv4/listhelp.h Message-Id: List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: lartc@vger.kernel.org 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 _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/