[PATCH] jffs, clang: avoid some warnings of used uninitialized ptr

Daniel Hellstrom daniel at gaisler.com
Fri Oct 5 07:38:24 UTC 2018


On 2018-10-05 09:34, Sebastian Huber wrote:
> On 05/10/2018 09:25, Daniel Hellstrom wrote:
>> On 2018-10-05 09:12, Sebastian Huber wrote:
>>> On 05/10/2018 08:57, Daniel Hellstrom wrote:
>>>> This fixes the following test failures on LEON3 UP/SMP when
>>>> built using clang compiler:
>>>>   * fsjffs2gc01
>>>>   * jffs2_fserror
>>>>   * jffs2_fspermission
>>>>   * jffs2_fsrdwr
>>>>   * jffs2_fstime
>>>
>>> The problem is probably in the 
>>> rbtree_postorder_for_each_entry_safe(). Coverity Scan has also an 
>>> issue with this macro. It is on my todo list. Please do not check in 
>>> this patch.
>> Ok I will not push it. Yes I was also thinking so. To use offsetof() 
>> macro could be an option maybe, however the node type input is not 
>> known to the rbtree_postorder_for_each_entry_safe() function even 
>> though it only used from jffs2 code. 
>
> The Linux code uses typeof. We could do this also:
>
> diff --git a/cpukit/include/linux/rbtree.h 
> b/cpukit/include/linux/rbtree.h
> index 53c777e8c1..8fc575240f 100644
> --- a/cpukit/include/linux/rbtree.h
> +++ b/cpukit/include/linux/rbtree.h
> @@ -126,12 +126,12 @@ static inline struct rb_node *rb_parent( struct 
> rb_node *node )
>    for ( \
>      node = _RBTree_Postorder_first( \
>        (RBTree_Control *) root, \
> -      (size_t) ( (char *) &node->field - (char *) node ) \
> +      offsetof( __typeof__( *node ), field ) \
>      ); \
>      node != NULL && ( \
>        next = _RBTree_Postorder_next( \
>          &node->field, \
> -        (size_t) ( (char *) &node->field - (char *) node ) \
> +        offsetof( __typeof__( *node ), field ) \
>        ), \
>        node != NULL \
>      ); \
>
> It shouldn't be a big problem since at least GCC and clang supports 
> it. It is also a standard C++ operator. It is already used in
>
> cpukit/libfs/src/jffs2/include/linux/list.h

Ok, I will give it a try.




More information about the devel mailing list