In order to silence these warnings

../../gllib/get-rusage-data.c:354:1: warning: 'get_rusage_data_via_iterator' 
defined but not used [-Wunused-function]
../../gllib/hamt.c:201:1: warning: 'init_element' defined but not used 
[-Wunused-function]
../../gltests/../gllib/stack.h:75:24: warning: 'stack_current_base' defined but 
not used [-Wunused-function]

I'm making use of _GL_ATTRIBUTE_MAYBE_UNUSED.


2023-05-18  Bruno Haible  <[email protected]>

        stack: Silence gcc warning in tests.
        * lib/stack.h (init, destroy, empty, current_base, push, pop, discard,
        top, size): Mark as possibly unused.

2023-05-18  Bruno Haible  <[email protected]>

        hamt: Silence gcc warning.
        * lib/hamt.c (init_element): Mark as possibly unused.

2023-05-18  Bruno Haible  <[email protected]>

        get-rusage-data: Silence gcc warning.
        * lib/get-rusage-data.c (get_rusage_data_via_iterator): Mark as possibly
        unused.

>From 1b63db9814cd6734596566433ff9f6230b6ec04a Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Thu, 18 May 2023 22:43:14 +0200
Subject: [PATCH 01/10] get-rusage-data: Silence gcc warning.

* lib/get-rusage-data.c (get_rusage_data_via_iterator): Mark as possibly
unused.
---
 ChangeLog             | 6 ++++++
 lib/get-rusage-data.c | 1 +
 2 files changed, 7 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index f105e2db8f..e080e8f670 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-05-18  Bruno Haible  <[email protected]>
+
+	get-rusage-data: Silence gcc warning.
+	* lib/get-rusage-data.c (get_rusage_data_via_iterator): Mark as possibly
+	unused.
+
 2023-05-18  Bruno Haible  <[email protected]>
 
 	astrxfrm: Fix use-after-free bug.
diff --git a/lib/get-rusage-data.c b/lib/get-rusage-data.c
index 4d5dc4092a..565fcc33f3 100644
--- a/lib/get-rusage-data.c
+++ b/lib/get-rusage-data.c
@@ -350,6 +350,7 @@ vma_iterate_callback (void *data, uintptr_t start, uintptr_t end,
   return 0;
 }
 
+_GL_ATTRIBUTE_MAYBE_UNUSED
 static uintptr_t
 get_rusage_data_via_iterator (void)
 {
-- 
2.34.1

>From 136942a565b7f3ccd6632731c3622460c5f55523 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Thu, 18 May 2023 22:45:45 +0200
Subject: [PATCH 02/10] hamt: Silence gcc warning.

* lib/hamt.c (init_element): Mark as possibly unused.
---
 ChangeLog  | 5 +++++
 lib/hamt.c | 1 +
 2 files changed, 6 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index e080e8f670..aff37369ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-05-18  Bruno Haible  <[email protected]>
+
+	hamt: Silence gcc warning.
+	* lib/hamt.c (init_element): Mark as possibly unused.
+
 2023-05-18  Bruno Haible  <[email protected]>
 
 	get-rusage-data: Silence gcc warning.
diff --git a/lib/hamt.c b/lib/hamt.c
index aa76f9029e..8cbca387f0 100644
--- a/lib/hamt.c
+++ b/lib/hamt.c
@@ -197,6 +197,7 @@ free_element (const struct function_table *functions, Hamt_entry *elt)
 }
 
 /* Return the initialized element.  */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 static Hamt_entry *
 init_element (Hamt_entry *elt)
 {
-- 
2.34.1

>From 54504760620fc798d62fc3ec3668ff87e3d9bd56 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Thu, 18 May 2023 22:48:54 +0200
Subject: [PATCH 03/10] stack: Silence gcc warning in tests.

* lib/stack.h (init, destroy, empty, current_base, push, pop, discard,
top, size): Mark as possibly unused.
---
 ChangeLog   |  6 ++++++
 lib/stack.h | 17 +++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aff37369ef..0216321fc6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-05-18  Bruno Haible  <[email protected]>
+
+	stack: Silence gcc warning in tests.
+	* lib/stack.h (init, destroy, empty, current_base, push, pop, discard,
+	top, size): Mark as possibly unused.
+
 2023-05-18  Bruno Haible  <[email protected]>
 
 	hamt: Silence gcc warning.
diff --git a/lib/stack.h b/lib/stack.h
index ab6b873176..dbd6812bc8 100644
--- a/lib/stack.h
+++ b/lib/stack.h
@@ -58,7 +58,7 @@
      #include "xalloc.h"
 */
 
-/* This file uses _GL_ATTRIBUTE_PURE.  */
+/* This file uses _GL_ATTRIBUTE_MAYBE_UNUSED, _GL_ATTRIBUTE_PURE.  */
 #if !_GL_CONFIG_H_INCLUDED
  #error "Please include config.h first."
 #endif
@@ -86,6 +86,7 @@ typedef struct
 } _GL_STACK_TYPE;
 
 /* Initialize a stack.  */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS void
 _GL_STACK_PREFIX (init) (_GL_STACK_TYPE *stack)
 {
@@ -95,6 +96,7 @@ _GL_STACK_PREFIX (init) (_GL_STACK_TYPE *stack)
 }
 
 /* Destroy a stack by freeing the allocated space.  */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS void
 _GL_STACK_PREFIX (destroy) (_GL_STACK_TYPE *stack)
 {
@@ -102,7 +104,8 @@ _GL_STACK_PREFIX (destroy) (_GL_STACK_TYPE *stack)
 }
 
 /* Return true if the stack currently holds no element.  */
-GL_STACK_STORAGECLASS _GL_ATTRIBUTE_PURE bool
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_PURE
+GL_STACK_STORAGECLASS bool
 _GL_STACK_PREFIX (empty) (const _GL_STACK_TYPE *stack)
 {
   return stack->size == 0;
@@ -112,13 +115,15 @@ _GL_STACK_PREFIX (empty) (const _GL_STACK_TYPE *stack)
 
    The result is invalidated as soon as an element is added or removed
    from the stack.  */
-GL_STACK_STORAGECLASS _GL_ATTRIBUTE_PURE GL_STACK_ELEMENT *
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_PURE
+GL_STACK_STORAGECLASS GL_STACK_ELEMENT *
 _GL_STACK_PREFIX (current_base) (const _GL_STACK_TYPE *stack)
 {
   return stack->base;
 }
 
 /* Push an element to the top of the stack.  */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS void
 _GL_STACK_PREFIX (push) (_GL_STACK_TYPE *stack, GL_STACK_ELEMENT item)
 {
@@ -130,6 +135,7 @@ _GL_STACK_PREFIX (push) (_GL_STACK_TYPE *stack, GL_STACK_ELEMENT item)
 
 /* Pop the element from the top of the stack, which must be non-empty,
    and return it. */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS GL_STACK_ELEMENT
 _GL_STACK_PREFIX (pop) (_GL_STACK_TYPE *stack)
 {
@@ -139,6 +145,7 @@ _GL_STACK_PREFIX (pop) (_GL_STACK_TYPE *stack)
 
 /* Pop the element from the top of the stack, which must be
    non-empty.  */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS void
 _GL_STACK_PREFIX (discard) (_GL_STACK_TYPE *stack)
 {
@@ -148,6 +155,7 @@ _GL_STACK_PREFIX (discard) (_GL_STACK_TYPE *stack)
 
 /* Return the element from the top of the stack, which must be
    non-empty.  */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS GL_STACK_ELEMENT
 _GL_STACK_PREFIX (top) (const _GL_STACK_TYPE *stack)
 {
@@ -156,7 +164,8 @@ _GL_STACK_PREFIX (top) (const _GL_STACK_TYPE *stack)
 }
 
 /* Return the currently stored number of elements in the stack.  */
-GL_STACK_STORAGECLASS _GL_ATTRIBUTE_PURE idx_t
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_PURE
+GL_STACK_STORAGECLASS idx_t
 _GL_STACK_PREFIX (size) (const _GL_STACK_TYPE *stack)
 {
   return stack->size;
-- 
2.34.1

Reply via email to