1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-09-01 02:34:55 +00:00

gnulib-common: update for C2x 2020-12-11 draft

Use blessed-by-draft-standard way to test for [[__deprecated__]]
etc.; this is supported by GCC 11 and the fallback code should
work fine with GCC 10 and earlier, clang, etc.
* NEWS, doc/attribute.texi:
Mention that DEPRECATED etc. must now come first.
* lib/fflush.c, lib/unistr.in.h:
Do not include unused-parameter.h.  All uses of _GL_UNUSED_PARAMETER
(after parameters) replaced by _GL_ATTRIBUTE_MAYBE_UNUSED (before
parameters).  Although perhaps we need a shorter name for
_GL_ATTRIBUTE_MAYBE_UNUSED, that should probably be in
gnulib-common.m4, due to the ubiquity of this issue.
And perhaps the snippet/unused-parameter module should be marked
obsolete since it's no longer compatible with its old use.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macro
_GL_HAS_C_ATTRIBUTE, and use it instead of __STDC_VERSION__ in
deciding whether to use C2x attributes like [[__deprecated__]].
(_GL_ATTRIBUTE_MAYBE_UNUSED): Fall back on _GL_ATTRIBUTE_UNUSED.
(_GL_ATTRIBUTE_UNUSED): New macro, for labels where C2x
[[maybe_unused]] do not work.
(_GL_UNUSED, _GL_UNUSED_LABEL): Use it.
* modules/fflush, modules/unistr/base (Depends-on):
Remove snippet/unused-parameter.
* modules/fflush (selinux/selinux.h, selinux/context.h)
(selinux/label.h): Do not use $(UNUSED_PARAMETER).
Remove useless chmod a-x.
This commit is contained in:
Paul Eggert
2021-07-30 12:56:24 -07:00
parent c44470fb95
commit 786bb6fb17
40 changed files with 248 additions and 212 deletions
+8
View File
@@ -1,5 +1,13 @@
2021-07-30 Paul Eggert <eggert@cs.ucla.edu>
gnulib-common: update for C2x 2020-12-11 draft
Use blessed-by-draft-standard way to test for [[__deprecated__]]
etc.; this is supported by GCC 11 and the fallback code should
work fine with GCC 10 and earlier.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macro
_GL_HAS_C_ATTRIBUTE, and use it instead of __STDC_VERSION__ in
deciding whether to use C2x attributes like [[__deprecated__]].
manywarnings: document GCC 11 warnings
* build-aux/gcc-warning.spec: Add warnings introduced in GCC 11.
None of them require Gnulib code changes, so this is just
+9
View File
@@ -66,6 +66,15 @@ User visible incompatible changes
Date Modules Changes
2021-07-29 (all) Due to draft C2x, the following attributes should
now appear at the start of a function declaration:
_GL_ATTRIBUTE_DEPRECATED
_GL_ATTRIBUTE_MAYBE_UNUSED
_GL_ATTRIBUTE_NODISCARD
attribute Likewise for DEPRECATED, MAYBE_UNUSED, NODISCARD.
snippet/unused-parameter
Likewise for _GL_UNUSED_PARAMETER.
2021-07-01 largefile AC_SYS_LARGEFILE now also arranges for time_t
to be 64-bit on 32-bit GNU/Linux platforms
that support it (glibc 2.34 or later).
+8
View File
@@ -23,11 +23,16 @@ Here is an example of its use:
@example
#include <attribute.h>
NODISCARD
extern char *crypt (char const *, char const *)
ATTRIBUTE_NOTHROW ATTRIBUTE_LEAF ATTRIBUTE_NONNULL ((1, 2));
@end example
@noindent
@code{NODISCARD} expands to @code{[[nodiscard]]} if the compiler
supports this C2X syntax, otherwise to
@code{__attribute__ ((__warn_unused_result__))} if the compiler
is a recent-enough GCC or GCC-like compiler, otherwise to nothing.
@code{ATTRIBUTE_NOTHROW} expands to @code{__attribute__
((__nothrow__))} if the compiler is a recent-enough GCC or GCC-like
compiler, and to nothing otherwise. Similarly for
@@ -41,3 +46,6 @@ names are not likely to clash with other macro names.
These macros are @code{DEPRECATED}, @code{FALLTHROUGH},
@code{MAYBE_UNUSED}, and @code{NODISCARD}, which can
be defined to @code{[[deprecated]]} etc.@: on C2X platforms.
Also, these exceptional macros should be placed at the start of
function declarations, whereas the @code{ATTRIBUTE_*} macros can be
placed at the end.
+1 -1
View File
@@ -32,7 +32,7 @@
INT_BUFSIZE_BOUND (INTTYPE) bytes long. Return the address of the
printable string, which need not start at BUF. */
char * _GL_ATTRIBUTE_NODISCARD
_GL_ATTRIBUTE_NODISCARD char *
anytostr (inttype i, char *buf)
{
char *p = buf + INT_STRLEN_BOUND (inttype);
+1 -1
View File
@@ -94,7 +94,7 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
specified by ATTR. For variable size bitsets, N_BITS is only a
hint and may be zero. */
enum bitset_type
bitset_type_choose (bitset_bindex n_bits MAYBE_UNUSED, unsigned attr)
bitset_type_choose (MAYBE_UNUSED bitset_bindex n_bits, unsigned attr)
{
/* Check attributes. */
if (attr & BITSET_FIXED && attr & BITSET_VARIABLE)
+5 -5
View File
@@ -84,7 +84,7 @@ abitset_small_list (bitset src, bitset_bindex *list,
/* Set bit BITNO in bitset DST. */
static void
abitset_set (bitset dst MAYBE_UNUSED, bitset_bindex bitno MAYBE_UNUSED)
abitset_set (MAYBE_UNUSED bitset dst, MAYBE_UNUSED bitset_bindex bitno)
{
/* This should never occur for abitsets since we should always hit
the cache. It is likely someone is trying to access outside the
@@ -95,8 +95,8 @@ abitset_set (bitset dst MAYBE_UNUSED, bitset_bindex bitno MAYBE_UNUSED)
/* Reset bit BITNO in bitset DST. */
static void
abitset_reset (bitset dst MAYBE_UNUSED,
bitset_bindex bitno MAYBE_UNUSED)
abitset_reset (MAYBE_UNUSED bitset dst,
MAYBE_UNUSED bitset_bindex bitno)
{
/* This should never occur for abitsets since we should always hit
the cache. It is likely someone is trying to access outside the
@@ -106,8 +106,8 @@ abitset_reset (bitset dst MAYBE_UNUSED,
/* Test bit BITNO in bitset SRC. */
static bool
abitset_test (bitset src MAYBE_UNUSED,
bitset_bindex bitno MAYBE_UNUSED)
abitset_test (MAYBE_UNUSED bitset src,
MAYBE_UNUSED bitset_bindex bitno)
{
/* This should never occur for abitsets since we should always
hit the cache. */
+2 -2
View File
@@ -1229,7 +1229,7 @@ struct bitset_vtable lbitset_vtable = {
/* Return size of initial structure. */
size_t
lbitset_bytes (bitset_bindex n_bits MAYBE_UNUSED)
lbitset_bytes (MAYBE_UNUSED bitset_bindex n_bits)
{
return sizeof (struct lbitset_struct);
}
@@ -1237,7 +1237,7 @@ lbitset_bytes (bitset_bindex n_bits MAYBE_UNUSED)
/* Initialize a bitset. */
bitset
lbitset_init (bitset bset, bitset_bindex n_bits MAYBE_UNUSED)
lbitset_init (bitset bset, MAYBE_UNUSED bitset_bindex n_bits)
{
BITSET_NBITS_ (bset) = n_bits;
bset->b.vtable = &lbitset_vtable;
+1 -1
View File
@@ -208,7 +208,7 @@ bitset_stats_print_1 (FILE *file, const char *name,
/* Print all bitset statistics to FILE. */
static void
bitset_stats_print (FILE *file, bool verbose MAYBE_UNUSED)
bitset_stats_print (FILE *file, MAYBE_UNUSED bool verbose)
{
if (!bitset_stats_info)
return;
+1 -1
View File
@@ -1132,7 +1132,7 @@ struct bitset_vtable tbitset_vtable = {
/* Return size of initial structure. */
size_t
tbitset_bytes (bitset_bindex n_bits MAYBE_UNUSED)
tbitset_bytes (MAYBE_UNUSED bitset_bindex n_bits)
{
return sizeof (struct tbitset_struct);
}
+4 -4
View File
@@ -126,7 +126,7 @@ vbitset_set (bitset dst, bitset_bindex bitno)
/* Reset bit BITNO in bitset DST. */
static void
vbitset_reset (bitset dst MAYBE_UNUSED, bitset_bindex bitno MAYBE_UNUSED)
vbitset_reset (MAYBE_UNUSED bitset dst, MAYBE_UNUSED bitset_bindex bitno)
{
/* We must be accessing outside the cache so the bit is
zero anyway. */
@@ -135,8 +135,8 @@ vbitset_reset (bitset dst MAYBE_UNUSED, bitset_bindex bitno MAYBE_UNUSED)
/* Test bit BITNO in bitset SRC. */
static bool
vbitset_test (bitset src MAYBE_UNUSED,
bitset_bindex bitno MAYBE_UNUSED)
vbitset_test (MAYBE_UNUSED bitset src,
MAYBE_UNUSED bitset_bindex bitno)
{
/* We must be accessing outside the cache so the bit is
zero anyway. */
@@ -964,7 +964,7 @@ struct bitset_vtable vbitset_vtable = {
size_t
vbitset_bytes (bitset_bindex n_bits MAYBE_UNUSED)
vbitset_bytes (MAYBE_UNUSED bitset_bindex n_bits)
{
return sizeof (struct vbitset_struct);
}
+2 -4
View File
@@ -28,8 +28,6 @@
#include "stdio-impl.h"
#include "unused-parameter.h"
#undef fflush
@@ -96,8 +94,8 @@ restore_seek_optimization (FILE *fp, int saved_flags)
# else
static void
update_fpos_cache (FILE *fp _GL_UNUSED_PARAMETER,
off_t pos _GL_UNUSED_PARAMETER)
update_fpos_cache (_GL_ATTRIBUTE_MAYBE_UNUSED FILE *fp,
_GL_ATTRIBUTE_MAYBE_UNUSED off_t pos)
{
# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
+13 -4
View File
@@ -250,12 +250,21 @@ typedef struct _ftsent {
} FTSENT;
__BEGIN_DECLS
FTSENT *fts_children (FTS *, int) __THROW _GL_ATTRIBUTE_NODISCARD;
int fts_close (FTS *) __THROW _GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
FTSENT *fts_children (FTS *, int) __THROW;
_GL_ATTRIBUTE_NODISCARD
int fts_close (FTS *) __THROW;
_GL_ATTRIBUTE_NODISCARD
FTS *fts_open (char * const *, int,
int (*)(const FTSENT **, const FTSENT **))
__THROW _GL_ATTRIBUTE_NODISCARD;
FTSENT *fts_read (FTS *) __THROW _GL_ATTRIBUTE_NODISCARD;
__THROW;
_GL_ATTRIBUTE_NODISCARD
FTSENT *fts_read (FTS *) __THROW;
int fts_set (FTS *, FTSENT *, int) __THROW;
__END_DECLS
+3 -3
View File
@@ -170,14 +170,14 @@ gl_linked_size (gl_list_t list)
}
static const void * _GL_ATTRIBUTE_PURE
gl_linked_node_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
gl_linked_node_value (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
gl_list_node_t node)
{
return node->value;
}
static int
gl_linked_node_nx_set_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
gl_linked_node_nx_set_value (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
gl_list_node_t node,
const void *elt)
{
@@ -1041,7 +1041,7 @@ gl_linked_iterator_next (gl_list_iterator_t *iterator,
}
static void
gl_linked_iterator_free (gl_list_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
gl_linked_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator)
{
}
+7 -7
View File
@@ -60,14 +60,14 @@ gl_tree_size (gl_list_t list)
}
static const void * _GL_ATTRIBUTE_PURE
gl_tree_node_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
gl_tree_node_value (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
gl_list_node_t node)
{
return node->value;
}
static int
gl_tree_node_nx_set_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
gl_tree_node_nx_set_value (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
gl_list_node_t node, const void *elt)
{
#if WITH_HASHTABLE
@@ -103,7 +103,7 @@ gl_tree_node_nx_set_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
}
static gl_list_node_t _GL_ATTRIBUTE_PURE
gl_tree_next_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
gl_tree_next_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
gl_list_node_t node)
{
if (node->right != NULL)
@@ -122,7 +122,7 @@ gl_tree_next_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
}
static gl_list_node_t _GL_ATTRIBUTE_PURE
gl_tree_previous_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
gl_tree_previous_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
gl_list_node_t node)
{
if (node->left != NULL)
@@ -141,7 +141,7 @@ gl_tree_previous_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
}
static gl_list_node_t _GL_ATTRIBUTE_PURE
gl_tree_first_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED)
gl_tree_first_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list)
{
gl_list_node_t node = list->root;
@@ -154,7 +154,7 @@ gl_tree_first_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED)
}
static gl_list_node_t _GL_ATTRIBUTE_PURE
gl_tree_last_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED)
gl_tree_last_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list)
{
gl_list_node_t node = list->root;
@@ -658,7 +658,7 @@ gl_tree_iterator_next (gl_list_iterator_t *iterator,
}
static void
gl_tree_iterator_free (gl_list_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
gl_tree_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator)
{
}
+1 -1
View File
@@ -300,6 +300,6 @@ gl_tree_iterator_next (gl_omap_iterator_t *iterator,
}
static void
gl_tree_iterator_free (gl_omap_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
gl_tree_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_omap_iterator_t *iterator)
{
}
+1 -1
View File
@@ -438,6 +438,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_ATTRIBUTE_MAYBE_UNUSED)
gl_tree_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_oset_iterator_t *iterator)
{
}
+1 -1
View File
@@ -527,7 +527,7 @@ gl_array_iterator_next (gl_list_iterator_t *iterator,
}
static void
gl_array_iterator_free (gl_list_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
gl_array_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator)
{
}
+1 -1
View File
@@ -370,7 +370,7 @@ gl_array_iterator_next (gl_omap_iterator_t *iterator,
}
static void
gl_array_iterator_free (gl_omap_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
gl_array_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_omap_iterator_t *iterator)
{
}
+1 -1
View File
@@ -488,7 +488,7 @@ gl_array_iterator_next (gl_oset_iterator_t *iterator, const void **eltp)
}
static void
gl_array_iterator_free (gl_oset_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
gl_array_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_oset_iterator_t *iterator)
{
}
+1 -1
View File
@@ -699,7 +699,7 @@ gl_carray_iterator_next (gl_list_iterator_t *iterator,
}
static void
gl_carray_iterator_free (gl_list_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
gl_carray_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator)
{
}
+30 -30
View File
@@ -197,9 +197,9 @@ extern const void * gl_list_node_value (gl_list_t list, gl_list_node_t node);
extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node,
const void *elt);
/* Likewise. Returns 0 upon success, -1 upon out-of-memory. */
_GL_ATTRIBUTE_NODISCARD
extern int gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node,
const void *elt)
_GL_ATTRIBUTE_NODISCARD;
const void *elt);
/* Returns the node immediately after the given node in the list, or NULL
if the given node is the last (rightmost) one in the list. */
@@ -245,9 +245,9 @@ extern const void * gl_list_get_last (gl_list_t list);
extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position,
const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
_GL_ATTRIBUTE_NODISCARD
extern gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position,
const void *elt)
_GL_ATTRIBUTE_NODISCARD;
const void *elt);
/* Replaces the element at the first position in the list.
Returns its node.
@@ -255,8 +255,8 @@ extern gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position,
/* declared in gl_xlist.h */
extern gl_list_node_t gl_list_set_first (gl_list_t list, const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_node_t gl_list_nx_set_first (gl_list_t list, const void *elt)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern gl_list_node_t gl_list_nx_set_first (gl_list_t list, const void *elt);
/* Replaces the element at the last position in the list.
Returns its node.
@@ -264,8 +264,8 @@ extern gl_list_node_t gl_list_nx_set_first (gl_list_t list, const void *elt)
/* declared in gl_xlist.h */
extern gl_list_node_t gl_list_set_last (gl_list_t list, const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_node_t gl_list_nx_set_last (gl_list_t list, const void *elt)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern gl_list_node_t gl_list_nx_set_last (gl_list_t list, const void *elt);
/* Searches whether an element is already in the list.
Returns its node if found, or NULL if not present in the list. */
@@ -307,16 +307,16 @@ extern size_t gl_list_indexof_from_to (gl_list_t list,
/* declared in gl_xlist.h */
extern gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt);
/* Adds an element as the last element of the list.
Returns its node. */
/* declared in gl_xlist.h */
extern gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt);
/* Adds an element before a given element node of the list.
Returns its node. */
@@ -324,10 +324,10 @@ extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt)
extern gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node,
const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
_GL_ATTRIBUTE_NODISCARD
extern gl_list_node_t gl_list_nx_add_before (gl_list_t list,
gl_list_node_t node,
const void *elt)
_GL_ATTRIBUTE_NODISCARD;
const void *elt);
/* Adds an element after a given element node of the list.
Returns its node. */
@@ -335,9 +335,9 @@ extern gl_list_node_t gl_list_nx_add_before (gl_list_t list,
extern gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node,
const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
_GL_ATTRIBUTE_NODISCARD
extern gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node,
const void *elt)
_GL_ATTRIBUTE_NODISCARD;
const void *elt);
/* Adds an element at a given position in the list.
POSITION must be >= 0 and <= gl_list_size (list). */
@@ -345,9 +345,9 @@ extern gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node,
extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position,
const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
_GL_ATTRIBUTE_NODISCARD
extern gl_list_node_t gl_list_nx_add_at (gl_list_t list, size_t position,
const void *elt)
_GL_ATTRIBUTE_NODISCARD;
const void *elt);
/* Removes an element from the list.
Returns true. */
@@ -488,10 +488,10 @@ extern gl_list_node_t gl_sortedlist_add (gl_list_t list,
gl_listelement_compar_fn compar,
const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
_GL_ATTRIBUTE_NODISCARD
extern gl_list_node_t gl_sortedlist_nx_add (gl_list_t list,
gl_listelement_compar_fn compar,
const void *elt)
_GL_ATTRIBUTE_NODISCARD;
const void *elt);
/* Searches and removes an element from the list.
The list is assumed to be sorted with COMPAR.
@@ -630,7 +630,7 @@ gl_list_node_value (gl_list_t list, gl_list_node_t node)
->node_value (list, node);
}
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD int
_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE int
gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node,
const void *elt)
{
@@ -685,20 +685,20 @@ gl_list_get_last (gl_list_t list)
return gl_list_get_at (list, gl_list_size (list) - 1);
}
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
->nx_set_at (list, position, elt);
}
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
gl_list_nx_set_first (gl_list_t list, const void *elt)
{
return gl_list_nx_set_at (list, 0, elt);
}
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
gl_list_nx_set_last (gl_list_t list, const void *elt)
{
return gl_list_nx_set_at (list, gl_list_size (list) - 1, elt);
@@ -752,35 +752,35 @@ gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index,
->indexof_from_to (list, start_index, end_index, elt);
}
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
gl_list_nx_add_first (gl_list_t list, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
->nx_add_first (list, elt);
}
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
gl_list_nx_add_last (gl_list_t list, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
->nx_add_last (list, elt);
}
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
->nx_add_before (list, node, elt);
}
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
->nx_add_after (list, node, elt);
}
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
@@ -891,7 +891,7 @@ gl_sortedlist_indexof_from_to (gl_list_t list, gl_listelement_compar_fn compar,
elt);
}
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
+6 -6
View File
@@ -145,8 +145,8 @@ extern bool gl_map_search (gl_map_t map, const void *key, const void **valuep);
/* declared in gl_xmap.h */
extern bool gl_map_put (gl_map_t map, const void *key, const void *value);
/* Likewise. Returns -1 upon out-of-memory. */
extern int gl_map_nx_put (gl_map_t map, const void *key, const void *value)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern int gl_map_nx_put (gl_map_t map, const void *key, const void *value);
/* Adds a pair to a map and retrieves the previous value.
Returns true if a pair with the given key was not already in the map and so
@@ -157,9 +157,9 @@ extern int gl_map_nx_put (gl_map_t map, const void *key, const void *value)
extern bool gl_map_getput (gl_map_t map, const void *key, const void *value,
const void **oldvaluep);
/* Likewise. Returns -1 upon out-of-memory. */
_GL_ATTRIBUTE_NODISCARD
extern int gl_map_nx_getput (gl_map_t map, const void *key, const void *value,
const void **oldvaluep)
_GL_ATTRIBUTE_NODISCARD;
const void **oldvaluep);
/* Removes a pair from a map.
Returns true if the key was found and its pair removed.
@@ -280,7 +280,7 @@ gl_map_search (gl_map_t map, const void *key, const void **valuep)
->search (map, key, valuep);
}
GL_MAP_INLINE _GL_ATTRIBUTE_NODISCARD int
_GL_ATTRIBUTE_NODISCARD GL_MAP_INLINE int
gl_map_nx_getput (gl_map_t map, const void *key, const void *value,
const void **oldvaluep)
{
@@ -331,7 +331,7 @@ gl_map_get (gl_map_t map, const void *key)
return value;
}
GL_MAP_INLINE _GL_ATTRIBUTE_NODISCARD int
_GL_ATTRIBUTE_NODISCARD GL_MAP_INLINE int
gl_map_nx_put (gl_map_t map, const void *key, const void *value)
{
const void *oldvalue;
+6 -6
View File
@@ -155,8 +155,8 @@ extern bool gl_omap_search_atleast (gl_omap_t map,
/* declared in gl_xomap.h */
extern bool gl_omap_put (gl_omap_t map, const void *key, const void *value);
/* Likewise. Returns -1 upon out-of-memory. */
extern int gl_omap_nx_put (gl_omap_t map, const void *key, const void *value)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern int gl_omap_nx_put (gl_omap_t map, const void *key, const void *value);
/* Adds a pair to an ordered map and retrieves the previous value.
Returns true if a pair with the given key was not already in the map and so
@@ -167,9 +167,9 @@ extern int gl_omap_nx_put (gl_omap_t map, const void *key, const void *value)
extern bool gl_omap_getput (gl_omap_t map, const void *key, const void *value,
const void **oldvaluep);
/* Likewise. Returns -1 upon out-of-memory. */
_GL_ATTRIBUTE_NODISCARD
extern int gl_omap_nx_getput (gl_omap_t map, const void *key, const void *value,
const void **oldvaluep)
_GL_ATTRIBUTE_NODISCARD;
const void **oldvaluep);
/* Removes a pair from an ordered map.
Returns true if the key was found and its pair removed.
@@ -298,7 +298,7 @@ gl_omap_search_atleast (gl_omap_t map,
->search_atleast (map, threshold_fn, threshold, keyp, valuep);
}
GL_OMAP_INLINE _GL_ATTRIBUTE_NODISCARD int
_GL_ATTRIBUTE_NODISCARD GL_OMAP_INLINE int
gl_omap_nx_getput (gl_omap_t map, const void *key, const void *value,
const void **oldvaluep)
{
@@ -349,7 +349,7 @@ gl_omap_get (gl_omap_t map, const void *key)
return value;
}
GL_OMAP_INLINE _GL_ATTRIBUTE_NODISCARD int
_GL_ATTRIBUTE_NODISCARD GL_OMAP_INLINE int
gl_omap_nx_put (gl_omap_t map, const void *key, const void *value)
{
const void *oldvalue;
+4 -3
View File
@@ -134,9 +134,10 @@ extern bool gl_oset_search_atleast (gl_oset_t set,
Returns true if it was not already in the set and added, false otherwise. */
/* declared in gl_xoset.h */
extern bool gl_oset_add (gl_oset_t set, const void *elt);
/* Likewise. Returns -1 upon out-of-memory. */
extern int gl_oset_nx_add (gl_oset_t set, const void *elt)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern int gl_oset_nx_add (gl_oset_t set, const void *elt);
/* Removes an element from an ordered set.
Returns true if it was found and removed. */
@@ -272,7 +273,7 @@ gl_oset_search_atleast (gl_oset_t set,
->search_atleast (set, threshold_fn, threshold, eltp);
}
GL_OSET_INLINE _GL_ATTRIBUTE_NODISCARD int
_GL_ATTRIBUTE_NODISCARD GL_OSET_INLINE int
gl_oset_nx_add (gl_oset_t set, const void *elt)
{
return ((const struct gl_oset_impl_base *) set)->vtable->nx_add (set, elt);
+4 -3
View File
@@ -124,9 +124,10 @@ extern bool gl_set_search (gl_set_t set, const void *elt);
Returns true if it was not already in the set and added, false otherwise. */
/* declared in gl_xset.h */
extern bool gl_set_add (gl_set_t set, const void *elt);
/* Likewise. Returns -1 upon out-of-memory. */
extern int gl_set_nx_add (gl_set_t set, const void *elt)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern int gl_set_nx_add (gl_set_t set, const void *elt);
/* Removes an element from a set.
Returns true if it was found and removed. */
@@ -230,7 +231,7 @@ gl_set_search (gl_set_t set, const void *elt)
return ((const struct gl_set_impl_base *) set)->vtable->search (set, elt);
}
GL_SET_INLINE _GL_ATTRIBUTE_NODISCARD int
_GL_ATTRIBUTE_NODISCARD GL_SET_INLINE int
gl_set_nx_add (gl_set_t set, const void *elt)
{
return ((const struct gl_set_impl_base *) set)->vtable->nx_add (set, elt);
+10 -9
View File
@@ -139,14 +139,15 @@ typedef void (Hamt_freer) (Hamt_entry *elt);
/****************************/
/* Create and return a new and empty hash array mapped trie. */
_GL_ATTRIBUTE_NODISCARD
extern Hamt *hamt_create (Hamt_hasher *hasher, Hamt_comparator *comparator,
Hamt_freer *freer)
_GL_ATTRIBUTE_NODISCARD;
Hamt_freer *freer);
/* Return a copy of HAMT, which is not the same in the sense above.
This procedure can be used, for example, so that two threads can
access the same data independently. */
extern Hamt *hamt_copy (Hamt *hamt) _GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern Hamt *hamt_copy (Hamt *hamt);
/* Free the resources solely allocated by HAMT and all elements solely
contained in it. */
@@ -167,20 +168,20 @@ extern Hamt_entry *hamt_lookup (const Hamt *hamt, const void *elt);
/* If *ELT_PTR matches an element already in HAMT, set *ELT_PTR to the
existing element and return the original hamt. Otherwise, insert
*ELT_PTR into a copy of the hamt and return the copy. */
extern Hamt *hamt_insert (Hamt *hamt, Hamt_entry **elt_ptr)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern Hamt *hamt_insert (Hamt *hamt, Hamt_entry **elt_ptr);
/* If *ELT_PTR matches an element already in HAMT, set *ELT_PTR to the
existing element, remove the element from a copy of the hamt and
return the copy. Otherwise, return the original hamt. */
extern Hamt *hamt_remove (Hamt *hamt, Hamt_entry **elt_ptr)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern Hamt *hamt_remove (Hamt *hamt, Hamt_entry **elt_ptr);
/* Insert *ELT_PTR into a copy of HAMT and return the copy. If an
existing element was replaced, set *ELT_PTR to this element, and to
NULL otherwise. */
extern Hamt *hamt_replace (Hamt *hamt, Hamt_entry **elt_ptr)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern Hamt *hamt_replace (Hamt *hamt, Hamt_entry **elt_ptr);
/*************/
/* Iteration */
+10 -10
View File
@@ -172,21 +172,21 @@ typedef void (*Hash_data_freer) (void *entry);
all of your 'data' data. This is typically the case when your data is
simply an auxiliary struct that you have malloc'd to aggregate several
values. */
_GL_ATTRIBUTE_NODISCARD
extern Hash_table *hash_initialize (size_t candidate,
const Hash_tuning *tuning,
Hash_hasher hasher,
Hash_comparator comparator,
Hash_data_freer data_freer)
_GL_ATTRIBUTE_NODISCARD;
Hash_data_freer data_freer);
/* Same as hash_initialize, but invokes xalloc_die on memory exhaustion. */
/* This function is defined by module 'xhash'. */
_GL_ATTRIBUTE_NODISCARD
extern Hash_table *hash_xinitialize (size_t candidate,
const Hash_tuning *tuning,
Hash_hasher hasher,
Hash_comparator comparator,
Hash_data_freer data_freer)
_GL_ATTRIBUTE_NODISCARD;
Hash_data_freer data_freer);
/* Make all buckets empty, placing any chained entries on the free list.
Apply the user-specified function data_freer (if any) to the datas of any
@@ -210,16 +210,16 @@ extern void hash_free (Hash_table *table);
those already in the table, before any other growth of the hash table size
occurs. If TUNING->IS_N_BUCKETS is true, then CANDIDATE specifies the
exact number of buckets desired. Return true iff the rehash succeeded. */
extern bool hash_rehash (Hash_table *table, size_t candidate)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern bool hash_rehash (Hash_table *table, size_t candidate);
/* If ENTRY matches an entry already in the hash table, return the pointer
to the entry from the table. Otherwise, insert ENTRY and return ENTRY.
Return NULL if the storage required for insertion cannot be allocated.
This implementation does not support duplicate entries or insertion of
NULL. */
extern void *hash_insert (Hash_table *table, const void *entry)
_GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD
extern void *hash_insert (Hash_table *table, const void *entry);
/* Same as hash_insert, but invokes xalloc_die on memory exhaustion. */
/* This function is defined by module 'xhash'. */
@@ -251,8 +251,8 @@ extern void *hash_remove (Hash_table *table, const void *entry);
/* Same as hash_remove. This interface is deprecated.
FIXME: Remove in 2022. */
extern void *hash_delete (Hash_table *table, const void *entry)
_GL_ATTRIBUTE_DEPRECATED;
_GL_ATTRIBUTE_DEPRECATED
extern void *hash_delete (Hash_table *table, const void *entry);
# ifdef __cplusplus
}
+5 -5
View File
@@ -22,8 +22,8 @@
#include "intprops.h"
char *imaxtostr (intmax_t, char *) _GL_ATTRIBUTE_NODISCARD;
char *inttostr (int, char *) _GL_ATTRIBUTE_NODISCARD;
char *offtostr (off_t, char *) _GL_ATTRIBUTE_NODISCARD;
char *uinttostr (unsigned int, char *) _GL_ATTRIBUTE_NODISCARD;
char *umaxtostr (uintmax_t, char *) _GL_ATTRIBUTE_NODISCARD;
_GL_ATTRIBUTE_NODISCARD char *imaxtostr (intmax_t, char *);
_GL_ATTRIBUTE_NODISCARD char *inttostr (int, char *);
_GL_ATTRIBUTE_NODISCARD char *offtostr (off_t, char *);
_GL_ATTRIBUTE_NODISCARD char *uinttostr (unsigned int, char *);
_GL_ATTRIBUTE_NODISCARD char *umaxtostr (uintmax_t, char *);
+1 -1
View File
@@ -38,7 +38,7 @@ safe_alloc_realloc_n (void *ptr, size_t count, size_t size)
count = size = 1;
return reallocarray (ptr, count, size);
}
SAFE_ALLOC_INLINE int _GL_ATTRIBUTE_NODISCARD
_GL_ATTRIBUTE_NODISCARD SAFE_ALLOC_INLINE int
safe_alloc_check (void *ptr)
{
/* Return 0 if the allocation was successful, -1 otherwise. */
+25 -17
View File
@@ -29,34 +29,42 @@ _GL_INLINE_HEADER_BEGIN
# define SE_CONTEXT_INLINE _GL_INLINE
#endif
/* The definition of _GL_UNUSED_PARAMETER is copied here. */
typedef int context_t;
SE_CONTEXT_INLINE context_t context_new (char const *s _GL_UNUSED_PARAMETER)
SE_CONTEXT_INLINE context_t
context_new (_GL_ATTRIBUTE_MAYBE_UNUSED char const *s)
{ errno = ENOTSUP; return 0; }
SE_CONTEXT_INLINE char *context_str (context_t con _GL_UNUSED_PARAMETER)
SE_CONTEXT_INLINE char *
context_str (_GL_ATTRIBUTE_MAYBE_UNUSED context_t con)
{ errno = ENOTSUP; return (void *) 0; }
SE_CONTEXT_INLINE void context_free (context_t c _GL_UNUSED_PARAMETER) {}
SE_CONTEXT_INLINE void context_free (_GL_ATTRIBUTE_MAYBE_UNUSED context_t c) {}
SE_CONTEXT_INLINE int context_user_set (context_t sc _GL_UNUSED_PARAMETER,
char const *s _GL_UNUSED_PARAMETER)
SE_CONTEXT_INLINE int
context_user_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc,
_GL_ATTRIBUTE_MAYBE_UNUSED char const *s)
{ errno = ENOTSUP; return -1; }
SE_CONTEXT_INLINE int context_role_set (context_t sc _GL_UNUSED_PARAMETER,
char const *s _GL_UNUSED_PARAMETER)
SE_CONTEXT_INLINE int
context_role_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc,
_GL_ATTRIBUTE_MAYBE_UNUSED char const *s)
{ errno = ENOTSUP; return -1; }
SE_CONTEXT_INLINE int context_range_set (context_t sc _GL_UNUSED_PARAMETER,
char const *s _GL_UNUSED_PARAMETER)
SE_CONTEXT_INLINE int
context_range_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc,
_GL_ATTRIBUTE_MAYBE_UNUSED char const *s)
{ errno = ENOTSUP; return -1; }
SE_CONTEXT_INLINE int context_type_set (context_t sc _GL_UNUSED_PARAMETER,
char const *s _GL_UNUSED_PARAMETER)
SE_CONTEXT_INLINE int
context_type_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc,
_GL_ATTRIBUTE_MAYBE_UNUSED char const *s)
{ errno = ENOTSUP; return -1; }
SE_CONTEXT_INLINE char *context_type_get (context_t sc _GL_UNUSED_PARAMETER)
SE_CONTEXT_INLINE char *
context_type_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc)
{ errno = ENOTSUP; return (void *) 0; }
SE_CONTEXT_INLINE char *context_range_get (context_t sc _GL_UNUSED_PARAMETER)
SE_CONTEXT_INLINE char *
context_range_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc)
{ errno = ENOTSUP; return (void *) 0; }
SE_CONTEXT_INLINE char *context_role_get (context_t sc _GL_UNUSED_PARAMETER)
SE_CONTEXT_INLINE char *
context_role_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc)
{ errno = ENOTSUP; return (void *) 0; }
SE_CONTEXT_INLINE char *context_user_get (context_t sc _GL_UNUSED_PARAMETER)
SE_CONTEXT_INLINE char *
context_user_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc)
{ errno = ENOTSUP; return (void *) 0; }
_GL_INLINE_HEADER_END
+8 -10
View File
@@ -31,27 +31,25 @@ _GL_INLINE_HEADER_BEGIN
# define SE_LABEL_INLINE _GL_INLINE
#endif
/* The definition of _GL_UNUSED_PARAMETER is copied here. */
#define SELABEL_CTX_FILE 0
struct selabel_handle;
SE_LABEL_INLINE int
selabel_lookup (struct selabel_handle *hnd _GL_UNUSED_PARAMETER,
char **context _GL_UNUSED_PARAMETER,
char const *key _GL_UNUSED_PARAMETER,
int type _GL_UNUSED_PARAMETER)
selabel_lookup (_GL_ATTRIBUTE_MAYBE_UNUSED struct selabel_handle *hnd,
_GL_ATTRIBUTE_MAYBE_UNUSED char **context,
_GL_ATTRIBUTE_MAYBE_UNUSED char const *key,
_GL_ATTRIBUTE_MAYBE_UNUSED int type)
{ errno = ENOTSUP; return -1; }
SE_LABEL_INLINE struct selabel_handle *
selabel_open (int backend _GL_UNUSED_PARAMETER,
struct selinux_opt *options _GL_UNUSED_PARAMETER,
unsigned nopt _GL_UNUSED_PARAMETER)
selabel_open (_GL_ATTRIBUTE_MAYBE_UNUSED int backend,
_GL_ATTRIBUTE_MAYBE_UNUSED struct selinux_opt *options,
_GL_ATTRIBUTE_MAYBE_UNUSED unsigned nopt)
{ errno = ENOTSUP; return 0; }
SE_LABEL_INLINE void
selabel_close (struct selabel_handle *hnd _GL_UNUSED_PARAMETER)
selabel_close (_GL_ATTRIBUTE_MAYBE_UNUSED struct selabel_handle *hnd)
{ errno = ENOTSUP; }
_GL_INLINE_HEADER_END
+27 -29
View File
@@ -38,8 +38,6 @@ _GL_INLINE_HEADER_BEGIN
# define SE_SELINUX_INLINE _GL_INLINE
# endif
/* The definition of _GL_UNUSED_PARAMETER is copied here. */
# if !GNULIB_defined_security_types
typedef unsigned short security_class_t;
@@ -47,67 +45,67 @@ struct selinux_opt;
# define is_selinux_enabled() 0
SE_SELINUX_INLINE int
getcon (char **con _GL_UNUSED_PARAMETER)
getcon (_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE void
freecon (char *con _GL_UNUSED_PARAMETER) {}
freecon (_GL_ATTRIBUTE_MAYBE_UNUSED char *con) {}
SE_SELINUX_INLINE int
getfscreatecon (char **con _GL_UNUSED_PARAMETER)
getfscreatecon (_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
setfscreatecon (char const *con _GL_UNUSED_PARAMETER)
setfscreatecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
matchpathcon (char const *file _GL_UNUSED_PARAMETER,
mode_t m _GL_UNUSED_PARAMETER,
char **con _GL_UNUSED_PARAMETER)
matchpathcon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
_GL_ATTRIBUTE_MAYBE_UNUSED mode_t m,
_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
getfilecon (char const *file _GL_UNUSED_PARAMETER,
char **con _GL_UNUSED_PARAMETER)
getfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
lgetfilecon (char const *file _GL_UNUSED_PARAMETER,
char **con _GL_UNUSED_PARAMETER)
lgetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
fgetfilecon (int fd, char **con _GL_UNUSED_PARAMETER)
fgetfilecon (int fd,_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
setfilecon (char const *file _GL_UNUSED_PARAMETER,
char const *con _GL_UNUSED_PARAMETER)
setfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
lsetfilecon (char const *file _GL_UNUSED_PARAMETER,
char const *con _GL_UNUSED_PARAMETER)
lsetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
fsetfilecon (int fd _GL_UNUSED_PARAMETER,
char const *con _GL_UNUSED_PARAMETER)
fsetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED int fd,
_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
security_check_context (char const *con _GL_UNUSED_PARAMETER)
security_check_context (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
security_check_context_raw (char const *con _GL_UNUSED_PARAMETER)
security_check_context_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
setexeccon (char const *con _GL_UNUSED_PARAMETER)
setexeccon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE int
security_compute_create (char const *scon _GL_UNUSED_PARAMETER,
char const *tcon _GL_UNUSED_PARAMETER,
security_class_t tclass _GL_UNUSED_PARAMETER,
char **newcon _GL_UNUSED_PARAMETER)
security_compute_create (_GL_ATTRIBUTE_MAYBE_UNUSED char const *scon,
_GL_ATTRIBUTE_MAYBE_UNUSED char const *tcon,
_GL_ATTRIBUTE_MAYBE_UNUSED security_class_t tclass,
_GL_ATTRIBUTE_MAYBE_UNUSED char **newcon)
{ errno = ENOTSUP; return -1; }
SE_SELINUX_INLINE security_class_t
string_to_security_class (char const *name)
{ errno = ENOTSUP; return 0; }
SE_SELINUX_INLINE int
matchpathcon_init_prefix (char const *path _GL_UNUSED_PARAMETER,
char const *prefix _GL_UNUSED_PARAMETER)
matchpathcon_init_prefix (_GL_ATTRIBUTE_MAYBE_UNUSED char const *path,
_GL_ATTRIBUTE_MAYBE_UNUSED char const *prefix)
{ errno = ENOTSUP; return -1; }
# define GNULIB_defined_security_types 1
+3 -5
View File
@@ -19,9 +19,6 @@
#include "unitypes.h"
/* Get common macros for C. */
#include "unused-parameter.h"
/* Get bool. */
#include <stdbool.h>
@@ -193,7 +190,7 @@ extern int
# else
static inline int
u32_mbtouc_unsafe (ucs4_t *puc,
const uint32_t *s, size_t n _GL_UNUSED_PARAMETER)
const uint32_t *s, _GL_ATTRIBUTE_MAYBE_UNUSED size_t n)
{
uint32_t c = *s;
@@ -259,7 +256,8 @@ extern int
u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n);
# else
static inline int
u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n _GL_UNUSED_PARAMETER)
u32_mbtouc (ucs4_t *puc, const uint32_t *s,
_GL_ATTRIBUTE_MAYBE_UNUSED size_t n)
{
uint32_t c = *s;
+5 -8
View File
@@ -14,18 +14,15 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* _GL_UNUSED_PARAMETER is a marker that can be appended to function parameter
/* _GL_UNUSED_PARAMETER is a marker that can be prepended to function parameter
declarations for parameters that are not used. This helps to reduce
warnings, such as from GCC -Wunused-parameter. The syntax is as follows:
type param _GL_UNUSED_PARAMETER
_GL_UNUSED_PARAMETER type param
or more generally
param_decl _GL_UNUSED_PARAMETER
_GL_UNUSED_PARAMETER param_decl
For example:
int param _GL_UNUSED_PARAMETER
int *(*param)(void) _GL_UNUSED_PARAMETER
Other possible, but obscure and discouraged syntaxes:
int _GL_UNUSED_PARAMETER *(*param)(void)
_GL_UNUSED_PARAMETER int *(*param)(void)
_GL_UNUSED_PARAMETER int param
_GL_UNUSED_PARAMETER int *(*param) (void)
*/
#ifndef _GL_UNUSED_PARAMETER
# define _GL_UNUSED_PARAMETER _GL_ATTRIBUTE_MAYBE_UNUSED
+20 -9
View File
@@ -103,6 +103,12 @@ AC_DEFUN([gl_COMMON_BODY], [
# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
#endif
#ifdef __has_c_attribute
# define _GL_HAS_C_ATTRIBUTE(attr) __has_c_attribute (__##attr##__)
#else
# define _GL_HAS_C_ATTRIBUTE(attr) 0
#endif
]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead.
[
#if _GL_HAS_ATTRIBUTE (alloc_size)
@@ -142,7 +148,7 @@ AC_DEFUN([gl_COMMON_BODY], [
# define _GL_ATTRIBUTE_CONST
#endif
#if 201710L < __STDC_VERSION__
#if _GL_HAS_C_ATTRIBUTE (deprecated)
# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
#elif _GL_HAS_ATTRIBUTE (deprecated)
# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
@@ -168,7 +174,7 @@ AC_DEFUN([gl_COMMON_BODY], [
#endif
/* FALLTHROUGH is special, because it always expands to something. */
#if 201710L < __STDC_VERSION__
#if _GL_HAS_C_ATTRIBUTE (fallthrough)
# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
#elif _GL_HAS_ATTRIBUTE (fallthrough)
# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
@@ -195,15 +201,12 @@ AC_DEFUN([gl_COMMON_BODY], [
# define _GL_ATTRIBUTE_MAY_ALIAS
#endif
#if 201710L < __STDC_VERSION__
#if _GL_HAS_C_ATTRIBUTE (maybe_unused)
# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
#elif _GL_HAS_ATTRIBUTE (unused)
# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__))
#else
# define _GL_ATTRIBUTE_MAYBE_UNUSED
# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED
#endif
/* Earlier spellings of this macro. */
#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
#define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED
#if _GL_HAS_ATTRIBUTE (malloc)
@@ -212,7 +215,7 @@ AC_DEFUN([gl_COMMON_BODY], [
# define _GL_ATTRIBUTE_MALLOC
#endif
#if 201710L < __STDC_VERSION__
#if _GL_HAS_C_ATTRIBUTE (nodiscard)
# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
#elif _GL_HAS_ATTRIBUTE (warn_unused_result)
# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
@@ -270,11 +273,19 @@ AC_DEFUN([gl_COMMON_BODY], [
# define _GL_ATTRIBUTE_SENTINEL(pos)
#endif
#if _GL_HAS_ATTRIBUTE (unused)
# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#else
# define _GL_ATTRIBUTE_UNUSED
#endif
/* Earlier spellings of this macro. */
#define _GL_UNUSED _GL_ATTRIBUTE_UNUSED
]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
[
/* To support C++ as well as C, use _GL_UNUSED_LABEL with trailing ';'. */
#if !defined __cplusplus || _GL_GNUC_PREREQ (4, 5)
# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_MAYBE_UNUSED
# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED
#else
# define _GL_UNUSED_LABEL
#endif
-1
View File
@@ -8,7 +8,6 @@ m4/fflush.m4
Depends-on:
stdio
snippet/unused-parameter [test $REPLACE_FFLUSH = 1]
fpurge [test $REPLACE_FFLUSH = 1]
ftello [test $REPLACE_FFLUSH = 1]
freading [test $REPLACE_FFLUSH = 1]
+5 -12
View File
@@ -16,7 +16,6 @@ m4/selinux-selinux-h.m4
Depends-on:
errno
extern-inline
snippet/unused-parameter
configure.ac:
gl_HEADERS_SELINUX_SELINUX_H
@@ -31,7 +30,7 @@ lib_SOURCES += se-context.in.h se-label.in.h se-selinux.in.h \
se-context.c se-label.c se-selinux.c
BUILT_SOURCES += selinux/selinux.h
selinux/selinux.h: se-selinux.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
selinux/selinux.h: se-selinux.in.h $(top_builddir)/config.status
$(AM_V_at)$(MKDIR_P) selinux
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
@@ -40,23 +39,19 @@ selinux/selinux.h: se-selinux.in.h $(top_builddir)/config.status $(UNUSED_PARAME
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SELINUX_SELINUX_H''@|$(NEXT_SELINUX_SELINUX_H)|g' \
-e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \
< $(srcdir)/se-selinux.in.h; \
} > $@-t && \
chmod a-x $@-t && \
mv $@-t $@
MOSTLYCLEANFILES += selinux/selinux.h selinux/selinux.h-t
BUILT_SOURCES += $(SELINUX_CONTEXT_H)
if GL_GENERATE_SELINUX_CONTEXT_H
selinux/context.h: se-context.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
selinux/context.h: se-context.in.h $(top_builddir)/config.status
$(AM_V_at)$(MKDIR_P) selinux
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \
< $(srcdir)/se-context.in.h; \
cat $(srcdir)/se-context.in.h; \
} > $@-t && \
chmod a-x $@-t && \
mv $@-t $@
else
selinux/context.h: $(top_builddir)/config.status
@@ -66,14 +61,12 @@ MOSTLYCLEANFILES += selinux/context.h selinux/context.h-t
BUILT_SOURCES += $(SELINUX_LABEL_H)
if GL_GENERATE_SELINUX_LABEL_H
selinux/label.h: se-label.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
selinux/label.h: se-label.in.h $(top_builddir)/config.status
$(AM_V_at)$(MKDIR_P) selinux
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \
< $(srcdir)/se-label.in.h; \
cat $(srcdir)/se-label.in.h; \
} > $@-t && \
chmod a-x $@-t && \
mv $@-t $@
else
selinux/label.h: $(top_builddir)/config.status
-1
View File
@@ -7,7 +7,6 @@ m4/libunistring-base.m4
Depends-on:
unitypes
snippet/unused-parameter
stdbool
inline
+3 -3
View File
@@ -128,7 +128,7 @@ bag_from_list (gl_list_t list)
}
/* Returns true if and only if the given bag is empty. */
static bool _GL_ATTRIBUTE_MAYBE_UNUSED
_GL_ATTRIBUTE_MAYBE_UNUSED static bool
bag_is_empty (bag_t bag)
{
size_t i;
@@ -165,7 +165,7 @@ bag_equals (bag_t bag1, bag_t bag2)
/* Returns a bag that contains the elements of BAG1 and the elements of
BAG2. */
static bag_t _GL_ATTRIBUTE_MAYBE_UNUSED
_GL_ATTRIBUTE_MAYBE_UNUSED static bag_t
bag_or (bag_t bag1, bag_t bag2)
{
bag_t bag;
@@ -192,7 +192,7 @@ bag_xor (bag_t bag1, bag_t bag2)
}
/* Returns a bag that contains the elements of BAG1 that are not in BAG2. */
static bag_t _GL_ATTRIBUTE_MAYBE_UNUSED
_GL_ATTRIBUTE_MAYBE_UNUSED static bag_t
bag_and_not (bag_t bag1, bag_t bag2)
{
bag_t bag;
+5 -5
View File
@@ -26,11 +26,11 @@
#include "attribute.h"
struct s { int i; };
static char doChar (void) NODISCARD;
static int doInt (void) NODISCARD;
static off_t doOff (void) NODISCARD;
static void *doPtr (void) NODISCARD;
static struct s doStruct (void) NODISCARD;
NODISCARD static char doChar (void);
NODISCARD static int doInt (void);
NODISCARD static off_t doOff (void);
NODISCARD static void *doPtr (void);
NODISCARD static struct s doStruct (void);
static char
doChar (void)