[PATCH 4/5] i386: fix string formatting-related warnings

Ahelenia Ziemiańska nabijaczleweli at nabijaczleweli.xyz
Fri Oct 9 11:39:58 EDT 2020


fixed the same way as in 70cca82
"kexec: Fix snprintf related compilation warnings"

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli at nabijaczleweli.xyz>
---
 kexec/arch/i386/x86-linux-setup.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
index 057ee14..76e1185 100644
--- a/kexec/arch/i386/x86-linux-setup.c
+++ b/kexec/arch/i386/x86-linux-setup.c
@@ -232,8 +232,14 @@ static int parse_edd_extensions(const char *dir, struct edd_info *edd_info)
 	char line[1024];
 	uint16_t flags = 0;
 	FILE *fp;
+	int ret;
+
+	ret = snprintf(filename, PATH_MAX, "%s/%s", dir, "extensions");
+	if (ret < 0 || ret >= PATH_MAX) {
+		fprintf(stderr, "snprintf failed: %s\n", strerror(errno));
+		return -1;
+	}
 
-	snprintf(filename, PATH_MAX, "%s/%s", dir, "extensions");
 	filename[PATH_MAX-1] = 0;
 
 	fp = fopen(filename, "r");
@@ -269,8 +275,14 @@ static int read_edd_raw_data(const char *dir, struct edd_info *edd_info)
 	FILE *fp;
 	size_t read_chars;
 	uint16_t len;
+	int ret;
+
+	ret = snprintf(filename, PATH_MAX, "%s/%s", dir, "raw_data");
+	if (ret < 0 || ret >= PATH_MAX) {
+		fprintf(stderr, "snprintf failed: %s\n", strerror(errno));
+		return -1;
+	}
 
-	snprintf(filename, PATH_MAX, "%s/%s", dir, "raw_data");
 	filename[PATH_MAX-1] = 0;
 
 	fp = fopen(filename, "r");
-- 
2.28.0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kexec/attachments/20201009/1b349632/attachment-0001.sig>


More information about the kexec mailing list