[LEDE-DEV] [PATCH uclient v2] Fix unused results warnings

Felix Fietkau nbd at nbd.name
Mon Dec 5 09:23:13 PST 2016


On 2016-12-05 00:15, Florian Fainelli wrote:
> Fixes:
> 
> uclient-http.c:385:8: error: ignoring return value of 'fread', declared with attribute warn_unused_result [-Werror=unused-result]
>    fread(&val, sizeof(val), 1, f);
>         ^
> 
> uclient-fetch.c: In function 'main':
> uclient-fetch.c:664:12: error: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Werror=unused-result]
>     asprintf(&auth_str, "%s:%s", username, password);
>             ^
> uclient-fetch.c: In function 'read_data_cb':
> uclient-fetch.c:269:9: error: ignoring return value of 'write', declared with attribute warn_unused_result [-Werror=unused-result]
>     write(output_fd, buf, len);
> 
> Signed-off-by: Florian Fainelli <f.fainelli at gmail.com>
> ---
>  uclient-fetch.c | 16 +++++++++++-----
>  uclient-http.c  |  5 ++++-
>  2 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/uclient-fetch.c b/uclient-fetch.c
> index 4c603fbc1945..16fd3ca0c345 100644
> --- a/uclient-fetch.c
> +++ b/uclient-fetch.c
> @@ -254,6 +254,7 @@ static void header_done_cb(struct uclient *cl)
>  static void read_data_cb(struct uclient *cl)
>  {
>  	char buf[256];
> +	size_t n;
>  	int len;
>  
>  	if (!no_output && output_fd < 0)
> @@ -265,8 +266,11 @@ static void read_data_cb(struct uclient *cl)
>  			return;
>  
>  		out_bytes += len;
> -		if (!no_output)
> -			write(output_fd, buf, len);
> +		if (!no_output) {
> +			n = write(output_fd, buf, len);
> +			if (n < 0)
With size_t, n < 0 is never true (leading to another warning with some
compilers). Please use ssize_t.

- Felix




More information about the Lede-dev mailing list