[v2] Fix warning caused by unused-result in bug-atexit3-lib.cc

Message ID 1477677435-21029-1-git-send-email-gftg@linux.vnet.ibm.com
State Committed
Delegated to: Florian Weimer
Headers

Commit Message

Gabriel F T Gomes Oct. 28, 2016, 5:57 p.m. UTC
  Changes since v1:
  - Copy write_message from test-skeleton.c to dlfcn/bug-atexit3-lib.cc.
  - Replace calls to write with calls to write_message.

---8<---
The test case dlfcn/bug-atexit3-lib.cc calls write and doesn't check the
result.  When building with GCC 6.2, this generates a warning in 'make
check', which is treated as an error.  This patch replaces the call to
write with a call to write_message.

Tested for powerpc64le.

2016-10-28  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>

	* dlfcn/bug-atexit3-lib.cc (write_message): New function, copied
	from test-skeleton.c.
	(statclass): Replace calls to write with calls to write_message.
---
 dlfcn/bug-atexit3-lib.cc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
  

Comments

Florian Weimer Oct. 28, 2016, 8:38 p.m. UTC | #1
On 10/28/2016 07:57 PM, Gabriel F. T. Gomes wrote:

> 2016-10-28  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>
>
> 	* dlfcn/bug-atexit3-lib.cc (write_message): New function, copied
> 	from test-skeleton.c.
> 	(statclass): Replace calls to write with calls to write_message.

Looks good to me.

Thanks,
Florian
  
Gabriel F T Gomes Oct. 28, 2016, 9:46 p.m. UTC | #2
On Fri, 28 Oct 2016 22:38:10 +0200
Florian Weimer <fweimer@redhat.com> wrote:

> On 10/28/2016 07:57 PM, Gabriel F. T. Gomes wrote:
> 
> > 2016-10-28  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>
> >
> > 	* dlfcn/bug-atexit3-lib.cc (write_message): New function, copied
> > 	from test-skeleton.c.
> > 	(statclass): Replace calls to write with calls to write_message.  
> 
> Looks good to me.

Thank you.  Pushed as 1b16ff0b.
  

Patch

diff --git a/dlfcn/bug-atexit3-lib.cc b/dlfcn/bug-atexit3-lib.cc
index 3d01ea8..aba7720 100644
--- a/dlfcn/bug-atexit3-lib.cc
+++ b/dlfcn/bug-atexit3-lib.cc
@@ -1,14 +1,22 @@ 
 #include <unistd.h>
+#include <string.h>
+
+static void
+write_message (const char *message)
+{
+  ssize_t unused __attribute__ ((unused));
+  unused = write (STDOUT_FILENO, message, strlen (message));
+}
 
 struct statclass
 {
   statclass()
   {
-    write (1, "statclass\n", 10);
+    write_message ("statclass\n");
   }
   ~statclass()
   {
-    write (1, "~statclass\n", 11);
+    write_message ("~statclass\n");
   }
 };