]> Savannah Git Hosting - gnulib.git/commitdiff
avltree-list: avoid compiler warnings
authorDylan Cali <calid1984@gmail.com>
Tue, 16 Sep 2014 15:42:36 +0000 (16:42 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 16 Sep 2014 16:03:00 +0000 (17:03 +0100)
* lib/gl_anytree_list2.h: Add _GL_ATTRIBUTE_PURE to avoid
-Werror=suggest-attribute=pure.
* lib/gl_array_list.c: Likewise.
* lib/gl_avltree_list.c (gl_avltree_list_check_invariants): Add extern
declaration to avoid -Werror=missing-prototypes.  This is not added
to a header as only exported for tests.  Add (void) to the
check_invariants() call to indicate we're discarding the result
in this context which avoids -Werror=unused-value.  Note we don't
use ignore_value here to avoid a dependency as we know we'll not
be adding __attribute__((warn_unused_result)) to check_invariants().
Add _GL_ATTRIBUTE_CONST to avoid -Werror=suggest-attribute=const.

ChangeLog
lib/gl_anytree_list2.h
lib/gl_array_list.c
lib/gl_avltree_list.c

index 689d21b88de6bc663ef35751b38e9152bd0888fd..fbdc9030466560ea6789b13cd7249abbb95efa9a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2014-09-16  Dylan Cali  <calid1984@gmail.com>
+
+       avltree-list: avoid compiler warnings (trivial)
+       * lib/gl_anytree_list2.h: Add _GL_ATTRIBUTE_PURE to avoid
+       -Werror=suggest-attribute=pure.
+       * lib/gl_array_list.c: Likewise.
+       * lib/gl_avltree_list.c (gl_avltree_list_check_invariants): Add extern
+       declaration to avoid -Werror=missing-prototypes.  This is not added
+       to a header as only exported for tests.  Add (void) to the
+       check_invariants() call to indicate we're discarding the result
+       in this context which avoids -Werror=unused-value.  Note we don't
+       use ignore_value here to avoid a dependency as we know we'll not
+       be adding __attribute__((warn_unused_result)) to check_invariants().
+       Add _GL_ATTRIBUTE_CONST to avoid -Werror=suggest-attribute=const.
+
 2014-09-15  Paul Eggert  <eggert@cs.ucla.edu>
 
        qsort_r: new module, for GNU-style qsort_r
index 70e59a58c356b424922579280ac5b815ffce495b..cf4280e5fd91e7ed93fbeb343841c144c145ce19 100644 (file)
@@ -100,7 +100,7 @@ gl_tree_node_nx_set_value (gl_list_t list, gl_list_node_t node, const void *elt)
   return 0;
 }
 
-static gl_list_node_t
+static gl_list_node_t _GL_ATTRIBUTE_PURE
 gl_tree_next_node (gl_list_t list, gl_list_node_t node)
 {
   if (node->right != NULL)
@@ -118,7 +118,7 @@ gl_tree_next_node (gl_list_t list, gl_list_node_t node)
   return node;
 }
 
-static gl_list_node_t
+static gl_list_node_t _GL_ATTRIBUTE_PURE
 gl_tree_previous_node (gl_list_t list, gl_list_node_t node)
 {
   if (node->left != NULL)
@@ -137,7 +137,7 @@ gl_tree_previous_node (gl_list_t list, gl_list_node_t node)
 }
 
 /* Return the node at the given position < gl_tree_size (list).  */
-static gl_list_node_t
+static gl_list_node_t _GL_ATTRIBUTE_PURE
 node_at (gl_list_node_t root, size_t position)
 {
   /* Here we know that root != NULL.  */
@@ -162,7 +162,7 @@ node_at (gl_list_node_t root, size_t position)
   return node;
 }
 
-static const void *
+static const void * _GL_ATTRIBUTE_PURE
 gl_tree_get_at (gl_list_t list, size_t position)
 {
   gl_list_node_t node = list->root;
index b61b6cae26658c651392da3216da65d7a81dafe1..3220dd83aaa7918894f6c3e5b4b4a9ad2cb67d03 100644 (file)
@@ -120,7 +120,7 @@ gl_array_size (gl_list_t list)
   return list->count;
 }
 
-static const void *
+static const void * _GL_ATTRIBUTE_PURE
 gl_array_node_value (gl_list_t list, gl_list_node_t node)
 {
   uintptr_t index = NODE_TO_INDEX (node);
@@ -142,7 +142,7 @@ gl_array_node_nx_set_value (gl_list_t list, gl_list_node_t node,
   return 0;
 }
 
-static gl_list_node_t
+static gl_list_node_t _GL_ATTRIBUTE_PURE
 gl_array_next_node (gl_list_t list, gl_list_node_t node)
 {
   uintptr_t index = NODE_TO_INDEX (node);
@@ -156,7 +156,7 @@ gl_array_next_node (gl_list_t list, gl_list_node_t node)
     return NULL;
 }
 
-static gl_list_node_t
+static gl_list_node_t _GL_ATTRIBUTE_PURE
 gl_array_previous_node (gl_list_t list, gl_list_node_t node)
 {
   uintptr_t index = NODE_TO_INDEX (node);
@@ -169,7 +169,7 @@ gl_array_previous_node (gl_list_t list, gl_list_node_t node)
     return NULL;
 }
 
-static const void *
+static const void * _GL_ATTRIBUTE_PURE
 gl_array_get_at (gl_list_t list, size_t position)
 {
   size_t count = list->count;
index 1afe5caad5ad24f6e7ef1c4f52609aea6698c3af..1ca4bccda3255a82184e01e637562f34f542e3e0 100644 (file)
@@ -37,7 +37,9 @@
 #include "gl_anytree_list2.h"
 
 /* For debugging.  */
-static unsigned int
+extern void gl_avltree_list_check_invariants (gl_list_t list);
+
+static unsigned int _GL_ATTRIBUTE_PURE
 check_invariants (gl_list_node_t node, gl_list_node_t parent)
 {
   unsigned int left_height =
@@ -59,11 +61,12 @@ check_invariants (gl_list_node_t node, gl_list_node_t parent)
 
   return 1 + (left_height > right_height ? left_height : right_height);
 }
-void
+
+void _GL_ATTRIBUTE_CONST
 gl_avltree_list_check_invariants (gl_list_t list)
 {
   if (list->root != NULL)
-    check_invariants (list->root, NULL);
+    (void) check_invariants (list->root, NULL);
 }
 
 const struct gl_list_implementation gl_avltree_list_implementation =