PDA

View Full Version : Example bug when using Linux list macros



joecar
October 6th, 2006, 05:26 AM
Two of us have (here at work) been chasing a bug for about 4+ days...

We found this to be the faulty line of code:
list_for_each_entry(vha, &vfp->vp_list, vp_list)
It should have read as follows:
list_for_each_entry(vha, &vfp->vp_list, vsan_list)
Oh what fun we have been having... :bash::bash::bash::bash:

Brains
October 6th, 2006, 09:01 AM
Nothing like passing in the wrong list, huh? ;)

joecar
October 6th, 2006, 12:31 PM
Here's another good hole to fall into...




list_add_tail

Name
list_add_tail -- add a new entry

Synopsis
void list_add_tail (struct list_head * new, struct list_head * head);

Arguments
new new entry to be added
head list head to add it before

Description
Insert a new entry before the specified head. This is useful for implementing queues.


So what does the word "tail" mean in the name of this macro
(it does not append the new entry at the tail of the list)...?

:bash::bash::bash::bash:

joecar
October 6th, 2006, 01:42 PM
So what does the word "tail" mean in the name of this macro
(it does not append the new entry at the tail of the list)...?

Oh, I see it, it's a circular list, so before the head is the tail... :bash:

Garry
October 7th, 2006, 01:19 AM
You can also use list_add, which will add it after the &head-entry ... ;) In case you're wondering ...
It seems like there were lots of "list_add(item, listitem.prev)" calls, so in order to make the calls more easily readable, the function was added ... slightly poor choice of name, though ...