Hi,
I pushed a small build fix for the case where we are build on a system that hasn't (or has explicitly disabled) all compression libraries. In that case vmlinux_suffixes would be empty and the compiler would brek with -Werror because we did comparisons against a size_t and a zero sized array.
2011-04-11 Mark Wielaard mjw@redhat.com
* linux-kernel-modules.c (vmlinux_suffixes): Guard definition by check for zlib, bzlib or lzma defines to check it isn't empty. (try_kernel_name): Use same guard for use of vmlinux_suffixes.
Cheers,
Mark
commit dbb490fad0fb4924e7cd0ae3991dec1cda0de644 Author: Mark Wielaard mjw@redhat.com Date: Mon Apr 11 17:24:16 2011 +0200
Fix libdwfl compile issue in case none of the compression libraries are there.
* linux-kernel-modules.c (vmlinux_suffixes): Guard definition by check for zlib, bzlib or lzma defines to check it isn't empty. (try_kernel_name): Use same guard for use of vmlinux_suffixes.
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 3edc11b..abad77b 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2011-04-11 Mark Wielaard mjw@redhat.com + + * linux-kernel-modules.c (vmlinux_suffixes): Guard definition + by check for zlib, bzlib or lzma defines to check it isn't empty. + (try_kernel_name): Use same guard for use of vmlinux_suffixes. + 2011-03-08 Roland McGrath roland@redhat.com
* dwfl_module_getdwarf.c (open_elf): Clear errno before CBFAIL. diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index f3d9af1..ae74a49 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -78,6 +78,7 @@ #define MODULE_SECT_NAME_LEN 32 /* Minimum any linux/module.h has had. */
+#if defined (USE_ZLIB) || defined (USE_BZLIB) || defined (USE_LZMA) static const char *vmlinux_suffixes[] = { #ifdef USE_ZLIB @@ -90,6 +91,7 @@ static const char *vmlinux_suffixes[] = ".xz", #endif }; +#endif
/* Try to open the given file as it is or under the debuginfo directory. */ static int @@ -127,6 +129,7 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug) } }
+#if defined (USE_ZLIB) || defined (USE_BZLIB) || defined (USE_LZMA) if (fd < 0) for (size_t i = 0; i < sizeof vmlinux_suffixes / sizeof vmlinux_suffixes[0]; @@ -145,6 +148,7 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug) } } } +#endif
if (fd < 0) {
This might be just shifting the problem into the future, but this works with less code and will make it easier to add more formats, should that be necessary:
for (size_t i = 0;
- i < sizeof vmlinux_suffixes / sizeof vmlinux_suffixes[0];
- i + 1 < (sizeof vmlinux_suffixes / sizeof vmlinux_suffixes[0]) + 1;
PM
Hi Petr,
This might be just shifting the problem into the future, but this works with less code and will make it easier to add more formats, should that be necessary:
for (size_t i = 0;
- i < sizeof vmlinux_suffixes / sizeof vmlinux_suffixes[0];
- i + 1 < (sizeof vmlinux_suffixes / sizeof vmlinux_suffixes[0]) + 1;
Yeah, Frank did point out that if you make the code less specific and mark i as int, then the compiler also isn't smart enough to notice that the comparison is always true when the array is empty.
Feel free to replace my solution with something simpler if you think that is more clear. My fix might have been a tad too "pedantically correct".
Thanks,
Mark
elfutils-devel@lists.fedorahosted.org