All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] [Xenomai-forge] [PATCH] Silence unused_result warning from write()
@ 2013-11-07  9:22 Gernot Hillier
  2013-11-07 18:01 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 8+ messages in thread
From: Gernot Hillier @ 2013-11-07  9:22 UTC (permalink / raw)
  To: xenomai

Some glibc versions mark write() with attribute warn_unused_result (found in
Ubuntu 12.04 / eglibc 2.15 / gcc 4.6.3), so we need to silence this warning,
especially when building with -Werror.

Signed-off-by: Gernot Hillier <gernot.hillier@siemens.com>
---
 lib/cobalt/init.c           | 4 +++-
 testsuite/latency/latency.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c
index 101a2bd..568f9d0 100644
--- a/lib/cobalt/init.c
+++ b/lib/cobalt/init.c
@@ -53,7 +53,9 @@ int __rtdm_fd_start = INT_MAX;
 static void sigill_handler(int sig)
 {
 	const char m[] = "no Xenomai support in kernel?\n";
-	write(2, m, sizeof(m) - 1);
+	if (write(2, m, sizeof(m) - 1) < 1) {
+		/* Silence unused_result warning. No handling in error case, though. */
+	}
 	exit(EXIT_FAILURE);
 }
 
diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c
index 7c5099b..b9e1f00 100644
--- a/testsuite/latency/latency.c
+++ b/testsuite/latency/latency.c
@@ -507,7 +507,9 @@ static void sigdebug(int sig, siginfo_t *si, void *context)
 	case SIGDEBUG_WATCHDOG:
 		n = snprintf(buffer, sizeof(buffer), "%s\n",
 			     reason_str[reason]);
-		write(STDERR_FILENO, buffer, n);
+		if (write(STDERR_FILENO, buffer, n) < 1) {
+			/* Silence unused_result warning. No handling in error case, though. */
+		}
 		exit(EXIT_FAILURE);
 	}
 
-- 
1.8.1.2

-- 
Regards,

Gernot Hillier
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-01-14 12:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-07  9:22 [Xenomai] [Xenomai-forge] [PATCH] Silence unused_result warning from write() Gernot Hillier
2013-11-07 18:01 ` Gilles Chanteperdrix
2013-11-08  5:55   ` Gernot Hillier
2013-11-08 17:23     ` Gilles Chanteperdrix
2013-11-08 18:18       ` Jan Kiszka
2013-11-11  8:36         ` dietmar.schindler
2013-11-11 10:00           ` Gernot Hillier
2014-01-14 12:28       ` [Xenomai] [Xenomai-forge] [PATCH v2] " Gernot Hillier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.