On Wed, Apr 29, 2020 at 08:40:39AM +0200, Ahmad Fatoum wrote:
> Errors are propagated in the loop and ret is never set. Remove it.
> 
> Signed-off-by: Ahmad Fatoum <[email protected]>
> ---
>  scripts/bareboximd.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/scripts/bareboximd.c b/scripts/bareboximd.c
> index b733cae61c87..d11b661fa391 100644
> --- a/scripts/bareboximd.c
> +++ b/scripts/bareboximd.c
> @@ -53,7 +53,7 @@ int imd_command_setenv(const char *variable_name, const 
> char *value)
>  
>  static int write_file(const char *filename, const void *buf, size_t size)
>  {
> -     int fd, ret;
> +     int fd;
>       int now;
>  
>       fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR | 
> S_IRGRP | S_IROTH);
> @@ -74,9 +74,6 @@ static int write_file(const char *filename, const void 
> *buf, size_t size)
>  
>       close(fd);
>  
> -     if (ret < 0)
> -             return ret;
> -

There's more wrong in this function. In the error path the file is never
closed. It is not an error when write() returns 0. The return value of
write_file() is never checked by the caller. Steffen, care to fix some
of these?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to