aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-07-19 11:41:22 -0400
committerWim Van Sebroeck <wim@iguana.be>2016-07-25 05:02:17 -0400
commit9dd8d5f870f44597c67d0e5f72753b9d02810308 (patch)
tree3be87d80ea4667be11371c8148df7ba81824a67f
parente035d8f787b1de664fcac5eb84643f8c374284c4 (diff)
Documentation/watchdog: check return value for magic close
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> Acked-by: Timur Tabi <timur@codeaurora.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
-rw-r--r--Documentation/watchdog/src/watchdog-test.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Documentation/watchdog/src/watchdog-test.c b/Documentation/watchdog/src/watchdog-test.c
index c69153913722..6983d05097e2 100644
--- a/Documentation/watchdog/src/watchdog-test.c
+++ b/Documentation/watchdog/src/watchdog-test.c
@@ -2,6 +2,7 @@
2 * Watchdog Driver Test Program 2 * Watchdog Driver Test Program
3 */ 3 */
4 4
5#include <errno.h>
5#include <stdio.h> 6#include <stdio.h>
6#include <stdlib.h> 7#include <stdlib.h>
7#include <string.h> 8#include <string.h>
@@ -35,9 +36,13 @@ static void keep_alive(void)
35 36
36static void term(int sig) 37static void term(int sig)
37{ 38{
38 write(fd, &v, 1); 39 int ret = write(fd, &v, 1);
40
39 close(fd); 41 close(fd);
40 printf("\nStopping watchdog ticks...\n"); 42 if (ret < 0)
43 printf("\nStopping watchdog ticks failed (%d)...\n", errno);
44 else
45 printf("\nStopping watchdog ticks...\n");
41 exit(0); 46 exit(0);
42} 47}
43 48
@@ -45,6 +50,7 @@ int main(int argc, char *argv[])
45{ 50{
46 int flags; 51 int flags;
47 unsigned int ping_rate = 1; 52 unsigned int ping_rate = 1;
53 int ret;
48 54
49 setbuf(stdout, NULL); 55 setbuf(stdout, NULL);
50 56
@@ -91,7 +97,9 @@ int main(int argc, char *argv[])
91 sleep(ping_rate); 97 sleep(ping_rate);
92 } 98 }
93end: 99end:
94 write(fd, &v, 1); 100 ret = write(fd, &v, 1);
101 if (ret < 0)
102 printf("Stopping watchdog ticks failed (%d)...\n", errno);
95 close(fd); 103 close(fd);
96 return 0; 104 return 0;
97} 105}