lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090414171756.GA18510@elte.hu>
Date:	Tue, 14 Apr 2009 19:17:56 +0200
From:	Ingo Molnar <mingo@...e.hu>
To:	Jaswinder Singh Rajput <jaswinder@...nel.org>
Cc:	x86 maintainers <x86@...nel.org>,
	Andreas Herrmann <andreas.herrmann3@....com>,
	LKML <linux-kernel@...r.kernel.org>,
	Mark Langsdorf <mark.langsdorf@....com>
Subject: Re: [PATCH -tip] x86: k8.h reference to node in node_to_k8_nb_misc
	for !CONFIG_K8_NB


* Jaswinder Singh Rajput <jaswinder@...nel.org> wrote:

> On Tue, 2009-04-14 at 18:52 +0200, Ingo Molnar wrote:
> > * Jaswinder Singh Rajput <jaswinder@...nel.org> wrote:
> > 
> > > Add reference to node in node_to_k8_nb_misc for !CONFIG_K8_NB to make compiler happy.
> > > 
> > > So fixes compiler warnings:
> > >   arch/x86/kernel/cpu/intel_cacheinfo.c: In function ‘show_cache_disable’:
> > >   arch/x86/kernel/cpu/intel_cacheinfo.c:712: warning: unused variable ‘node’
> > >   arch/x86/kernel/cpu/intel_cacheinfo.c: In function ‘store_cache_disable’:
> > >   arch/x86/kernel/cpu/intel_cacheinfo.c:739: warning: unused variable ‘node’
> > > 
> > > Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@...il.com>
> > > ---
> > >  arch/x86/include/asm/k8.h |    2 +-
> > >  1 files changed, 1 insertions(+), 1 deletions(-)
> > > 
> > > diff --git a/arch/x86/include/asm/k8.h b/arch/x86/include/asm/k8.h
> > > index c23b3d1..c81e4ee 100644
> > > --- a/arch/x86/include/asm/k8.h
> > > +++ b/arch/x86/include/asm/k8.h
> > > @@ -16,7 +16,7 @@ extern int k8_scan_nodes(unsigned long start, unsigned long end);
> > >  #define node_to_k8_nb_misc(node) \
> > >  	(node < num_k8_northbridges) ? k8_northbridges[node] : NULL
> > >  #else
> > > -#define node_to_k8_nb_misc(node) NULL
> > > +#define node_to_k8_nb_misc(node) (node) ? NULL : NULL
> > >  #endif
> > 
> > Ugh, that's very ugly. I gave you a proper solution:
> > 
> > >> The typical way to solve this is to add a dummy:
> > >> 
> > >> 	(void)(cpu)
> > >> 
> > >> use to the 'cpu' parameter to the macro definition - or, 
> > >> (which is a much better solution), to convert it to an 
> > >> inline function.
> > 
> 
> Subject: [PATCH] x86: cpu/cacheinfo.c reference to node for node_to_k8_nb_misc for !CONFIG_K8_NB
> 
> Add reference to node for node_to_k8_nb_misc for !CONFIG_K8_NB to make compiler happy.
> 
> And fixes:
>   arch/x86/kernel/cpu/intel_cacheinfo.c: In function ‘show_cache_disable’:
>   arch/x86/kernel/cpu/intel_cacheinfo.c:712: warning: unused variable ‘node’
>   arch/x86/kernel/cpu/intel_cacheinfo.c: In function ‘store_cache_disable’:
>   arch/x86/kernel/cpu/intel_cacheinfo.c:739: warning: unused variable ‘node’
> 
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@...il.com>
> ---
>  arch/x86/kernel/cpu/intel_cacheinfo.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
> index 789efe2..4414c92 100644
> --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
> +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
> @@ -719,6 +719,7 @@ static ssize_t show_cache_disable(struct _cpuid4_info *this_leaf, char *buf,
>  	if (!dev)
>  		return -EINVAL;
>  
> +	(void)(node);

No, we should fix the node_to_k8_nb_misc() primitive.

I.e. convert node_to_k8_nb_misc() from a macro to an inline 
function. Same end result in terms of emitted instructions, 
but the compiler now knows that 'node' is really used.

With a macro the preprocessor hid this fact from the 
compiler, so the compiler only saw this in essence:

        int node = 0;
        struct pci_dev *dev;

and thought that 'node' was unused. Hence it emitted a 
warning. This is one reason why macros are bad - they hide 
program logic from the compiler.

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ