bug-gnulib
[Top][All Lists]
Advanced

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

Re: list: fix GCC warnings


From: Akim Demaille
Subject: Re: list: fix GCC warnings
Date: Sun, 31 May 2020 12:43:53 +0200


> Le 31 mai 2020 à 11:28, Bruno Haible <bruno@clisp.org> a écrit :
> 
> Hi Akim,
> 
> Thanks for caring about these warnings.

Sure!

>>    * 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?

Good with me.

>> 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.

Very much agreed.  Installed as follows.

Cheers!

commit d8a8fb3423499851bf06aac2302112944a276f97
Author: Akim Demaille <akim.demaille@gmail.com>
Date:   Sun May 31 08:59:25 2020 +0200

    list: fix GCC 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.
    
    * lib/gl_anytreehash_list2.h (gl_tree_search_from_to): Avoid using
    the same variable name in nested scopes.

diff --git a/ChangeLog b/ChangeLog
index 321d5e28c..5ef05e037 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2020-05-31  Akim Demaille  <akim@lrde.epita.fr>
+
+       list: fix GCC 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.
+
+       * lib/gl_anytreehash_list2.h (gl_tree_search_from_to): Avoid using
+       the same variable name in nested scopes.
+
 2020-05-31  Bruno Haible  <bruno@clisp.org>
 
        list-c++, set-c++, oset-c++, map-c++, omap-c++: Don't fool the compiler.
diff --git a/lib/gl_anylinked_list2.h b/lib/gl_anylinked_list2.h
index 114106c7d..3e01f8fa0 100644
--- a/lib/gl_anylinked_list2.h
+++ b/lib/gl_anylinked_list2.h
@@ -76,11 +76,11 @@ gl_linked_nx_create_empty (gl_list_implementation_t 
implementation,
 
 static gl_list_t
 gl_linked_nx_create (gl_list_implementation_t implementation,
-                  gl_listelement_equals_fn equals_fn,
-                  gl_listelement_hashcode_fn hashcode_fn,
-                  gl_listelement_dispose_fn dispose_fn,
-                  bool allow_duplicates,
-                  size_t count, const void **contents)
+                     gl_listelement_equals_fn equals_fn,
+                     gl_listelement_hashcode_fn hashcode_fn,
+                     gl_listelement_dispose_fn dispose_fn,
+                     bool allow_duplicates,
+                     size_t count, const void **contents)
 {
   struct gl_list_impl *list =
     (struct gl_list_impl *) malloc (sizeof (struct gl_list_impl));
@@ -170,13 +170,15 @@ gl_linked_size (gl_list_t list)
 }
 
 static const void * _GL_ATTRIBUTE_PURE
-gl_linked_node_value (gl_list_t list, gl_list_node_t node)
+gl_linked_node_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
+                      gl_list_node_t node)
 {
   return node->value;
 }
 
 static int
-gl_linked_node_nx_set_value (gl_list_t list, gl_list_node_t node,
+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
@@ -1021,7 +1023,7 @@ gl_linked_iterator_next (gl_list_iterator_t *iterator,
 }
 
 static void
-gl_linked_iterator_free (gl_list_iterator_t *iterator)
+gl_linked_iterator_free (gl_list_iterator_t *iterator 
_GL_ATTRIBUTE_MAYBE_UNUSED)
 {
 }
 
diff --git a/lib/gl_anytree_list2.h b/lib/gl_anytree_list2.h
index c5a67dbd0..939b79748 100644
--- a/lib/gl_anytree_list2.h
+++ b/lib/gl_anytree_list2.h
@@ -60,13 +60,15 @@ gl_tree_size (gl_list_t list)
 }
 
 static const void *
-gl_tree_node_value (gl_list_t list, gl_list_node_t node)
+gl_tree_node_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
+                    gl_list_node_t node)
 {
   return node->value;
 }
 
 static int
-gl_tree_node_nx_set_value (gl_list_t list, gl_list_node_t node, const void 
*elt)
+gl_tree_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)
@@ -101,7 +103,8 @@ gl_tree_node_nx_set_value (gl_list_t list, gl_list_node_t 
node, const void *elt)
 }
 
 static gl_list_node_t _GL_ATTRIBUTE_PURE
-gl_tree_next_node (gl_list_t list, gl_list_node_t node)
+gl_tree_next_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
+                   gl_list_node_t node)
 {
   if (node->right != NULL)
     {
@@ -119,7 +122,8 @@ gl_tree_next_node (gl_list_t list, gl_list_node_t node)
 }
 
 static gl_list_node_t _GL_ATTRIBUTE_PURE
-gl_tree_previous_node (gl_list_t list, gl_list_node_t node)
+gl_tree_previous_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
+                       gl_list_node_t node)
 {
   if (node->left != NULL)
     {
@@ -628,7 +632,7 @@ gl_tree_iterator_next (gl_list_iterator_t *iterator,
 }
 
 static void
-gl_tree_iterator_free (gl_list_iterator_t *iterator)
+gl_tree_iterator_free (gl_list_iterator_t *iterator  
_GL_ATTRIBUTE_MAYBE_UNUSED)
 {
 }
 
diff --git a/lib/gl_anytree_oset.h b/lib/gl_anytree_oset.h
index e837f6324..d737e313d 100644
--- a/lib/gl_anytree_oset.h
+++ b/lib/gl_anytree_oset.h
@@ -292,6 +292,6 @@ gl_tree_iterator_next (gl_oset_iterator_t *iterator, const 
void **eltp)
 }
 
 static void
-gl_tree_iterator_free (gl_oset_iterator_t *iterator)
+gl_tree_iterator_free (gl_oset_iterator_t *iterator  
_GL_ATTRIBUTE_MAYBE_UNUSED)
 {
 }
diff --git a/lib/gl_anytreehash_list2.h b/lib/gl_anytreehash_list2.h
index 69e6776b0..26e52bf38 100644
--- a/lib/gl_anytreehash_list2.h
+++ b/lib/gl_anytreehash_list2.h
@@ -61,13 +61,13 @@ gl_tree_search_from_to (gl_list_t list, size_t start_index, 
size_t end_index,
                         {
                           /* We have to return only the one at the minimal
                              position >= start_index.  */
-                          const void *elt;
+                          const void *nodes_elt;
                           if (gl_oset_search_atleast (nodes,
                                                       
compare_position_threshold,
                                                       (void 
*)(uintptr_t)start_index,
-                                                      &elt))
+                                                      &nodes_elt))
                             {
-                              node = (gl_list_node_t) elt;
+                              node = (gl_list_node_t) nodes_elt;
                               if (end_index == list->root->branch_size
                                   || node_position (node) < end_index)
                                 return node;




reply via email to

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