[PATCH 5/6] kexec: Fix return value build warnings

Simon Horman horms at verge.net.au
Wed Oct 2 21:06:01 EDT 2013


On Wed, Oct 02, 2013 at 08:49:46PM +0000, Geoff Levand wrote:
> Add a local variable and check return values.

The patch seems to do a bit more than that.
Could you either split the patch up or enhance the changelog?

> 
> Fixes build warnings like these:
> 
>   kexec/fs2dt.c: warning: ignoring return value of ‘read’
> 
> Signed-off-by: Geoff Levand <geoff at infradead.org> for Huawei, Linaro
> ---
>  kexec/fs2dt.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> index 1f5b0cf..50e173e 100644
> --- a/kexec/fs2dt.c
> +++ b/kexec/fs2dt.c
> @@ -555,6 +555,7 @@ static void putnode(void)
>  	/* Add cmdline to the second kernel.  Check to see if the new
>  	 * cmdline has a root=.  If not, use the old root= cmdline.  */
>  	if (!strcmp(basename,"chosen/")) {
> +		size_t result;
>  		size_t cmd_len = 0;
>  		char *param = NULL;
>  		char filename[MAXPATH];
> @@ -636,8 +637,13 @@ static void putnode(void)
>  			close(fd);
>  			goto no_debug;
>  		}
> -		read(fd, buff, statbuf.st_size);
> +		result = read(fd, buff, statbuf.st_size);
>  		close(fd);
> +		if (result <= 0) {
> +			printf("Unable to stat %s, printing from purgatory is diabled\n",


It seems to me this should be "Unable to read..."

> +														filename);
> +			goto no_debug;
> +		}
>  		strncpy(filename, "/proc/device-tree/", MAXPATH);
>  		strncat(filename, buff, MAXPATH);
>  		strncat(filename, "/compatible", MAXPATH);
> @@ -659,8 +665,8 @@ static void putnode(void)
>  			close(fd);
>  			goto no_debug;
>  		}
> -		read(fd, buff, statbuf.st_size);
> -		if (!strcmp(buff, "hvterm1") || !strcmp(buff, "hvterm-protocol"))
> +		result = read(fd, buff, statbuf.st_size);
> +		if (result && (!strcmp(buff, "hvterm1") || !strcmp(buff, "hvterm-protocol")))
>  			my_debug = 1;
>  		close(fd);
>  		free(buff);
> -- 
> 1.8.1.2
> 
> 



More information about the kexec mailing list