comparison lib/gl_array_list.c @ 17761:af887cfa71dd

avltree-list: avoid compiler warnings * 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.
author Dylan Cali <calid1984@gmail.com>
date Tue, 16 Sep 2014 16:42:36 +0100
parents 344018b6e5d7
children ab58d4870664
comparison
equal deleted inserted replaced
17760:628a5850eee1 17761:af887cfa71dd
118 gl_array_size (gl_list_t list) 118 gl_array_size (gl_list_t list)
119 { 119 {
120 return list->count; 120 return list->count;
121 } 121 }
122 122
123 static const void * 123 static const void * _GL_ATTRIBUTE_PURE
124 gl_array_node_value (gl_list_t list, gl_list_node_t node) 124 gl_array_node_value (gl_list_t list, gl_list_node_t node)
125 { 125 {
126 uintptr_t index = NODE_TO_INDEX (node); 126 uintptr_t index = NODE_TO_INDEX (node);
127 if (!(index < list->count)) 127 if (!(index < list->count))
128 /* Invalid argument. */ 128 /* Invalid argument. */
140 abort (); 140 abort ();
141 list->elements[index] = elt; 141 list->elements[index] = elt;
142 return 0; 142 return 0;
143 } 143 }
144 144
145 static gl_list_node_t 145 static gl_list_node_t _GL_ATTRIBUTE_PURE
146 gl_array_next_node (gl_list_t list, gl_list_node_t node) 146 gl_array_next_node (gl_list_t list, gl_list_node_t node)
147 { 147 {
148 uintptr_t index = NODE_TO_INDEX (node); 148 uintptr_t index = NODE_TO_INDEX (node);
149 if (!(index < list->count)) 149 if (!(index < list->count))
150 /* Invalid argument. */ 150 /* Invalid argument. */
154 return INDEX_TO_NODE (index); 154 return INDEX_TO_NODE (index);
155 else 155 else
156 return NULL; 156 return NULL;
157 } 157 }
158 158
159 static gl_list_node_t 159 static gl_list_node_t _GL_ATTRIBUTE_PURE
160 gl_array_previous_node (gl_list_t list, gl_list_node_t node) 160 gl_array_previous_node (gl_list_t list, gl_list_node_t node)
161 { 161 {
162 uintptr_t index = NODE_TO_INDEX (node); 162 uintptr_t index = NODE_TO_INDEX (node);
163 if (!(index < list->count)) 163 if (!(index < list->count))
164 /* Invalid argument. */ 164 /* Invalid argument. */
167 return INDEX_TO_NODE (index - 1); 167 return INDEX_TO_NODE (index - 1);
168 else 168 else
169 return NULL; 169 return NULL;
170 } 170 }
171 171
172 static const void * 172 static const void * _GL_ATTRIBUTE_PURE
173 gl_array_get_at (gl_list_t list, size_t position) 173 gl_array_get_at (gl_list_t list, size_t position)
174 { 174 {
175 size_t count = list->count; 175 size_t count = list->count;
176 176
177 if (!(position < count)) 177 if (!(position < count))