Re: [PATCH 1/2] makedumpfile: Add ftruncate error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024/08/15 23:17, Stefan Wiehler wrote:
> Found via -Werror:
> 
>    makedumpfile.c: In function ‘dump_dmesg’:
>    makedumpfile.c:5884:33: error: ignoring return value of ‘ftruncate’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
>     5884 |                                 ftruncate(info->fd_dumpfile, 0);
>          |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hi Stefan, thanks for the patch.

I tried to reproduce those warnings, but could not get either one
with a plain make command and gcc 14.1 (or clang 18.1).

out of curiosity, what compiler version and build command do you use?

Thanks,
Kazu

> 
> Signed-off-by: Stefan Wiehler <stefan.wiehler@xxxxxxxxx>
> ---
>   makedumpfile.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/makedumpfile.c b/makedumpfile.c
> index ce0d40e..c6f70ff 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -5881,7 +5881,11 @@ dump_dmesg()
>   				char *first;
>   
>   				/* Clear everything we have already written... */
> -				ftruncate(info->fd_dumpfile, 0);
> +				if (ftruncate(info->fd_dumpfile, 0) != 0) {
> +					ERRMSG("Can't truncate file(%s). %s\n",
> +					       info->name_dumpfile, strerror(errno));
> +					goto out;
> +				}
>   				lseek(info->fd_dumpfile, 0, SEEK_SET);
>   
>   				/* ...and only write up to the corruption. */
_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux