virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/10] I386 mcheck p4 grotesque and needless warning fix.patch
@ 2007-04-10  0:06 Zachary Amsden
  2007-04-10 14:06 ` Chuck Ebbert
  2007-04-10 14:36 ` Jesper Juhl
  0 siblings, 2 replies; 3+ messages in thread
From: Zachary Amsden @ 2007-04-10  0:06 UTC (permalink / raw)
  To: Andrew Morton, Andi Kleen, Jeremy Fitzhardinge, Rusty Russell,
	Chris Wright, Virtualization Mailing List,
	Linux Kernel Mailing List, Zachary Amsden

No, just no.  You do not use goto to skip a code block.  You do not
return an obvious variable from a singly-inlined function and give
the function a return value.  You don't put unexplained comments
about kmalloc in code which doesn't do dynamic allocation.  And
you don't leave stray warnings around for no good reason.

Also, when possible, it is better to use block scoped variables
because gcc can sometime generate better code.

Signed-off-by: Zachary Amsden <zach@vmware.com>

diff -r ed741f57dae8 arch/i386/kernel/cpu/mcheck/p4.c
--- a/arch/i386/kernel/cpu/mcheck/p4.c	Fri Apr 06 14:29:52 2007 -0700
+++ b/arch/i386/kernel/cpu/mcheck/p4.c	Fri Apr 06 14:43:24 2007 -0700
@@ -124,12 +124,9 @@ static void intel_init_thermal(struct cp
 
 
 /* P4/Xeon Extended MCE MSR retrieval, return 0 if unsupported */
-static inline int intel_get_extended_msrs(struct intel_mce_extended_msrs *r)
+static inline void intel_get_extended_msrs(struct intel_mce_extended_msrs *r)
 {
 	u32 h;
-
-	if (mce_num_extended_msrs == 0)
-		goto done;
 
 	rdmsr (MSR_IA32_MCG_EAX, r->eax, h);
 	rdmsr (MSR_IA32_MCG_EBX, r->ebx, h);
@@ -141,12 +138,6 @@ static inline int intel_get_extended_msr
 	rdmsr (MSR_IA32_MCG_ESP, r->esp, h);
 	rdmsr (MSR_IA32_MCG_EFLAGS, r->eflags, h);
 	rdmsr (MSR_IA32_MCG_EIP, r->eip, h);
-
-	/* can we rely on kmalloc to do a dynamic
-	 * allocation for the reserved registers?
-	 */
-done:
-	return mce_num_extended_msrs;
 }
 
 static fastcall void intel_machine_check(struct pt_regs * regs, long error_code)
@@ -155,7 +146,6 @@ static fastcall void intel_machine_check
 	u32 alow, ahigh, high, low;
 	u32 mcgstl, mcgsth;
 	int i;
-	struct intel_mce_extended_msrs dbg;
 
 	rdmsr (MSR_IA32_MCG_STATUS, mcgstl, mcgsth);
 	if (mcgstl & (1<<0))	/* Recoverable ? */
@@ -164,7 +154,9 @@ static fastcall void intel_machine_check
 	printk (KERN_EMERG "CPU %d: Machine Check Exception: %08x%08x\n",
 		smp_processor_id(), mcgsth, mcgstl);
 
-	if (intel_get_extended_msrs(&dbg)) {
+	if (mce_num_extended_msrs > 0) {
+		struct intel_mce_extended_msrs dbg;
+		intel_get_extended_msrs(&dbg);
 		printk (KERN_DEBUG "CPU %d: EIP: %08x EFLAGS: %08x\n",
 			smp_processor_id(), dbg.eip, dbg.eflags);
 		printk (KERN_DEBUG "\teax: %08x ebx: %08x ecx: %08x edx: %08x\n",

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 3/10] I386 mcheck p4 grotesque and needless warning fix.patch
  2007-04-10  0:06 [PATCH 3/10] I386 mcheck p4 grotesque and needless warning fix.patch Zachary Amsden
@ 2007-04-10 14:06 ` Chuck Ebbert
  2007-04-10 14:36 ` Jesper Juhl
  1 sibling, 0 replies; 3+ messages in thread
From: Chuck Ebbert @ 2007-04-10 14:06 UTC (permalink / raw)
  To: Zachary Amsden
  Cc: Andrew Morton, Andi Kleen, Jeremy Fitzhardinge, Rusty Russell,
	Chris Wright, Virtualization Mailing List,
	Linux Kernel Mailing List

Zachary Amsden wrote:
> No, just no.  You do not use goto to skip a code block.  You do not
> return an obvious variable from a singly-inlined function and give
> the function a return value.  You don't put unexplained comments
> about kmalloc in code which doesn't do dynamic allocation.  And
> you don't leave stray warnings around for no good reason.
> 
> Also, when possible, it is better to use block scoped variables
> because gcc can sometime generate better code.
> 
> Signed-off-by: Zachary Amsden <zach@vmware.com>
> 
> diff -r ed741f57dae8 arch/i386/kernel/cpu/mcheck/p4.c
> --- a/arch/i386/kernel/cpu/mcheck/p4.c	Fri Apr 06 14:29:52 2007 -0700
> +++ b/arch/i386/kernel/cpu/mcheck/p4.c	Fri Apr 06 14:43:24 2007 -0700
> @@ -124,12 +124,9 @@ static void intel_init_thermal(struct cp
>  
>  
>  /* P4/Xeon Extended MCE MSR retrieval, return 0 if unsupported */
> -static inline int intel_get_extended_msrs(struct intel_mce_extended_msrs *r)
> +static inline void intel_get_extended_msrs(struct intel_mce_extended_msrs *r)
>  {

The comment needs fixing.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 3/10] I386 mcheck p4 grotesque and needless warning fix.patch
  2007-04-10  0:06 [PATCH 3/10] I386 mcheck p4 grotesque and needless warning fix.patch Zachary Amsden
  2007-04-10 14:06 ` Chuck Ebbert
@ 2007-04-10 14:36 ` Jesper Juhl
  1 sibling, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2007-04-10 14:36 UTC (permalink / raw)
  To: Zachary Amsden
  Cc: Andrew Morton, Andi Kleen, Chris Wright,
	Virtualization Mailing List, Linux Kernel Mailing List

On 10/04/07, Zachary Amsden <zach@vmware.com> wrote:
> No, just no.  You do not use goto to skip a code block.  You do not
> return an obvious variable from a singly-inlined function and give
> the function a return value.  You don't put unexplained comments
> about kmalloc in code which doesn't do dynamic allocation.  And
> you don't leave stray warnings around for no good reason.
>
> Also, when possible, it is better to use block scoped variables
> because gcc can sometime generate better code.
>
> Signed-off-by: Zachary Amsden <zach@vmware.com>
>
> diff -r ed741f57dae8 arch/i386/kernel/cpu/mcheck/p4.c
> --- a/arch/i386/kernel/cpu/mcheck/p4.c  Fri Apr 06 14:29:52 2007 -0700
> +++ b/arch/i386/kernel/cpu/mcheck/p4.c  Fri Apr 06 14:43:24 2007 -0700
[...]
>  static fastcall void intel_machine_check(struct pt_regs * regs, long error_code)
> @@ -155,7 +146,6 @@ static fastcall void intel_machine_check
>         u32 alow, ahigh, high, low;
>         u32 mcgstl, mcgsth;
>         int i;
> -       struct intel_mce_extended_msrs dbg;
>
>         rdmsr (MSR_IA32_MCG_STATUS, mcgstl, mcgsth);
>         if (mcgstl & (1<<0))    /* Recoverable ? */
> @@ -164,7 +154,9 @@ static fastcall void intel_machine_check
>         printk (KERN_EMERG "CPU %d: Machine Check Exception: %08x%08x\n",
>                 smp_processor_id(), mcgsth, mcgstl);
>
> -       if (intel_get_extended_msrs(&dbg)) {
> +       if (mce_num_extended_msrs > 0) {
> +               struct intel_mce_extended_msrs dbg;

shouldn't there be a blank line here?

> +               intel_get_extended_msrs(&dbg);
>                 printk (KERN_DEBUG "CPU %d: EIP: %08x EFLAGS: %08x\n",
>                         smp_processor_id(), dbg.eip, dbg.eflags);
>                 printk (KERN_DEBUG "\teax: %08x ebx: %08x ecx: %08x edx: %08x\n",


-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-04-10 14:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-10  0:06 [PATCH 3/10] I386 mcheck p4 grotesque and needless warning fix.patch Zachary Amsden
2007-04-10 14:06 ` Chuck Ebbert
2007-04-10 14:36 ` Jesper Juhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).