On 5/14/20 7:01 AM, Marc Nieper-Wißkirchen wrote:
> This will be a nice use case for the newly created attribute module
> and MAYBE_UNUSED.

I don't think we need to go that far, since c-stack is already using
ignore_value. I installed the attached.

>From c8c5f321dd10b21c8ad55f5c134c93235ffc9930 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Fri, 15 May 2020 13:58:30 -0700
Subject: [PATCH] c-stack: pacify -Wunused-result when DEBUG
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Marc Nieper-Wißkirchen in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00132.html
* lib/c-stack.c (segv_handler, overflow_handler, segv_handler) [DEBUG]:
Explicitly ignore write failures.
---
 ChangeLog     | 8 ++++++++
 lib/c-stack.c | 6 +++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a3b412818..67af0d448 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-15  Paul Eggert  <egg...@cs.ucla.edu>
+
+	c-stack: pacify -Wunused-result when DEBUG
+	Problem reported by Marc Nieper-Wißkirchen in:
+	https://lists.gnu.org/r/bug-gnulib/2020-05/msg00132.html
+	* lib/c-stack.c (segv_handler, overflow_handler, segv_handler) [DEBUG]:
+	Explicitly ignore write failures.
+
 2020-05-13  Jim Meyering  <meyer...@fb.com>
 
 	announce-gen: improve a comment
diff --git a/lib/c-stack.c b/lib/c-stack.c
index e48659130..59606299b 100644
--- a/lib/c-stack.c
+++ b/lib/c-stack.c
@@ -172,7 +172,7 @@ segv_handler (void *address _GL_UNUSED, int serious)
     char buf[1024];
     int saved_errno = errno;
     sprintf (buf, "segv_handler serious=%d\n", serious);
-    write (STDERR_FILENO, buf, strlen (buf));
+    ignore_value (write (STDERR_FILENO, buf, strlen (buf)));
     errno = saved_errno;
   }
 # endif
@@ -195,7 +195,7 @@ overflow_handler (int emergency, stackoverflow_context_t context _GL_UNUSED)
     char buf[1024];
     sprintf (buf, "overflow_handler emergency=%d segv_handler_missing=%d\n",
              emergency, segv_handler_missing);
-    write (STDERR_FILENO, buf, strlen (buf));
+    ignore_value (write (STDERR_FILENO, buf, strlen (buf)));
   }
 # endif
 
@@ -268,7 +268,7 @@ segv_handler (int signo, siginfo_t *info, void *context _GL_UNUSED)
                  "segv_handler fault=%p base=%p size=%lx page=%lx signo=%d\n",
                  faulting_address, stack_base, (unsigned long) stack_size,
                  (unsigned long) page_size, signo);
-        write (STDERR_FILENO, buf, strlen (buf));
+        ignore_value (write (STDERR_FILENO, buf, strlen (buf)));
       }
 #   endif
     }
-- 
2.17.1

Reply via email to