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

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

 



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);
        |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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. */
-- 
2.42.0


_______________________________________________
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