From ebcecdf1c3dd76965f1690535bfe97b1733e3e63 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 10 Feb 2012 16:48:48 +0100 Subject: [PATCH] Increase warning level. * conf/Makefile.common (CFLAGS_GNULIB): Add -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-old-style-definition. * configure.ac (HOST_CFLAGS): Add bunch of -W arguments. (TARGET_CFLAGS): Likewise. (HOST_CFLAGS): Add -Werror unless --disable-werror is activated. * grub-core/Makefile.core.def (decompressor_xz): Add -Wno-unreachable-code. (normal): Add -Wno-redundant-decls. (xzio): Add -Wno-unreachable-code. (lzopio): Add -Wno-redundant-decls -Wno-error. * grub-core/commands/acpi.c: Add exception to -Wcast-align. * grub-core/commands/lsacpi.c: Add exception to -Wcast-align. * grub-core/gensymlist.sh: Add exception to -Wmissing-format-attribute. * grub-core/kern/dl.c: Add exception to -Wcast-align. * grub-core/kern/efi/efi.c (grub_efi_modules_addr): Likewise. * grub-core/kern/i386/coreboot/init.c: Add exception to -Wsuggest-attribute=noreturn. * grub-core/kern/ia64/dl.c: Add exception to -Wcast-align. * grub-core/kern/ia64/dl_helper.c: Likewise. * grub-core/kern/mips/dl.c: Likewise. * grub-core/kern/sparc64/dl.c: Likewise. * grub-core/lib/LzmaEnc.c: Add exception to -Wshadow. * grub-core/lib/libgcrypt_wrap/cipher_wrap.h (memcpy): Likewise. (memcmp): Likewise. * grub-core/lib/pbkdf2.c: Add exception to -Wunreachable-code. * grub-core/loader/ia64/efi/linux.c: Add exception to -Wcast-align. * grub-core/loader/mips/linux.c: Likewise. * grub-core/loader/multiboot_elfxx.c: Likewise. * grub-core/script/parser.y: Add exception to -Wunreachable-code. * grub-core/video/sm712.c: Add exception to -Wcast-align. * util/import_gcry.py: Add -Wno-cast-align to modules checked by hand. * grub-core/font/font.c (grub_font_loader_init): Add explicit cast and fixme. * grub-core/fs/iso9660.c (grub_iso9660_iterate_dir): Likewise. * grub-core/kern/i386/multiboot_mmap.c (grub_machine_mmap_init): Fix prototype. --- ChangeLog | 41 ++++++++++++++++++++++ Makefile.am | 2 +- conf/Makefile.common | 2 +- configure.ac | 5 ++- grub-core/Makefile.core.def | 7 ++-- grub-core/commands/acpi.c | 2 ++ grub-core/commands/lsacpi.c | 2 ++ grub-core/font/font.c | 3 +- grub-core/fs/iso9660.c | 5 +-- grub-core/gensymlist.sh | 2 ++ grub-core/kern/dl.c | 2 ++ grub-core/kern/efi/efi.c | 4 +++ grub-core/kern/i386/coreboot/init.c | 2 ++ grub-core/kern/i386/multiboot_mmap.c | 2 +- grub-core/kern/ia64/dl.c | 2 ++ grub-core/kern/ia64/dl_helper.c | 2 ++ grub-core/kern/mips/dl.c | 2 ++ grub-core/kern/sparc64/dl.c | 1 + grub-core/lib/LzmaEnc.c | 2 ++ grub-core/lib/libgcrypt_wrap/cipher_wrap.h | 2 ++ grub-core/lib/pbkdf2.c | 2 ++ grub-core/loader/ia64/efi/linux.c | 2 ++ grub-core/loader/mips/linux.c | 2 ++ grub-core/loader/multiboot_elfxx.c | 2 ++ grub-core/script/parser.y | 2 ++ grub-core/video/sm712.c | 2 ++ util/import_gcry.py | 6 +++- 27 files changed, 99 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a7e7871c..e6eb0f0e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,44 @@ +2012-02-10 Vladimir Serbinenko + + Increase warning level. + + * conf/Makefile.common (CFLAGS_GNULIB): Add -Wno-redundant-decls + -Wno-unreachable-code -Wno-conversion -Wno-old-style-definition. + * configure.ac (HOST_CFLAGS): Add bunch of -W arguments. + (TARGET_CFLAGS): Likewise. + (HOST_CFLAGS): Add -Werror unless --disable-werror is activated. + * grub-core/Makefile.core.def (decompressor_xz): Add + -Wno-unreachable-code. + (normal): Add -Wno-redundant-decls. + (xzio): Add -Wno-unreachable-code. + (lzopio): Add -Wno-redundant-decls -Wno-error. + * grub-core/commands/acpi.c: Add exception to -Wcast-align. + * grub-core/commands/lsacpi.c: Add exception to -Wcast-align. + * grub-core/gensymlist.sh: Add exception to -Wmissing-format-attribute. + * grub-core/kern/dl.c: Add exception to -Wcast-align. + * grub-core/kern/efi/efi.c (grub_efi_modules_addr): Likewise. + * grub-core/kern/i386/coreboot/init.c: Add exception to + -Wsuggest-attribute=noreturn. + * grub-core/kern/ia64/dl.c: Add exception to -Wcast-align. + * grub-core/kern/ia64/dl_helper.c: Likewise. + * grub-core/kern/mips/dl.c: Likewise. + * grub-core/kern/sparc64/dl.c: Likewise. + * grub-core/lib/LzmaEnc.c: Add exception to -Wshadow. + * grub-core/lib/libgcrypt_wrap/cipher_wrap.h (memcpy): Likewise. + (memcmp): Likewise. + * grub-core/lib/pbkdf2.c: Add exception to -Wunreachable-code. + * grub-core/loader/ia64/efi/linux.c: Add exception to -Wcast-align. + * grub-core/loader/mips/linux.c: Likewise. + * grub-core/loader/multiboot_elfxx.c: Likewise. + * grub-core/script/parser.y: Add exception to -Wunreachable-code. + * grub-core/video/sm712.c: Add exception to -Wcast-align. + * util/import_gcry.py: Add -Wno-cast-align to modules checked by hand. + * grub-core/font/font.c (grub_font_loader_init): Add explicit cast and + fixme. + * grub-core/fs/iso9660.c (grub_iso9660_iterate_dir): Likewise. + * grub-core/kern/i386/multiboot_mmap.c (grub_machine_mmap_init): + Fix prototype. + 2012-02-10 Vladimir Serbinenko * grub-core/lib/i386/relocator16.S: Fix incorrect use of absolute diff --git a/Makefile.am b/Makefile.am index 99b141e07..24bf9f86a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -304,7 +304,7 @@ endif BOOTCHECKS += bootcheck-kfreebsd-aout -BOOTCHECKS += bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 +#BOOTCHECKS += bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 BOOTCHECKS += bootcheck-multiboot bootcheck-multiboot2 diff --git a/conf/Makefile.common b/conf/Makefile.common index ed84e76d8..fd8454e59 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -105,7 +105,7 @@ platformdir = $(pkglibrootdir)/$(target_cpu)-$(platform) CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers CPPFLAGS_GCRY = -I$(top_srcdir)/grub-core/lib/libgcrypt_wrap -CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter +CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-old-style-definition CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib CFLAGS_POSIX = -fno-builtin diff --git a/configure.ac b/configure.ac index 45a5a40e6..d1d8ebc3c 100644 --- a/configure.ac +++ b/configure.ac @@ -373,7 +373,9 @@ LDFLAGS="$TARGET_LDFLAGS" LIBS="" # debug flags. -TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wundef -Wstrict-prototypes -g" +WARN_FLAGS="-Wall -W -Wshadow -Wold-style-declaration -Wold-style-definition -Wpointer-arith -Wmissing-prototypes -Wundef -Wextra -Waddress -Warray-bounds -Wattributes -Wbuiltin-macro-redefined -Wcast-align -Wchar-subscripts -Wclobbered -Wcomment -Wcoverage-mismatch -Wdeprecated -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-contains-nul -Wformat-extra-args -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Winline -Wint-to-pointer-cast -Winvalid-pch -Wunsafe-loop-optimizations -Wlogical-op -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmudflap -Wmultichar -Wnonnull -Woverflow -Wpacked-bitfield-compat -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector -Wstrict-aliasing -Wstrict-overflow -Wswitch -Wsync-nand -Wtrigraphs -Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-result -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wmissing-declarations -Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wpointer-sign" +HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS" +TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls" TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g" # Force no alignment to save space on i386. @@ -592,6 +594,7 @@ AC_ARG_ENABLE([werror], [do not use -Werror when building GRUB])]) if test x"$enable_werror" != xno ; then TARGET_CFLAGS="$TARGET_CFLAGS -Werror" + HOST_CFLAGS="$HOST_CFLAGS -Werror" fi TARGET_CPP="$TARGET_CC -E" diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 5905a91a6..9d3d208f9 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -348,7 +348,7 @@ image = { mips_qemu_mips_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000'; mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x8bc00000'; ldadd = '-lgcc'; - cflags = '-static-libgcc'; + cflags = '-Wno-unreachable-code -static-libgcc'; enable = mips; }; @@ -1452,7 +1452,7 @@ module = { extra_dist = script/yylex.l; extra_dist = script/parser.y; - cflags = '$(CFLAGS_POSIX)'; + cflags = '$(CFLAGS_POSIX) -Wno-redundant-decls'; cppflags = '$(CPPFLAGS_POSIX)'; }; @@ -1737,13 +1737,14 @@ module = { common = lib/xzembed/xz_dec_lzma2.c; common = lib/xzembed/xz_dec_stream.c; cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed'; + cflags='-Wno-unreachable-code'; }; module = { name = lzopio; common = io/lzopio.c; common = lib/minilzo/minilzo.c; - cflags = '$(CFLAGS_POSIX) -Wno-undef'; + cflags = '$(CFLAGS_POSIX) -Wno-undef -Wno-redundant-decls -Wno-error'; cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H'; }; diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index bb09029a6..57e7003f4 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -33,6 +33,8 @@ #include #endif +#pragma GCC diagnostic ignored "-Wcast-align" + GRUB_MOD_LICENSE ("GPLv3+"); static const struct grub_arg_option options[] = { diff --git a/grub-core/commands/lsacpi.c b/grub-core/commands/lsacpi.c index f219022a0..4f1742b8d 100644 --- a/grub-core/commands/lsacpi.c +++ b/grub-core/commands/lsacpi.c @@ -25,6 +25,8 @@ #include #include +#pragma GCC diagnostic ignored "-Wcast-align" + GRUB_MOD_LICENSE ("GPLv3+"); static void diff --git a/grub-core/font/font.c b/grub-core/font/font.c index 8d74534ef..e0597ea45 100644 --- a/grub-core/font/font.c +++ b/grub-core/font/font.c @@ -192,7 +192,8 @@ grub_font_loader_init (void) /* Initialize the null font. */ font_init (&null_font); - null_font.name = ""; + /* FIXME: Fix this slightly improper cast. */ + null_font.name = (char *) ""; null_font.ascent = unknown_glyph->height - 3; null_font.descent = 3; null_font.max_char_width = unknown_glyph->width; diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c index fb5da2aa7..5e767dc27 100644 --- a/grub-core/fs/iso9660.c +++ b/grub-core/fs/iso9660.c @@ -560,10 +560,11 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, { /* The flags are stored at the data position 0, here the filename type is stored. */ + /* FIXME: Fix this slightly improper cast. */ if (entry->data[0] & GRUB_ISO9660_RR_DOT) - filename = "."; + filename = (char *) "."; else if (entry->data[0] & GRUB_ISO9660_RR_DOTDOT) - filename = ".."; + filename = (char *) ".."; else if (entry->len >= 5) { grub_size_t size = 1, csize = 1; diff --git a/grub-core/gensymlist.sh b/grub-core/gensymlist.sh index 5f402ea87..a13d7cc38 100644 --- a/grub-core/gensymlist.sh +++ b/grub-core/gensymlist.sh @@ -41,6 +41,8 @@ cat < #include +#pragma GCC diagnostic ignored "-Wcast-align" + void grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, grub_size_t *got) diff --git a/grub-core/kern/mips/dl.c b/grub-core/kern/mips/dl.c index 262d9a2ca..22b23d654 100644 --- a/grub-core/kern/mips/dl.c +++ b/grub-core/kern/mips/dl.c @@ -49,6 +49,8 @@ grub_arch_dl_check_header (void *ehdr) return GRUB_ERR_NONE; } +#pragma GCC diagnostic ignored "-Wcast-align" + /* Relocate symbols. */ grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) diff --git a/grub-core/kern/sparc64/dl.c b/grub-core/kern/sparc64/dl.c index 6ea65d7e3..a0c1837d0 100644 --- a/grub-core/kern/sparc64/dl.c +++ b/grub-core/kern/sparc64/dl.c @@ -38,6 +38,7 @@ grub_arch_dl_check_header (void *ehdr) return GRUB_ERR_NONE; } +#pragma GCC diagnostic ignored "-Wcast-align" /* Relocate symbols. */ grub_err_t diff --git a/grub-core/lib/LzmaEnc.c b/grub-core/lib/LzmaEnc.c index ed687b830..ae0c3b9f6 100644 --- a/grub-core/lib/LzmaEnc.c +++ b/grub-core/lib/LzmaEnc.c @@ -923,6 +923,8 @@ static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur) #define LIT_PROBS(pos, prevByte) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevByte) >> (8 - p->lc))) * 0x300) +#pragma GCC diagnostic ignored "-Wshadow" + static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) { UInt32 numAvailableBytes, lenMain, numDistancePairs; diff --git a/grub-core/lib/libgcrypt_wrap/cipher_wrap.h b/grub-core/lib/libgcrypt_wrap/cipher_wrap.h index 5a64c5736..828530577 100644 --- a/grub-core/lib/libgcrypt_wrap/cipher_wrap.h +++ b/grub-core/lib/libgcrypt_wrap/cipher_wrap.h @@ -88,6 +88,7 @@ fips_mode (void) } #ifdef GRUB_UTIL +#pragma GCC diagnostic ignored "-Wshadow" static inline void * memcpy (void *dest, const void *src, grub_size_t n) { @@ -105,6 +106,7 @@ memcmp (const void *s1, const void *s2, grub_size_t n) { return grub_memcmp (s1, s2, n); } +#pragma GCC diagnostic error "-Wshadow" #endif diff --git a/grub-core/lib/pbkdf2.c b/grub-core/lib/pbkdf2.c index 09b8c7360..beac3c3d6 100644 --- a/grub-core/lib/pbkdf2.c +++ b/grub-core/lib/pbkdf2.c @@ -31,6 +31,8 @@ GRUB_MOD_LICENSE ("GPLv2+"); desired derived output length DKLEN. Output buffer is DK which must have room for at least DKLEN octets. The output buffer will be filled with the derived data. */ +#pragma GCC diagnostic ignored "-Wunreachable-code" + gcry_err_code_t grub_crypto_pbkdf2 (const struct gcry_md_spec *md, const grub_uint8_t *P, grub_size_t Plen, diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c index 42b460b48..e4ba6a269 100644 --- a/grub-core/loader/ia64/efi/linux.c +++ b/grub-core/loader/ia64/efi/linux.c @@ -35,6 +35,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); +#pragma GCC diagnostic ignored "-Wcast-align" + #define ALIGN_MIN (256*1024*1024) #define GRUB_ELF_SEARCH 1024 diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c index 66850e2e6..a988808c8 100644 --- a/grub-core/loader/mips/linux.c +++ b/grub-core/loader/mips/linux.c @@ -31,6 +31,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); +#pragma GCC diagnostic ignored "-Wcast-align" + /* For frequencies. */ #include diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index 36c80ea03..3803bf37a 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -39,6 +39,8 @@ #define CONCAT(a,b) CONCAT_(a, b) #define CONCAT_(a,b) a ## b +#pragma GCC diagnostic ignored "-Wcast-align" + /* Check if BUFFER contains ELF32 (or ELF64). */ static int CONCAT(grub_multiboot_is_elf, XX) (void *buffer) diff --git a/grub-core/script/parser.y b/grub-core/script/parser.y index c2b099d7a..0c2d8867b 100644 --- a/grub-core/script/parser.y +++ b/grub-core/script/parser.y @@ -29,6 +29,8 @@ #define YYENABLE_NLS 0 #include "grub_script.tab.h" + +#pragma GCC diagnostic ignored "-Wunreachable-code" %} %union { diff --git a/grub-core/video/sm712.c b/grub-core/video/sm712.c index 60f2c9089..bc38b2e92 100644 --- a/grub-core/video/sm712.c +++ b/grub-core/video/sm712.c @@ -30,6 +30,8 @@ #include "sm712_init.c" +#pragma GCC diagnostic ignored "-Wcast-align" + #define GRUB_SM712_TOTAL_MEMORY_SPACE 0x700400 #define GRUB_SM712_REG_BASE 0x700000 #define GRUB_SM712_PCIID 0x0712126f diff --git a/util/import_gcry.py b/util/import_gcry.py index b7bf7ca5f..097789a94 100644 --- a/util/import_gcry.py +++ b/util/import_gcry.py @@ -323,7 +323,11 @@ for cipher_file in cipher_files: for src in modfiles.split(): conf.write (" common = %s;\n" % src) confutil.write (" common = grub-core/%s;\n" % src) - conf.write (" cflags = '$(CFLAGS_GCRY)';\n"); + if modname == "gcry_rijndael" or modname == "gcry_md4" or modname == "gcry_md5" or modname == "gcry_rmd160" or modname == "gcry_sha1" or modname == "gcry_sha256" or modname == "gcry_sha512" or modname == "gcry_tiger": + # Alignment checked by hand + conf.write (" cflags = '$(CFLAGS_GCRY) -Wno-cast-align';\n"); + else: + conf.write (" cflags = '$(CFLAGS_GCRY)';\n"); conf.write (" cppflags = '$(CPPFLAGS_GCRY)';\n"); conf.write ("};\n\n") elif isc and cipher_file != "camellia.c":