bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: Akim Demaille <akim.demaille@gmail.com>
Subject: Re: list: fix GCC warnings
Date: Sun, 31 May 2020 11:28:11 +0200	[thread overview]
Message-ID: <2524825.qb9ItadjnO@omega> (raw)
In-Reply-To: <B6F404EA-D016-4B5B-A813-73932A16B5B3@gmail.com>

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	other threads:[~2020-05-31  9:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31  7:05 list: fix GCC warnings Akim Demaille
2020-05-31  9:28 ` Bruno Haible [this message]
2020-05-31 10:43   ` Akim Demaille

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=2524825.qb9ItadjnO@omega \
    --to=bruno@clisp.org \
    --cc=akim.demaille@gmail.com \
    --cc=bug-gnulib@gnu.org \
    /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).