lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <fc9151de-4870-8441-5e75-7504a0eb107e@infradead.org>
Date:	Tue, 19 Jul 2016 07:54:37 -0700
From:	Randy Dunlap <rdunlap@...radead.org>
To:	Arnd Bergmann <arnd@...db.de>, Wim Van Sebroeck <wim@...ana.be>
Cc:	Guenter Roeck <linux@...ck-us.net>,
	Jonathan Corbet <corbet@....net>,
	Timur Tabi <timur@...eaurora.org>,
	linux-watchdog@...r.kernel.org, linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Documentation/watchdog: check return value for magic
 close

On 07/19/16 02:24, 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 <arnd@...db.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);

Stopping

>      close(fd);
>      return 0;
>  }
> 


-- 
~Randy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ