From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753348AbcGTBxO (ORCPT ); Tue, 19 Jul 2016 21:53:14 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:42623 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753317AbcGTBxL (ORCPT ); Tue, 19 Jul 2016 21:53:11 -0400 Subject: Re: [PATCH v2] Documentation/watchdog: check return value for magic close To: Arnd Bergmann , Wim Van Sebroeck References: <20160719154136.3132886-1-arnd@arndb.de> Cc: Jonathan Corbet , Timur Tabi , linux-watchdog@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org From: Guenter Roeck Message-ID: <578ED974.7060201@roeck-us.net> Date: Tue, 19 Jul 2016 18:52:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <20160719154136.3132886-1-arnd@arndb.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/19/2016 08:41 AM, Arnd Bergmann wrote: > 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 Reviewed-by: Guenter Roeck > --- > v2: fix typo as pointed out by both Guenter Roeck and Randy Dunlap > --- > 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..6983d05097e2 100644 > --- a/Documentation/watchdog/src/watchdog-test.c > +++ b/Documentation/watchdog/src/watchdog-test.c > @@ -2,6 +2,7 @@ > * Watchdog Driver Test Program > */ > > +#include > #include > #include > #include > @@ -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("Stopping watchdog ticks failed (%d)...\n", errno); > close(fd); > return 0; > } >