While building postfix for Debian a couple of compiler warnings show
up, all caused by the warning `-Wunused-result`[1].
Two of them are caused by attempts to silence compilers via a
void-cast, but GCC does not respect that, see [2].
One solution is to cast the negated result, i.e. `(void)! foo(...)`,
suggested at [3].
mail_copy.c: In function ‘mail_copy’:
mail_copy.c:289:20: warning: ignoring return value of ‘ftruncate’
declared with attribute ‘warn_unused_result’ [-Wunused-result]
289 | (void) ftruncate(vstream_fileno(dst), orig_length);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
postscreen.c: In function ‘psc_endpt_lookup_done’:
postscreen.c:706:16: warning: ignoring return value of ‘write’
declared with attribute ‘warn_unused_result’ [-Wunused-result]
706 | (void) write(vstream_fileno(smtp_client_stream),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
707 | "421 4.3.2 No system resources\r\n",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
708 | sizeof("421 4.3.2 No system
resources\r\n") - 1);
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The other five might be actual function to check:
dict_cdb.c: In function ‘dict_cdbm_open’:
dict_cdb.c:398:9: warning: ignoring return value of ‘ftruncate’
declared with attribute ‘warn_unused_result’ [-Wunused-result]
398 | ftruncate(fd, 0);
| ^~~~~~~~~~~~~~~~
debug_process.c: In function ‘debug_process’:
debug_process.c:61:5: warning: ignoring return value of ‘system’
declared with attribute ‘warn_unused_result’ [-Wunused-result]
61 | system(command);
| ^~~~~~~~~~~~~~~
In file included from mail_params.c:226:
mail_params.c: In function ‘read_param_from_file’:
../../include/vstring_vstream.h:38:9: warning: ignoring return
value of ‘vstring_get_flags_nonl’ declared with attribute
‘warn_unused_result’ [-Wunused-result]
38 | vstring_get_flags_nonl((string), (stream),
VSTRING_GET_FLAG_NONE)
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mail_params.c:615:5: note: in expansion of macro ‘vstring_get_nonl’
615 | vstring_get_nonl(buf, fp);
| ^~~~~~~~~~~~~~~~
pipe_command.c: In function ‘pipe_command’:
pipe_command.c:488:13: warning: ignoring return value of ‘seteuid’
declared with attribute ‘warn_unused_result’ [-Wunused-result]
488 | seteuid(0);
| ^~~~~~~~~~
master.c: In function ‘main’:
master.c:557:9: warning: ignoring return value of ‘write’ declared
with attribute ‘warn_unused_result’ [-Wunused-result]
557 | write(monitor_fd, "", 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~
[1]:
https://buildd.debian.org/status/fetch.php?pkg=postfix&arch=amd64&ver=3.6.3-5&stamp=1641330867&raw=0
[2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
[3]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c34