Skip to contentSkip to conversation

configure.ac: quote result of AC_CHECK_LIB()

PATCH Applied Yousong Zhou 2 participants 8 messages Jan 31, 2015 – Feb 10, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 configure.ac: quote result of AC_CHECK_LIB()

Fix the following error when searching for lzma support.

checking for lzma_code in -llzma... ./configure: line 4756: ac_fn_c_try_link: command not found

---
 configure.ac |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
configure.ac +6 -6
index 4e15cb0..212e838 100644
@@ -152,22 +152,22 @@ AC_CHECK_PROG([DIRNAME],  dirname,  dirname,  "no", [$PATH])
 dnl See if I have a usable copy of zlib available
 if test "$with_zlib" = yes ; then
 	AC_CHECK_HEADER(zlib.h,
-		AC_CHECK_LIB(z, inflateInit_, ,
-		AC_MSG_NOTICE([zlib support disabled])))
+		[AC_CHECK_LIB(z, inflateInit_, ,
+		AC_MSG_NOTICE([zlib support disabled]))])
 fi
 
 dnl See if I have a usable copy of lzma available
 if test "$with_lzma" = yes ; then
 	AC_CHECK_HEADER(lzma.h,
-		AC_CHECK_LIB(lzma, lzma_code, ,
-		AC_MSG_NOTICE([lzma support disabled])))
+		[AC_CHECK_LIB(lzma, lzma_code, ,
+		AC_MSG_NOTICE([lzma support disabled]))])
 fi
 
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then
 	AC_CHECK_HEADER(xenctrl.h,
-		AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
-		AC_MSG_NOTICE([Xen support disabled])))
+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+		AC_MSG_NOTICE([Xen support disabled]))])
 fi
 
 dnl ---Sanity checks
Signature · 7 lines
1.7.10.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

PATCH 2/3 Fix zlib/lzma decompression.

Let {zlib,lzma}_decompress_file() return NULL if anything wrong happened to allow the other method to have a chance to run.

---
 kexec/lzma.c |   33 ++++++++++++++++++++++-----------
 kexec/zlib.c |   57 +++++++++++++++++++++++++++++++++++----------------------
 2 files changed, 57 insertions(+), 33 deletions(-)
kexec/lzma.c +22 -11
index 939aeb3..5bfccb7 100644
@@ -162,13 +162,16 @@ char *lzma_decompress_file(const char *filename, off_t *r_size)
 	off_t size, allocated;
 	ssize_t result;
 
-	if (!filename) {
-		*r_size = 0;
-		return 0;
-	}
+	dbgprintf("Try LZMA decompression.\n");
+
+	*r_size = 0;
+	if (!filename)
+		return NULL;
+
 	fp = lzopen(filename, "rb");
 	if (fp == 0) {
-		die("Cannot open `%s'\n", filename);
+		dbgprintf("Cannot open `%s'\n", filename);
+		return NULL;
 	}
 	size = 0;
 	allocated = 65536;
@@ -183,17 +186,25 @@ char *lzma_decompress_file(const char *filename, off_t *r_size)
 			if ((errno == EINTR) || (errno == EAGAIN))
 				continue;
 
-			die ("read on %s of %ld bytes failed\n",
-				filename, (allocated - size) + 0UL);
+			dbgprintf("%s: read on %s of %ld bytes failed\n",
+				__func__, filename, (allocated - size) + 0UL);
+			break;
 		}
 		size += result;
-	} while(result > 0);
-	result = lzclose(fp);
-	if (result != LZMA_OK) {
-		die ("Close of %s failed\n", filename);
+	} while (result > 0);
+
+	if (lzclose(fp) != LZMA_OK) {
+		dbgprintf("%s: Close of %s failed\n", __func__, filename);
+		goto fail;
 	}
+	if (result < 0)
+		goto fail;
+
 	*r_size =  size;
 	return buf;
+fail:
+	free(buf);
+	return NULL;
 }
 #else
 char *lzma_decompress_file(const char *UNUSED(filename), off_t *UNUSED(r_size))
kexec/zlib.c +35 -22

89 lines not on this page · raw message

Signature · 7 lines
1.7.10.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#3 lore raw

PATCH 3/3 Fix a few compilation warnings.

In reply to Yousong Zhou
---
 kexec/arch/mips/crashdump-mips.c |    3 ++-
 kexec/arch/mips/kexec-elf-mips.c |    2 +-
 kexec/kexec-elf-rel.c            |    3 +++
 kexec/kexec.h                    |    2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)
kexec/arch/mips/crashdump-mips.c +2 -1
index e7840e0..98c9f7c 100644
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <limits.h>
+#include <inttypes.h>
 #include <elf.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -52,7 +53,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info)
 
 	if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) {
 		elf_info->kern_paddr_start = start;
-		dbgprintf("kernel load physical addr start = 0x%lx\n", start);
+		dbgprintf("kernel load physical addr start = 0x%" PRIu64 "\n", start);
 		return 0;
 	}
 
kexec/arch/mips/kexec-elf-mips.c +1 -1
index a27d986..8a6419a 100644
@@ -158,7 +158,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
 	if (info->kexec_flags & KEXEC_ON_CRASH)
 		/* In case of crashdump segment[0] is kernel.
 		 * Put cmdline just after it. */
-		cmdline_addr = info->segment[0].mem +
+		cmdline_addr = (unsigned long)info->segment[0].mem +
 				info->segment[0].memsz;
 	else
 		cmdline_addr = 0;
kexec/kexec-elf-rel.c +3 -0
index c625f30..5a5fcd1 100644
@@ -347,6 +347,9 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,
 			else if (shdr->sh_type == SHT_RELA) {
 				rel = elf_rela(ehdr, ptr);
 			}
+			else {
+				die("Unexpected sh_type: %d\n", shdr->sh_type);
+			}
 			/* the location to change */
 			location = section->sh_data + rel.r_offset;
 
kexec/kexec.h +1 -1
index 4be2b2f..2c85052 100644
@@ -245,7 +245,7 @@ extern int file_types;
 
 extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);
 extern void die(const char *fmt, ...)
-	__attribute__ ((format (printf, 1, 2)));
+	__attribute__ ((format (printf, 1, 2), noreturn));
 extern void *xmalloc(size_t size);
 extern void *xrealloc(void *ptr, size_t size);
 extern char *slurp_file(const char *filename, off_t *r_size);
Signature · 7 lines
1.7.10.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#4 lore raw

Re: [PATCH 3/3] Fix a few compilation warnings.

These changes do not seem to be related to each other. Please split this into 4 separate patches each with a changelog that briefly describes what the problem is.

Quoted 35 lines · Yousong Zhou
---
 kexec/arch/mips/crashdump-mips.c |    3 ++-
 kexec/arch/mips/kexec-elf-mips.c |    2 +-
 kexec/kexec-elf-rel.c            |    3 +++
 kexec/kexec.h                    |    2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)
kexec/arch/mips/crashdump-mips.c +2 -1
index e7840e0..98c9f7c 100644
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <limits.h>
+#include <inttypes.h>
 #include <elf.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -52,7 +53,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info)
 
 	if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) {
 		elf_info->kern_paddr_start = start;
-		dbgprintf("kernel load physical addr start = 0x%lx\n", start);
+		dbgprintf("kernel load physical addr start = 0x%" PRIu64 "\n", start);
 		return 0;
 	}
 
kexec/arch/mips/kexec-elf-mips.c +0 -0
index a27d986..8a6419a 100644

kexec/arch/mips/kexec-elf-mips.c int elf_mips_load(int argc, char **argv, const char *buf, off_t len, · line 162

Quoted 6 lines
kexec/arch/mips/kexec-elf-mips.c +1 -1
@@ -158,7 +158,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
 	if (info->kexec_flags & KEXEC_ON_CRASH)
 		/* In case of crashdump segment[0] is kernel.
 		 * Put cmdline just after it. */
-		cmdline_addr = info->segment[0].mem +
+		cmdline_addr = (unsigned long)info->segment[0].mem +
 				info->segment[0].memsz;

I wonder if we can resolve this without resorting to a cast.

Quoted 32 lines
kexec/arch/mips/kexec-elf-mips.c +0 -0
 	else
 		cmdline_addr = 0;
kexec/kexec-elf-rel.c +3 -0
index c625f30..5a5fcd1 100644
@@ -347,6 +347,9 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,
 			else if (shdr->sh_type == SHT_RELA) {
 				rel = elf_rela(ehdr, ptr);
 			}
+			else {
+				die("Unexpected sh_type: %d\n", shdr->sh_type);
+			}
 			/* the location to change */
 			location = section->sh_data + rel.r_offset;
 
kexec/kexec.h +1 -1
index 4be2b2f..2c85052 100644
@@ -245,7 +245,7 @@ extern int file_types;
 
 extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);
 extern void die(const char *fmt, ...)
-	__attribute__ ((format (printf, 1, 2)));
+	__attribute__ ((format (printf, 1, 2), noreturn));
 extern void *xmalloc(size_t size);
 extern void *xrealloc(void *ptr, size_t size);
 extern char *slurp_file(const char *filename, off_t *r_size);
Signature · 1 line
1.7.10.4

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#5 lore raw

Re: [PATCH 3/3] Fix a few compilation warnings.

Quoted 4 lines · Simon Horman

These changes do not seem to be related to each other. Please split this into 4 separate patches each with a changelog that briefly describes what the problem is.

Will split them each into a separate patch.

Quoted 31 lines · Yousong Zhou
Quoted 30 lines
---
 kexec/arch/mips/crashdump-mips.c |    3 ++-
 kexec/arch/mips/kexec-elf-mips.c |    2 +-
 kexec/kexec-elf-rel.c            |    3 +++
 kexec/kexec.h                    |    2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)
kexec/arch/mips/crashdump-mips.c +2 -1
index e7840e0..98c9f7c 100644
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <limits.h>
+#include <inttypes.h>
 #include <elf.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -52,7 +53,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info)
 
      if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) {
              elf_info->kern_paddr_start = start;
-             dbgprintf("kernel load physical addr start = 0x%lx\n", start);
+             dbgprintf("kernel load physical addr start = 0x%" PRIu64 "\n", start);
              return 0;
      }
 
Quoted 13 lines

kexec/arch/mips/kexec-elf-mips.c int elf_mips_load(int argc, char **argv, const char *buf, off_t len, · line 162

Quoted 11 lines
kexec/arch/mips/kexec-elf-mips.c +1 -1
index a27d986..8a6419a 100644
@@ -158,7 +158,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
      if (info->kexec_flags & KEXEC_ON_CRASH)
              /* In case of crashdump segment[0] is kernel.
               * Put cmdline just after it. */
-             cmdline_addr = info->segment[0].mem +
+             cmdline_addr = (unsigned long)info->segment[0].mem +
                              info->segment[0].memsz;

I wonder if we can resolve this without resorting to a cast.

It's a "pointer to integer without cast" warning. I think keeping (unsigned long) for a pointer is fine, isnt it?

Quoted 17 lines
Quoted 8 lines
kexec/arch/mips/kexec-elf-mips.c +0 -0
      else
              cmdline_addr = 0;
kexec/kexec-elf-rel.c +0 -0
index c625f30..5a5fcd1 100644

kexec/kexec-elf-rel.c int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, · line 355

Quoted 9 lines
kexec/kexec-elf-rel.c +3 -0
@@ -347,6 +347,9 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,
                      else if (shdr->sh_type == SHT_RELA) {
                              rel = elf_rela(ehdr, ptr);
                      }
+                     else {
+                             die("Unexpected sh_type: %d\n", shdr->sh_type);
+                     }
                      /* the location to change */
                      location = section->sh_data + rel.r_offset;
 

This one has already been fixed by explicitly initialising the local variable. So I will drop it in the next version.

Thank you for your time on this.

yousong

Quoted 6 lines
Quoted 6 lines
kexec/kexec.h +0 -0
index 4be2b2f..2c85052 100644
@@ -245,7 +245,7 @@ extern int file_types;
 
Quoted 10 lines
Quoted 10 lines
kexec/kexec.h +1 -2
 extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);
 extern void die(const char *fmt, ...)
-     __attribute__ ((format (printf, 1, 2)));
+     __attribute__ ((format (printf, 1, 2), noreturn));
 extern void *xmalloc(size_t size);
 extern void *xrealloc(void *ptr, size_t size);
 extern char *slurp_file(const char *filename, off_t *r_size);
--

1.7.10.4

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw

Re: [PATCH 3/3] Fix a few compilation warnings.

Quoted 53 lines · Yousong Zhou
Quoted 4 lines · Simon Horman

These changes do not seem to be related to each other. Please split this into 4 separate patches each with a changelog that briefly describes what the problem is.

Will split them each into a separate patch.

Quoted 31 lines · Yousong Zhou
Quoted 30 lines
---
 kexec/arch/mips/crashdump-mips.c |    3 ++-
 kexec/arch/mips/kexec-elf-mips.c |    2 +-
 kexec/kexec-elf-rel.c            |    3 +++
 kexec/kexec.h                    |    2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)
kexec/arch/mips/crashdump-mips.c +2 -1
index e7840e0..98c9f7c 100644
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <limits.h>
+#include <inttypes.h>
 #include <elf.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -52,7 +53,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info)
 
      if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) {
              elf_info->kern_paddr_start = start;
-             dbgprintf("kernel load physical addr start = 0x%lx\n", start);
+             dbgprintf("kernel load physical addr start = 0x%" PRIu64 "\n", start);
              return 0;
      }
 
Quoted 13 lines

kexec/arch/mips/kexec-elf-mips.c int elf_mips_load(int argc, char **argv, const char *buf, off_t len, · line 162

Quoted 11 lines
kexec/arch/mips/kexec-elf-mips.c +1 -1
index a27d986..8a6419a 100644
@@ -158,7 +158,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
      if (info->kexec_flags & KEXEC_ON_CRASH)
              /* In case of crashdump segment[0] is kernel.
               * Put cmdline just after it. */
-             cmdline_addr = info->segment[0].mem +
+             cmdline_addr = (unsigned long)info->segment[0].mem +
                              info->segment[0].memsz;

I wonder if we can resolve this without resorting to a cast.

Quoted 2 lines

It's a "pointer to integer without cast" warning. I think keeping (unsigned long) for a pointer is fine, isnt it?

Yes, I guess it is the least-bad solution.

Quoted 22 lines
Quoted 18 lines
Quoted 9 lines
kexec/arch/mips/kexec-elf-mips.c +0 -0
      else
              cmdline_addr = 0;
kexec/kexec-elf-rel.c +0 -0
index c625f30..5a5fcd1 100644

kexec/kexec-elf-rel.c int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, · line 355

Quoted 9 lines
kexec/kexec-elf-rel.c +3 -0
@@ -347,6 +347,9 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,
                      else if (shdr->sh_type == SHT_RELA) {
                              rel = elf_rela(ehdr, ptr);
                      }
+                     else {
+                             die("Unexpected sh_type: %d\n", shdr->sh_type);
+                     }
                      /* the location to change */
                      location = section->sh_data + rel.r_offset;
 

This one has already been fixed by explicitly initialising the local variable. So I will drop it in the next version.

Quoted 1 line

Thank you for your time on this.

Likewise, thanks for spending time on this.

Quoted 8 lines

yousong

Quoted 6 lines
Quoted 6 lines
kexec/kexec.h +0 -0
index 4be2b2f..2c85052 100644
@@ -245,7 +245,7 @@ extern int file_types;
 
Quoted 16 lines
Quoted 10 lines
Quoted 10 lines
kexec/kexec.h +1 -2
 extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);
 extern void die(const char *fmt, ...)
-     __attribute__ ((format (printf, 1, 2)));
+     __attribute__ ((format (printf, 1, 2), noreturn));
 extern void *xmalloc(size_t size);
 extern void *xrealloc(void *ptr, size_t size);
 extern char *slurp_file(const char *filename, off_t *r_size);
--

1.7.10.4

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#7 lore raw
In reply to Yousong Zhou
Quoted 3 lines · Yousong Zhou

Fix the following error when searching for lzma support.

checking for lzma_code in -llzma... ./configure: line 4756: ac_fn_c_try_link: command not found

This change does more than the changelog suggests. Please either update the change log or split the patch up.

Quoted 41 lines
---
 configure.ac |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
configure.ac +6 -6
index 4e15cb0..212e838 100644
@@ -152,22 +152,22 @@ AC_CHECK_PROG([DIRNAME],  dirname,  dirname,  "no", [$PATH])
 dnl See if I have a usable copy of zlib available
 if test "$with_zlib" = yes ; then
 	AC_CHECK_HEADER(zlib.h,
-		AC_CHECK_LIB(z, inflateInit_, ,
-		AC_MSG_NOTICE([zlib support disabled])))
+		[AC_CHECK_LIB(z, inflateInit_, ,
+		AC_MSG_NOTICE([zlib support disabled]))])
 fi
 
 dnl See if I have a usable copy of lzma available
 if test "$with_lzma" = yes ; then
 	AC_CHECK_HEADER(lzma.h,
-		AC_CHECK_LIB(lzma, lzma_code, ,
-		AC_MSG_NOTICE([lzma support disabled])))
+		[AC_CHECK_LIB(lzma, lzma_code, ,
+		AC_MSG_NOTICE([lzma support disabled]))])
 fi
 
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then
 	AC_CHECK_HEADER(xenctrl.h,
-		AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
-		AC_MSG_NOTICE([Xen support disabled])))
+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+		AC_MSG_NOTICE([Xen support disabled]))])
 fi
 
 dnl ---Sanity checks
Signature · 1 line
1.7.10.4

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec