[makedumpfile PATCH] fix compiler warnings

Atsushi Kumagai ats-kumagai at wm.jp.nec.com
Fri Jul 14 00:44:02 PDT 2017


Hello Eric,

Thanks, I'll merge this into v1.6.2.

Regards,
Atsushi Kumagai

>When building makedumpfile with GCC 5.4, I observe a few warnings:
>
>% make LINKTYPE=dynamic
>
>sadump_info.c: In function ‘sadump_is_dumpable’:
>sadump_info.c:145:3: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result
>[-Wunused-result]
>   read(bitmap->fd, bitmap->buf, BUFSIZE_BITMAP);
>   ^
>In file included from sadump_info.c:21:0:
>makedumpfile.h: In function ‘is_dumpable_file’:
>makedumpfile.h:1992:3: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result
>[-Wunused-result]
>   read(bitmap->fd, bitmap->buf, BUFSIZE_BITMAP);
>   ^
>makedumpfile.c: In function ‘write_eraseinfo’:
>makedumpfile.c:8273:4: warning: format not a string literal and no format arguments [-Wformat-security]
>    DEBUG_MSG(obuf);
>    ^
>makedumpfile.c:8273:4: warning: format not a string literal and no format arguments [-Wformat-security]
>In file included from makedumpfile.c:16:0:
>makedumpfile.h: In function ‘is_dumpable_file’:
>makedumpfile.h:1992:3: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result
>[-Wunused-result]
>   read(bitmap->fd, bitmap->buf, BUFSIZE_BITMAP);
>   ^
>
>This patch eliminates the warnings.
>
>Signed-off-by: Eric DeVolder <eric.devolder at oracle.com>
>---
>v1: 12jul2017 posted to kexec-tools mailing list
>---
> makedumpfile.c | 2 +-
> makedumpfile.h | 6 +++++-
> sadump_info.c  | 6 +++++-
> 3 files changed, 11 insertions(+), 3 deletions(-)
>
>diff --git a/makedumpfile.c b/makedumpfile.c
>index e69b6df..8b8a6b0 100644
>--- a/makedumpfile.c
>+++ b/makedumpfile.c
>@@ -8270,7 +8270,7 @@ write_eraseinfo(struct cache_data *cd_page, unsigned long *size_out)
> 			}
> 			sprintf(obuf, "erase %s %s", erase_info[i].symbol_expr,
> 							size_str);
>-			DEBUG_MSG(obuf);
>+			DEBUG_MSG("%s", obuf);
> 			if (!write_cache(cd_page, obuf, strlen(obuf)))
> 				goto out;
> 			size_eraseinfo += strlen(obuf);
>diff --git a/makedumpfile.h b/makedumpfile.h
>index e32e567..38ea673 100644
>--- a/makedumpfile.h
>+++ b/makedumpfile.h
>@@ -1981,6 +1981,7 @@ static inline int
> is_dumpable_file(struct dump_bitmap *bitmap, mdf_pfn_t pfn)
> {
> 	off_t offset;
>+	ssize_t rcode;
> 	if (pfn == 0 || bitmap->no_block != pfn/PFN_BUFBITMAP) {
> 		offset = bitmap->offset + BUFSIZE_BITMAP*(pfn/PFN_BUFBITMAP);
> 		if (lseek(bitmap->fd, offset, SEEK_SET) < 0 ) {
>@@ -1989,7 +1990,10 @@ is_dumpable_file(struct dump_bitmap *bitmap, mdf_pfn_t pfn)
> 			return FALSE;
> 		}
>
>-		read(bitmap->fd, bitmap->buf, BUFSIZE_BITMAP);
>+		rcode = read(bitmap->fd, bitmap->buf, BUFSIZE_BITMAP);
>+		if (rcode != BUFSIZE_BITMAP)
>+			ERRMSG("Can't read the bitmap(%s). %s\n",
>+				bitmap->file_name, strerror(errno));
> 		if (pfn == 0)
> 			bitmap->no_block = 0;
> 		else
>diff --git a/sadump_info.c b/sadump_info.c
>index f77a020..9a6b977 100644
>--- a/sadump_info.c
>+++ b/sadump_info.c
>@@ -138,11 +138,15 @@ static inline int
> sadump_is_dumpable(struct dump_bitmap *bitmap, mdf_pfn_t pfn)
> {
> 	off_t offset;
>+	ssize_t rcode;
>
> 	if (pfn == 0 || bitmap->no_block != pfn/PFN_BUFBITMAP) {
> 		offset = bitmap->offset + BUFSIZE_BITMAP*(pfn/PFN_BUFBITMAP);
> 		lseek(bitmap->fd, offset, SEEK_SET);
>-		read(bitmap->fd, bitmap->buf, BUFSIZE_BITMAP);
>+		rcode = read(bitmap->fd, bitmap->buf, BUFSIZE_BITMAP);
>+		if (rcode != BUFSIZE_BITMAP)
>+			ERRMSG("Can't read the bitmap(%s). %s\n",
>+				bitmap->file_name, strerror(errno));
> 		if (pfn == 0)
> 			bitmap->no_block = 0;
> 		else
>--
>2.7.4


More information about the kexec mailing list