* [PATCH] Fix warning caused by unused-result in bug-atexit3-lib.cc
@ 2016-10-28 13:01 Gabriel F. T. Gomes
2016-10-28 13:04 ` Florian Weimer
0 siblings, 1 reply; 7+ messages in thread
From: Gabriel F. T. Gomes @ 2016-10-28 13:01 UTC (permalink / raw)
To: libc-alpha
The test case dlfcn/bug-atexit3-lib.cc calls write and doesn't check the
result. When building with GCC 6.2 from IBM's branch, this generates a
warning in 'make check', which is treated as an error. This patch adds a
return variable to get rid of the warning and of the error.
Tested for powerpc64le.
2016-10-28 Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
* dlfcn/bug-atexit3-lib.cc (statclass): Assign return of call to
write (defined with __wur) to unused variable.
---
dlfcn/bug-atexit3-lib.cc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/dlfcn/bug-atexit3-lib.cc b/dlfcn/bug-atexit3-lib.cc
index 3d01ea8..5a7c454 100644
--- a/dlfcn/bug-atexit3-lib.cc
+++ b/dlfcn/bug-atexit3-lib.cc
@@ -4,11 +4,15 @@ struct statclass
{
statclass()
{
- write (1, "statclass\n", 10);
+ size_t unused_ret;
+ (void) unused_ret;
+ unused_ret = write (1, "statclass\n", 10);
}
~statclass()
{
- write (1, "~statclass\n", 11);
+ size_t unused_ret;
+ (void) unused_ret;
+ unused_ret = write (1, "~statclass\n", 11);
}
};
--
2.4.11
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix warning caused by unused-result in bug-atexit3-lib.cc
2016-10-28 13:01 [PATCH] Fix warning caused by unused-result in bug-atexit3-lib.cc Gabriel F. T. Gomes
@ 2016-10-28 13:04 ` Florian Weimer
2016-10-28 13:33 ` Gabriel F. T. Gomes
0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2016-10-28 13:04 UTC (permalink / raw)
To: Gabriel F. T. Gomes; +Cc: libc-alpha
On 10/28/2016 03:00 PM, Gabriel F. T. Gomes wrote:
> The test case dlfcn/bug-atexit3-lib.cc calls write and doesn't check the
> result. When building with GCC 6.2 from IBM's branch, this generates a
> warning in 'make check', which is treated as an error. This patch adds a
> return variable to get rid of the warning and of the error.
You could use write_message from test-skeleton.c instead. it has a
proper unused variable guard.
Thanks,
Florian
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix warning caused by unused-result in bug-atexit3-lib.cc
2016-10-28 13:04 ` Florian Weimer
@ 2016-10-28 13:33 ` Gabriel F. T. Gomes
2016-10-28 13:35 ` Florian Weimer
0 siblings, 1 reply; 7+ messages in thread
From: Gabriel F. T. Gomes @ 2016-10-28 13:33 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On Fri, 28 Oct 2016 15:04:13 +0200
Florian Weimer <fweimer@redhat.com> wrote:
> On 10/28/2016 03:00 PM, Gabriel F. T. Gomes wrote:
> > The test case dlfcn/bug-atexit3-lib.cc calls write and doesn't check the
> > result. When building with GCC 6.2 from IBM's branch, this generates a
> > warning in 'make check', which is treated as an error. This patch adds a
> > return variable to get rid of the warning and of the error.
>
> You could use write_message from test-skeleton.c instead. it has a
> proper unused variable guard.
Is it ok to use write_message in c++ code being built as object?
Thanks,
Gabriel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix warning caused by unused-result in bug-atexit3-lib.cc
2016-10-28 13:33 ` Gabriel F. T. Gomes
@ 2016-10-28 13:35 ` Florian Weimer
2016-10-28 17:58 ` [PATCH v2] " Gabriel F. T. Gomes
0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2016-10-28 13:35 UTC (permalink / raw)
To: Gabriel F. T. Gomes; +Cc: libc-alpha
On 10/28/2016 03:32 PM, Gabriel F. T. Gomes wrote:
> On Fri, 28 Oct 2016 15:04:13 +0200
> Florian Weimer <fweimer@redhat.com> wrote:
>
>> On 10/28/2016 03:00 PM, Gabriel F. T. Gomes wrote:
>>> The test case dlfcn/bug-atexit3-lib.cc calls write and doesn't check the
>>> result. When building with GCC 6.2 from IBM's branch, this generates a
>>> warning in 'make check', which is treated as an error. This patch adds a
>>> return variable to get rid of the warning and of the error.
>>
>> You could use write_message from test-skeleton.c instead. it has a
>> proper unused variable guard.
>
> Is it ok to use write_message in c++ code being built as object?
Oh, right, this probably will not work. Bummer.
You could copy the function into the .cc file, though. The unused
attribute may be needed in the long term.
Florian
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] Fix warning caused by unused-result in bug-atexit3-lib.cc
2016-10-28 13:35 ` Florian Weimer
@ 2016-10-28 17:58 ` Gabriel F. T. Gomes
2016-10-28 20:38 ` Florian Weimer
0 siblings, 1 reply; 7+ messages in thread
From: Gabriel F. T. Gomes @ 2016-10-28 17:58 UTC (permalink / raw)
To: fweimer; +Cc: libc-alpha
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(-)
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");
}
};
--
2.4.11
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] Fix warning caused by unused-result in bug-atexit3-lib.cc
2016-10-28 17:58 ` [PATCH v2] " Gabriel F. T. Gomes
@ 2016-10-28 20:38 ` Florian Weimer
2016-10-28 21:47 ` Gabriel F. T. Gomes
0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2016-10-28 20:38 UTC (permalink / raw)
To: Gabriel F. T. Gomes; +Cc: libc-alpha
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] Fix warning caused by unused-result in bug-atexit3-lib.cc
2016-10-28 20:38 ` Florian Weimer
@ 2016-10-28 21:47 ` Gabriel F. T. Gomes
0 siblings, 0 replies; 7+ messages in thread
From: Gabriel F. T. Gomes @ 2016-10-28 21:47 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-10-28 21:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-28 13:01 [PATCH] Fix warning caused by unused-result in bug-atexit3-lib.cc Gabriel F. T. Gomes
2016-10-28 13:04 ` Florian Weimer
2016-10-28 13:33 ` Gabriel F. T. Gomes
2016-10-28 13:35 ` Florian Weimer
2016-10-28 17:58 ` [PATCH v2] " Gabriel F. T. Gomes
2016-10-28 20:38 ` Florian Weimer
2016-10-28 21:47 ` Gabriel F. T. Gomes
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).