Clean up patches
Subsystems (4)
cover Clean up patches
Like other kernel developers, I compile kernels several times a day with various configs. Some are for testing, others are given to me by others to debug some code.
I like to look at any warnings that gcc gives me, and lately I've been irritated by the same warnings appearing in the same places that has nothing to do with my code.
The biggest offender is the Xen code. I figured that I'll take a look at what these warnings are and if they are trivial, I'll fix them.
The thing that got me when looking into this, is most of the warnings in Xen come from dead code! Code that is not called by anyone, or has references by #if 0 code.
There was one patch from the sound code that only needed a more robust macro when the debugging was not configured.
The rest of the patches get rid of most of my warnings. There are a few left where gcc complains about discarding qualifier types but those are not as trivial to fix, so I'll leave them to those maintainers.
-- Steve
PATCH 1/5 xen: clean up label
In enlighten.c there's a macro that is defined to jump to a label. This macro is only used in an ifdef CONFIG_X86_32 section, and the label is outside that define conditional, which causes warnings.
This patch pushes the label inside the define condition.
--- arch/x86/xen/enlighten.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/xen/enlighten.c +2 -2
@@ -1082,10 +1082,10 @@ static unsigned xen_patch(u8 type, u16 cSITE (pv_irq_ops, irq_disable);SITE (pv_irq_ops, save_fl);SITE (pv_irq_ops, restore_fl); -#endif /* CONFIG_X86_32 */ -#undef SITE patch_site: +#endif /* CONFIG_X86_32 */ +#undef SITEif (start ==NULL || (end-start) > len) goto default_patch;
PATCH 2/5 xen: remove unused function warnings
In reply to Steven RostedtThe compiler is complaining that there are unused static functions in the Xen code. Looking into this, it seems that they are used but only within #if statements.
This patch matches the functions with the #if statements that they are referenced by.
--- arch/x86/xen/enlighten.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/xen/enlighten.c +4 -0
@@ -704,10 +704,12 @@ static unsigned long xen_read_cr2(void)return x86_read_percpu (xen_vcpu)->arch.cr2; } +#ifdef CONFIG_X86_32 static unsigned long xen_read_cr2_direct (void ) {return x86_read_percpu (xen_vcpu_info.arch.cr2); } +#endif static void xen_write_cr4 (unsigned long cr4) {
@@ -962,6 +964,7 @@ static void *xen_kmap_atomic_pte(struct }#endif +#ifndef CONFIG_X86_64 static __init pte_t mask_rw_pte (pte_t *ptep,pte_t pte) {/* If there's an existing pte, then don't allow _PAGE_RW to be set */
@@ -980,6 +983,7 @@ static __init void xen_set_pte_init(pte_ xen_set_pte(ptep, pte); } +#endif static __init void xen_pagetable_setup_start (pgd_t *base) {
PATCH 3/5 xen: nuke dead code in enlighten.c
In reply to Steven RostedtThe kernel is no place to hold dead code.
No reason for #if 0 in the kernel proper.
Note, the walk function being deleted is only referenced in the
#if 0 code.
--- arch/x86/xen/enlighten.c | 42 ------------------------------------------ 1 file changed, 42 deletions(-)
arch/x86/xen/enlighten.c +0 -42
@@ -1451,39 +1451,6 @@ static void *m2v(phys_addr_t maddr)return __ka (m2p (maddr)); } -#ifdef CONFIG_X86_64 -static void walk (pgd_t *pgd,unsigned long addr) -{ -unsigned l4idx =pgd_index (addr); -unsigned l3idx =pud_index (addr); -unsigned l2idx =pmd_index (addr); -unsigned l1idx =pte_index (addr); -pgd_t l4; -pud_t l3; -pmd_t l2; -pte_t l1; - -xen_raw_printk ("walk %p, %lx -> %d %d %d %d\n" , - pgd, addr, l4idx, l3idx, l2idx, l1idx); - - l4 = pgd[l4idx]; -xen_raw_printk (" l4: %016lx\n" , l4.pgd); -xen_raw_printk (" %016lx\n" ,pgd_val (l4)); - - l3 = ((pud_t *)(m2v (l4.pgd)))[l3idx]; -xen_raw_printk (" l3: %016lx\n" , l3.pud); -xen_raw_printk (" %016lx\n" ,pud_val (l3)); - - l2 = ((pmd_t *)(m2v (l3.pud)))[l2idx]; -xen_raw_printk (" l2: %016lx\n" , l2.pmd); -xen_raw_printk (" %016lx\n" ,pmd_val (l2)); - - l1 = ((pte_t *)(m2v (l2.pmd)))[l1idx]; -xen_raw_printk (" l1: %016lx\n" , l1.pte); -xen_raw_printk (" %016lx\n" ,pte_val (l1)); -} -#endif -static void set_page_prot (void *addr,pgprot_t prot) {unsigned long pfn =__pa (addr) >>PAGE_SHIFT ;
@@ -1747,15 +1714,6 @@ asmlinkage void __init xen_start_kernel(xen_raw_console_write ("about to get started...\n" ); -#if 0 -xen_raw_printk ("&boot_params=%p __pa(&boot_params)=%lx __va(__pa(&boot_params))=%lx\n" , - &boot_params,__pa_symbol (&boot_params), -__va (__pa_symbol (&boot_params))); - -walk (pgd, &boot_params); -walk (pgd,__va (__pa (&boot_params))); -#endif -/* Start the world */ #ifdef CONFIG_X86_32 i386_start_kernel ();
PATCH 4/5 sound: update snd_assert macro
In reply to Steven RostedtOne user of the snd_assert macro calls a goto and the compiler complains that the label is not used when the snd_assert is not set.
This patch makes snd_assert more robust when not defined to let the compiler know about arguments when not in use.
--- include/sound/core.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/sound/core.h +7 -1
@@ -407,7 +407,13 @@ void snd_verbose_printd(const char *file#else /* !CONFIG_SND_DEBUG */ #define snd_printd(fmt, args...) /* nothing */ -#define snd_assert(expr, args...) (void)(expr) +/* Keep the compiler happy by showing the expr and args */ +#define snd_assert(expr, args...) do { \ + if (0) { \ + (void)(expr); \ + args; \ + } \ +} while(0)#define snd_BUG ()/* nothing */ #endif /* CONFIG_SND_DEBUG */
Re: [PATCH 4/5] sound: update snd_assert macro
At Thu, 02 Oct 2008 11:05:33 -0400,
Quoted 7 lines · Steven Rostedt
One user of the
snd_assertmacro calls a goto and the compiler complains that the label is not used when thesnd_assertis not set.This patch makes
snd_assertmore robust when not defined to let the compiler know about arguments when not in use.
This issue was already fixed differently in the recent ALSA tree (thus in linux-next tree as well).
thanks,
Takashi
Quoted 34 lines
CC Jaroslav Kysela <[email protected]>Signed-off-by Steven Rostedt <[email protected]>--- include/sound/core.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)Index:
linux-compile.git/include/sound/core.h
===================================================================include/sound/core.h +7
-1@@ -407,7 +407,13 @@ void snd_verbose_printd(const char *file#else /* !CONFIG_SND_DEBUG */ #define snd_printd(fmt, args...) /* nothing */ -#define snd_assert(expr, args...) (void)(expr) +/* Keep the compiler happy by showing the expr and args */ +#define snd_assert(expr, args...) do { \ + if (0) { \ + (void)(expr); \ + args; \ + } \ +} while(0)#define snd_BUG ()/* nothing */ #endif /* CONFIG_SND_DEBUG */ Signature · 6 lines
-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/5] sound: update snd_assert macro
Quoted 7 lines · Takashi Iwai
At Thu, 02 Oct 2008 11:05:33 -0400,
Quoted 5 lines · Steven Rostedt
One user of the
snd_assertmacro calls a goto and the compiler complains that the label is not used when thesnd_assertis not set.
Quoted 6 lines
Quoted 2 lines
This patch makes
snd_assertmore robust when not defined to let the compiler know about arguments when not in use.This issue was already fixed differently in the recent ALSA tree (thus in linux-next tree as well).
So it seems.
Thanks,
-- Steve
PATCH 5/5 xen: nuke the ballon files
In reply to Steven RostedtInvestigating the unused static files in the balloon code, I discovered that the balloon code is not used at all.
The header file is one big #if 0 and all the functions in the C file is static. There is no caller like init_module to hook to any of these functions. Basically, this code is one big patch of dead code wasting space on my hard drive.
This patch removes the balloon code altogether since there are no users.
--- drivers/xen/Makefile | 1 drivers/xen/balloon.c | 713 -------------------------------------------------- include/xen/balloon.h | 61 ---- 3 files changed, 775 deletions(-)
drivers/xen/Makefile +0 -1
@@ -1,4 +1,3 @@ obj-y += grant-table.o features.o events.o manage.o obj-y += xenbus/ obj-$(CONFIG_XEN_XENCOMM) += xencomm.o -obj-$(CONFIG_XEN_BALLOON) += balloon.o
drivers/xen/balloon.c deleted +0 -713
713 lines not on this page · raw message
include/xen/balloon.h deleted +0 -61
61 lines not on this page · raw message
Re: [PATCH 5/5] xen: nuke the ballon files
Quoted 11 lines · Steven Rostedt
Investigating the unused static files in the balloon code, I discovered that the balloon code is not used at all.
The header file is one big #if 0 and all the functions in the C file is static. There is no caller like
init_moduleto hook to any of these functions. Basically, this code is one big patch of dead code wasting space on my hard drive.This patch removes the balloon code altogether since there are no users.
Er, I think you should back away from that crack pipe.
Quoted 1 line
-subsys_initcall(balloon_init);
J
Re: [PATCH 5/5] xen: nuke the ballon files
Quoted 9 lines · Jeremy Fitzhardinge
Quoted 8 lines · Steven Rostedt
Investigating the unused static files in the balloon code, I discovered that the balloon code is not used at all.
The header file is one big #if 0 and all the functions in the C file is static. There is no caller like
init_moduleto hook to any of these functions. Basically, this code is one big patch of dead code wasting space on my hard drive.
Quoted 5 lines
Quoted 3 lines
This patch removes the balloon code altogether since there are no users.
Er, I think you should back away from that crack pipe.
No, coffee is my drug of choice. I did have a bit of overdose today ;-)
Quoted 2 lines
Quoted 2 lines
-subsys_initcall(balloon_init);
Ouch! How did I miss that.
Anyway, there are still a bunch of functions in that code that are not referenced. OK, nack this patch, but could you please supply one that cleans that code up.
Thanks,
-- Steve