bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: list: fix GCC warnings


From: Bruno Haible
Subject: Re: list: fix GCC warnings
Date: Sun, 31 May 2020 11:28:11 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; )

Hi Akim,

Thanks for caring about these warnings.

>     * lib/gl_anytree_list2.h (gl_tree_iterator_free)
>     (gl_tree_next_node, gl_tree_node_nx_set_value)
>     (gl_tree_previous_node, gl_tree_next_node):
>     Mark unused arguments.
>     * lib/gl_anytree_oset.h (gl_tree_iterator_free): Likewise.
>     * lib/gl_anylinked_list2.h (gl_linked_node_value)
>     (gl_linked_node_nx_set_value, gl_linked_iterator_free): Likewise.

This part looks good.

>     * lib/gl_anytreehash_list2.h (gl_tree_search_from_to): Avoid using
>     the same variable name in nested scopes.

'p' is a poor variable name here. Please, can use you 'nodes_elt' instead?

> static int
> gl_linked_node_nx_set_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
>                              gl_list_node_t node,
>                              const void *elt)
> {
> #if WITH_HASHTABLE
>   if (elt != node->value)
>     {
>       size_t new_hashcode =
>         (list->base.hashcode_fn != NULL
>          ? list->base.hashcode_fn (elt)
>          : (size_t)(uintptr_t) elt);
> ...
>     }
> #else
>   node->value = elt;
> #endif
>   return 0;
> }
> 
> I don't think the MAYBE_UNUSED attribute may harm in any way, but if we
> want to avoid that, the simplest would probably be to move the #if outside
> and implement the function twice.

Better use _GL_ATTRIBUTE_MAYBE_UNUSED. Implementing the function twice means
  - duplicating the parameter list,
  - having no proper place for attaching a comment to the function.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]