Commit 75e2f0a6 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Ingo Molnar

x86/fpu/math-emu: Fix possible uninitialized variable use

When building the kernel with "make EXTRA_CFLAGS=...", this overrides
the "PARANOID" preprocessor macro defined in arch/x86/math-emu/Makefile,
and we run into a build warning:

  arch/x86/math-emu/reg_compare.c: In function ‘compare_i_st_st’:
  arch/x86/math-emu/reg_compare.c:254:6: error: ‘f’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

This fixes the implementation to work correctly even without the PARANOID
flag, and also fixes the Makefile to not use the EXTRA_CFLAGS variable
but instead use the ccflags-y variable in the Makefile that is meant
for this purpose.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Cc: Bill Metzenthen <billm@melbpc.org.au>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170719125310.2487451-3-arnd@arndb.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 11d8b058
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#DEBUG = -DDEBUGGING #DEBUG = -DDEBUGGING
DEBUG = DEBUG =
PARANOID = -DPARANOID PARANOID = -DPARANOID
EXTRA_CFLAGS := $(PARANOID) $(DEBUG) -fno-builtin $(MATH_EMULATION) ccflags-y += $(PARANOID) $(DEBUG) -fno-builtin $(MATH_EMULATION)
EXTRA_AFLAGS := $(PARANOID) asflags-y += $(PARANOID)
# From 'C' language sources: # From 'C' language sources:
C_OBJS =fpu_entry.o errors.o \ C_OBJS =fpu_entry.o errors.o \
......
...@@ -168,7 +168,7 @@ static int compare(FPU_REG const *b, int tagb) ...@@ -168,7 +168,7 @@ static int compare(FPU_REG const *b, int tagb)
/* This function requires that st(0) is not empty */ /* This function requires that st(0) is not empty */
int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag) int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag)
{ {
int f = 0, c; int f, c;
c = compare(loaded_data, loaded_tag); c = compare(loaded_data, loaded_tag);
...@@ -189,12 +189,12 @@ int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag) ...@@ -189,12 +189,12 @@ int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag)
case COMP_No_Comp: case COMP_No_Comp:
f = SW_C3 | SW_C2 | SW_C0; f = SW_C3 | SW_C2 | SW_C0;
break; break;
#ifdef PARANOID
default: default:
#ifdef PARANOID
EXCEPTION(EX_INTERNAL | 0x121); EXCEPTION(EX_INTERNAL | 0x121);
#endif /* PARANOID */
f = SW_C3 | SW_C2 | SW_C0; f = SW_C3 | SW_C2 | SW_C0;
break; break;
#endif /* PARANOID */
} }
setcc(f); setcc(f);
if (c & COMP_Denormal) { if (c & COMP_Denormal) {
...@@ -205,7 +205,7 @@ int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag) ...@@ -205,7 +205,7 @@ int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag)
static int compare_st_st(int nr) static int compare_st_st(int nr)
{ {
int f = 0, c; int f, c;
FPU_REG *st_ptr; FPU_REG *st_ptr;
if (!NOT_EMPTY(0) || !NOT_EMPTY(nr)) { if (!NOT_EMPTY(0) || !NOT_EMPTY(nr)) {
...@@ -235,12 +235,12 @@ static int compare_st_st(int nr) ...@@ -235,12 +235,12 @@ static int compare_st_st(int nr)
case COMP_No_Comp: case COMP_No_Comp:
f = SW_C3 | SW_C2 | SW_C0; f = SW_C3 | SW_C2 | SW_C0;
break; break;
#ifdef PARANOID
default: default:
#ifdef PARANOID
EXCEPTION(EX_INTERNAL | 0x122); EXCEPTION(EX_INTERNAL | 0x122);
#endif /* PARANOID */
f = SW_C3 | SW_C2 | SW_C0; f = SW_C3 | SW_C2 | SW_C0;
break; break;
#endif /* PARANOID */
} }
setcc(f); setcc(f);
if (c & COMP_Denormal) { if (c & COMP_Denormal) {
...@@ -283,12 +283,12 @@ static int compare_i_st_st(int nr) ...@@ -283,12 +283,12 @@ static int compare_i_st_st(int nr)
case COMP_No_Comp: case COMP_No_Comp:
f = X86_EFLAGS_ZF | X86_EFLAGS_PF | X86_EFLAGS_CF; f = X86_EFLAGS_ZF | X86_EFLAGS_PF | X86_EFLAGS_CF;
break; break;
#ifdef PARANOID
default: default:
#ifdef PARANOID
EXCEPTION(EX_INTERNAL | 0x122); EXCEPTION(EX_INTERNAL | 0x122);
#endif /* PARANOID */
f = 0; f = 0;
break; break;
#endif /* PARANOID */
} }
FPU_EFLAGS = (FPU_EFLAGS & ~(X86_EFLAGS_ZF | X86_EFLAGS_PF | X86_EFLAGS_CF)) | f; FPU_EFLAGS = (FPU_EFLAGS & ~(X86_EFLAGS_ZF | X86_EFLAGS_PF | X86_EFLAGS_CF)) | f;
if (c & COMP_Denormal) { if (c & COMP_Denormal) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment