Page MenuHome GnuPG

Spurious warning: ignoring return value of ‘write’ ...
Closed, SpitePublic

Description

I'm building GnuPG and components from Master using GCC 7.5 on Ubuntu Bionic with the standard project settings. There's some noise from GCC about ignoring return values from write.

Since the void cast is no longer working as expected.... I believe the way to clear the noise in a portable way is:

#ifndef UNUSED
# define UNUSED(x) ((void)(x))
#endif

ssize_t res = write (2, "\n", 1 );
UNUSED(res);

signal.c: In function ‘got_fatal_signal’:
signal.c:111:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
   (void)write (2, "\n", 1 );
   ^~~~~~~~~~~~~~~~~~~~~~~~~
signal.c:114:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
     (void)write(2, s, strlen (s));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
signal.c:115:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
   (void)write (2, ": signal ", 9 );
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
signal.c:118:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
     (void) write (2, s, strlen(s) );
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
signal.c:128:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
         (void)write (2, "?", 1);
         ^~~~~~~~~~~~~~~~~~~~~~~
signal.c:137:19: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
                   (void)write (2, &"0123456789"[value/i], 1);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
signal.c:145:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
   (void)write (2, " caught ... exiting\n", 20);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Details

Version
git-master

Event Timeline

JW created this object in space S1 Public.
werner claimed this task.
werner added a subscriber: werner.

Please stop this and use the mailing list for such ramblings. Usually only one developer reads a bug report and thus you can't participate from the experience of others - use mailing lists - please.

There is nothing spiteful about this other than your actions.