[sheepdog] [RFC PATCH 0/3] make list and rbtree more safe

Liu Yuan namei.unix at gmail.com
Thu Sep 26 07:09:38 CEST 2013


On Thu, Sep 26, 2013 at 03:12:08AM +0900, MORITA Kazutaka wrote:
> From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> 
> This series adds a bit complexity to list and rbtree macros
> definition, but makes their usage much simpler and type-safer.  With
> this series,
> 
>  - list and rbtree macros can detect errors when we insert a wrong
>    type entry to them.  E.g. the current code cannot detect an error
>    when we add a sd_node entry to the sd_vnode tree, but this patch
>    enables us to dectect it.
> 
>  - we don't need to specify a type name, a member name, nor a
>    comparison function to list/rbtree macros any more.  E.g.
> 
>    [before]
>       list_first_entry(head, type, member);
> 
>       list_add(&entry->member, head);
> 
>       list_for_each_entry(entry, head, member) {
>       }
> 
>       rb_insert(root, entry, member, cmp_func);
> 
>       rb_erase(&entry->member, root);
> 
>    [after]
>       list_first_entry(head);
> 
>       list_add(entry, head);
> 
>       list_for_each_entry(entry, head) {
>       }
> 
>       rb_insert(entry, root);
> 
>       rb_erase(entry, root);
> 
> The changes with this series is not so small, but very systematic.  If
> what this series tries to do looks good to the developers, I'll add a
> documentation for each list/rbtree macro definition and send it as a
> v2 series.
> 

Looks good to me but 3/3 can't patch cleanly.

Thanks
Yuan



More information about the sheepdog mailing list