|
From: <gi...@cr...> - 2012-02-29 23:42:43
|
via 72d282bcc77ac5db162a6563e87e6a115ab00785 (commit)
from 38276ccf6c37ee355bb313769e00acfc0a61e767 (commit)
-----------------------------------------------------------------------
commit 72d282bcc77ac5db162a6563e87e6a115ab00785
Author: Adam Borowski <kil...@an...>
Date: Thu Mar 1 00:38:47 2012 +0100
Hackily hush a spurious warning if hardening is on.
Ubuntu and now Debian enable it by default for package builds (but not
regular gcc use), which causes spam.
-----------------------------------------------------------------------
Summary of changes:
crawl-ref/source/libunix.cc | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc
index 6529de7..6501e46 100644
--- a/crawl-ref/source/libunix.cc
+++ b/crawl-ref/source/libunix.cc
@@ -390,7 +390,12 @@ void console_startup(void)
termio_init();
#ifdef CURSES_USE_KEYPAD
- write(1, KPADAPP, strlen(KPADAPP));
+ // If hardening is enabled (default on recent distributions), glibc
+ // declares write() with __attribute__((warn_unused_result)) which not
+ // only spams when not relevant, but cannot even be selectively hushed
+ // by (void) casts like all other such warnings.
+ // "if ();" is an unsightly hack...
+ if (write(1, KPADAPP, strlen(KPADAPP)));
#endif
#ifdef USE_UNIX_SIGNALS
@@ -438,7 +443,8 @@ void console_shutdown()
tcsetattr(0, TCSAFLUSH, &def_term);
#ifdef CURSES_USE_KEYPAD
- write(1, KPADCUR, strlen(KPADCUR));
+ // "if ();" to avoid undisableable spurious warning.
+ if (write(1, KPADCUR, strlen(KPADCUR)));
#endif
#ifdef USE_UNIX_SIGNALS
--
Dungeon Crawl Stone Soup
|