Message ID | 20170712123658.25363-3-phil@nwl.cc |
---|---|
State | Changes Requested |
Delegated to: | Pablo Neira |
Headers | show |
On 12 July 2017 at 14:36, Phil Sutter <phil@nwl.cc> wrote: > Similar to list_first_entry, this macro allows to retrieve the list's > last entry. > > Signed-off-by: Phil Sutter <phil@nwl.cc> > --- > include/list.h | 11 +++++++++++ > 1 file changed, 11 insertions(+) Phil, I think you can safely merge this patch into 1/4. Better to introduce new functions at the same time of the callers, the same patch. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Jul 12, 2017 at 05:41:32PM +0200, Arturo Borrero Gonzalez wrote: > On 12 July 2017 at 14:36, Phil Sutter <phil@nwl.cc> wrote: > > Similar to list_first_entry, this macro allows to retrieve the list's > > last entry. > > > > Signed-off-by: Phil Sutter <phil@nwl.cc> > > --- > > include/list.h | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > Phil, > > I think you can safely merge this patch into 1/4. > > Better to introduce new functions at the same time of the callers, the > same patch. Well, patches 2 and 3 are used by patch 4, so not added afterwards (that would be a bummer indeed). I kept them separate for a purpose: When backporting fixes, it is often quite annoying when one has to fiddle these independent parts out of another patch which does something unrelated. So whenever One wants to backport a patch using list_first_entry() (in this example), there is a separate commit to backport which contains the macro and nothing else. No big deal in this case, though so no objections merging them. Thanks, Phil -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/include/list.h b/include/list.h index 75d2921240101..5405dbbc0066b 100644 --- a/include/list.h +++ b/include/list.h @@ -337,6 +337,17 @@ static inline void list_splice_tail_init(struct list_head *list, #define list_first_entry(ptr, type, member) \ list_entry((ptr)->next, type, member) +/** + * list_last_entry - get the last element from a list + * @ptr: the list head to take the element from. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + * + * Note, that list is expected to be not empty. + */ +#define list_last_entry(ptr, type, member) \ + list_entry((ptr)->prev, type, member) + /** * list_for_each_entry - iterate over list of given type
Similar to list_first_entry, this macro allows to retrieve the list's last entry. Signed-off-by: Phil Sutter <phil@nwl.cc> --- include/list.h | 11 +++++++++++ 1 file changed, 11 insertions(+)