From: Arnd Bergmann <arnd@arndb.de>
To: Wim Van Sebroeck <wim@iguana.be>
Cc: Arnd Bergmann <arnd@arndb.de>, Guenter Roeck <linux@roeck-us.net>,
Jonathan Corbet <corbet@lwn.net>,
Timur Tabi <timur@codeaurora.org>,
linux-watchdog@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] Documentation/watchdog: check return value for magic close
Date: Tue, 19 Jul 2016 11:24:50 +0200 [thread overview]
Message-ID: <20160719092522.6397-1-arnd@arndb.de> (raw)
A recent commit added a write to the watchdog test code for doing the "magic
close", but that caused a compile-time warning:
Documentation/watchdog/src/watchdog-test.c: In function ‘main’:
Documentation/watchdog/src/watchdog-test.c:94:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
This changes the code to print a runtime warning if the write fails.
Fixes: 5a2d3de19602 ("Documentation/watchdog: add support for magic close to watchdog-test")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Documentation/watchdog/src/watchdog-test.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/Documentation/watchdog/src/watchdog-test.c b/Documentation/watchdog/src/watchdog-test.c
index c69153913722..52eea54649ab 100644
--- a/Documentation/watchdog/src/watchdog-test.c
+++ b/Documentation/watchdog/src/watchdog-test.c
@@ -2,6 +2,7 @@
* Watchdog Driver Test Program
*/
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -35,9 +36,13 @@ static void keep_alive(void)
static void term(int sig)
{
- write(fd, &v, 1);
+ int ret = write(fd, &v, 1);
+
close(fd);
- printf("\nStopping watchdog ticks...\n");
+ if (ret < 0)
+ printf("\nStopping watchdog ticks failed (%d)...\n", errno);
+ else
+ printf("\nStopping watchdog ticks...\n");
exit(0);
}
@@ -45,6 +50,7 @@ int main(int argc, char *argv[])
{
int flags;
unsigned int ping_rate = 1;
+ int ret;
setbuf(stdout, NULL);
@@ -91,7 +97,9 @@ int main(int argc, char *argv[])
sleep(ping_rate);
}
end:
- write(fd, &v, 1);
+ ret = write(fd, &v, 1);
+ if (ret < 0)
+ printf("Sopping watchdog ticks failed (%d)...\n", errno);
close(fd);
return 0;
}
--
2.9.0
next reply other threads:[~2016-07-19 9:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-19 9:24 Arnd Bergmann [this message]
2016-07-19 13:26 ` [PATCH] Documentation/watchdog: check return value for magic close Guenter Roeck
2016-07-19 14:54 ` Randy Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160719092522.6397-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=timur@codeaurora.org \
--cc=wim@iguana.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox