[LEDE-DEV] rtnl_flush: Error on failed write()

Message ID 20170617163836.37795-1-raj.khem@gmail.com
State New
Headers show

Commit Message

Khem Raj June 17, 2017, 4:38 p.m.
Fixes
route.c:45:2: error: ignoring return value of 'write', declared with attribute warn_unused_result [-Werror=unused-result]
|   write(fd, "-1", 2);
|   ^~~~~~~~~~~~~~~~~~

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 route.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Florian Fainelli June 17, 2017, 8:29 p.m. | #1
Le 06/17/17 à 09:38, Khem Raj a écrit :
> Fixes
> route.c:45:2: error: ignoring return value of 'write', declared with attribute warn_unused_result [-Werror=unused-result]
> |   write(fd, "-1", 2);
> |   ^~~~~~~~~~~~~~~~~~
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>

Which project in LEDE did you intend this to be applied to? If you make
submissions in the future can you specify the sub-project in the
subject, e.g: [PATCH procd] Blah blah

Thanks!

> ---
>  route.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/route.c b/route.c
> index c552d1f..fc5c31e 100644
> --- a/route.c
> +++ b/route.c
> @@ -42,7 +42,8 @@ static void rtnl_flush(void)
>  	if (fd < 0)
>  		return;
>  
> -	write(fd, "-1", 2);
> +	if (write(fd, "-1", 2) < 0 )
> +		perror("write");
>  	close(fd);
>  }
>  
>

Patch

diff --git a/route.c b/route.c
index c552d1f..fc5c31e 100644
--- a/route.c
+++ b/route.c
@@ -42,7 +42,8 @@  static void rtnl_flush(void)
 	if (fd < 0)
 		return;
 
-	write(fd, "-1", 2);
+	if (write(fd, "-1", 2) < 0 )
+		perror("write");
 	close(fd);
 }