bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Dylan Cali <calid1984@gmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: bug-gnulib@gnu.org
Subject: Re: compile warnings when including avltree-list and gcc-warnings is enabled
Date: Sat, 6 Sep 2014 02:05:54 -0500	[thread overview]
Message-ID: <CAM1XmN9E0M0TY8N7_uWaZS4=b0gt3s0i83jDPn9ctpmu5wMFcA@mail.gmail.com> (raw)
In-Reply-To: <5409DBEA.8010006@cs.ucla.edu>

[-- Attachment #1: Type: text/plain, Size: 850 bytes --]

On Fri, Sep 5, 2014 at 10:51 AM, Paul Eggert <eggert@cs.ucla.edu> wrote:
> Thanks, it looks like some declarations are missing in the corresponding .h
> file, or are missing attributes that they should have.  Is that something
> you could write a patch for?

Hi Paul,

Attached is a patch for the attribute and declaration warnings.  After
fixing those the next warning that popped up is:

lib/gl_avltree_list.c: In function 'gl_avltree_list_check_invariants':
lib/gl_avltree_list.c:66:5: error: statement with no effect
[-Werror=unused-value]
     check_invariants (list->root, NULL);
     ^

I'm not sure how to proceed with this one.  It seems gcc is just
confused (the statement definitely has an effect as that function
aborts if the checks fail).  Would it be appropriate to add a pragma
to ignore the warning for that function?

Thanks,
Dylan

[-- Attachment #2: fix-attr-declaration-warnings.patch --]
[-- Type: text/x-patch, Size: 3797 bytes --]

From b47d780b903b4ea1fcc4421c605dc2c0978c4c3c Mon Sep 17 00:00:00 2001
From: Dylan Cali <calid1984@gmail.com>
Date: Sat, 6 Sep 2014 01:52:31 -0500
Subject: [PATCH] build: fix attribute and declaration warnings

* tests/test-avltree_list.c: Remove gl_avltree_list_check_invariants
declaration
* lib/gl_avltree_list.h: Add gl_avltree_list_check_invariants
declaration from test-avltree_list.c
* lib/gl_avltree_list.c: (check_invariants): Add pure attribute
(gl_avltree_list_check_invariants): Add const attribute
* lib/gl_anytree_list2.h: Add pure attribute to (gl_tree_node_value),
(gl_tree_next_node), (gl_tree_previous_node), (node_at),
(gl_tree_get_at)
---
 lib/gl_anytree_list2.h    | 10 +++++-----
 lib/gl_avltree_list.c     |  4 ++--
 lib/gl_avltree_list.h     |  1 +
 tests/test-avltree_list.c |  2 --
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/lib/gl_anytree_list2.h b/lib/gl_anytree_list2.h
index 70e59a5..05fde15 100644
--- a/lib/gl_anytree_list2.h
+++ b/lib/gl_anytree_list2.h
@@ -59,7 +59,7 @@ gl_tree_size (gl_list_t list)
   return (list->root != NULL ? list->root->branch_size : 0);
 }
 
-static const void *
+static const void * _GL_ATTRIBUTE_PURE
 gl_tree_node_value (gl_list_t list, gl_list_node_t node)
 {
   return node->value;
@@ -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;
diff --git a/lib/gl_avltree_list.c b/lib/gl_avltree_list.c
index 1afe5ca..31ed334 100644
--- a/lib/gl_avltree_list.c
+++ b/lib/gl_avltree_list.c
@@ -37,7 +37,7 @@
 #include "gl_anytree_list2.h"
 
 /* For debugging.  */
-static unsigned int
+static unsigned int _GL_ATTRIBUTE_PURE
 check_invariants (gl_list_node_t node, gl_list_node_t parent)
 {
   unsigned int left_height =
@@ -59,7 +59,7 @@ 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)
diff --git a/lib/gl_avltree_list.h b/lib/gl_avltree_list.h
index 7f09ff3..e8300f1 100644
--- a/lib/gl_avltree_list.h
+++ b/lib/gl_avltree_list.h
@@ -24,6 +24,7 @@
 extern "C" {
 #endif
 
+extern void gl_avltree_list_check_invariants (gl_list_t list);
 extern const struct gl_list_implementation gl_avltree_list_implementation;
 #define GL_AVLTREE_LIST &gl_avltree_list_implementation
 
diff --git a/tests/test-avltree_list.c b/tests/test-avltree_list.c
index 1c0331a..c877c09 100644
--- a/tests/test-avltree_list.c
+++ b/tests/test-avltree_list.c
@@ -25,8 +25,6 @@
 #include "progname.h"
 #include "macros.h"
 
-extern void gl_avltree_list_check_invariants (gl_list_t list);
-
 static const char *objects[15] =
   {
     "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o"
-- 
2.1.0


  parent reply	other threads:[~2014-09-06  7:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-05 14:37 compile warnings when including avltree-list and gcc-warnings is enabled Dylan Cali
2014-09-05 15:51 ` Paul Eggert
2014-09-05 16:11   ` Dylan Cali
2014-09-06  7:05   ` Dylan Cali [this message]
2014-09-07  0:30     ` Paul Eggert
2014-09-07  1:42       ` Dylan Cali
2014-09-08 14:27         ` Eric Blake
2014-09-08 15:04           ` Dylan Cali
2014-09-08 23:09             ` Dylan Cali
2014-09-16 16:05               ` Pádraig Brady
2019-09-29 14:39                 ` Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAM1XmN9E0M0TY8N7_uWaZS4=b0gt3s0i83jDPn9ctpmu5wMFcA@mail.gmail.com' \
    --to=calid1984@gmail.com \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).