Skip to content

Commit e0ca935

Browse files
arndbbp3tk0v
authored andcommitted
x86/math-emu: Fix function cast warnings
clang-16 warns about casting function pointers with incompatible prototypes. The x86 math-emu code does this in a number of places to call some trivial functions that need no arguments: arch/x86/math-emu/fpu_etc.c:124:14: error: cast from 'void (*)(void)' to 'FUNC_ST0' \ (aka 'void (*)(struct fpu__reg *, unsigned char)') converts to incompatible function \ type [-Werror,-Wcast-function-type-strict] 124 | fchs, fabs, (FUNC_ST0) FPU_illegal, (FUNC_ST0) FPU_illegal, | ^~~~~~~~~~~~~~~~~~~~~~ arch/x86/math-emu/fpu_trig.c:1634:19: error: cast from 'void (*)(void)' to 'FUNC_ST0' \ (aka 'void (*)(struct fpu__reg *, unsigned char)') converts to incompatible function \ type [-Werror,-Wcast-function-type-strict] 1634 | fxtract, fprem1, (FUNC_ST0) fdecstp, (FUNC_ST0) fincstp | ^~~~~~~~~~~~~~~~~~ arch/x86/math-emu/reg_constant.c:112:53: error: cast from 'void (*)(void)' to 'FUNC_RC' \ (aka 'void (*)(int)') converts to incompatible function \ type [-Werror,-Wcast-function-type-strict] 112 | fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, (FUNC_RC) FPU_illegal Change the fdecstp() and fincstp() functions to actually have the correct prototypes based on the caller, and add wrappers around FPU_illegal() for adapting those. Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]
1 parent cb51761 commit e0ca935

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

arch/x86/math-emu/fpu_etc.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,14 @@ static void fxam(FPU_REG *st0_ptr, u_char st0tag)
120120
setcc(c);
121121
}
122122

123+
static void FPU_ST0_illegal(FPU_REG *st0_ptr, u_char st0_tag)
124+
{
125+
FPU_illegal();
126+
}
127+
123128
static FUNC_ST0 const fp_etc_table[] = {
124-
fchs, fabs, (FUNC_ST0) FPU_illegal, (FUNC_ST0) FPU_illegal,
125-
ftst_, fxam, (FUNC_ST0) FPU_illegal, (FUNC_ST0) FPU_illegal
129+
fchs, fabs, FPU_ST0_illegal, FPU_ST0_illegal,
130+
ftst_, fxam, FPU_ST0_illegal, FPU_ST0_illegal,
126131
};
127132

128133
void FPU_etc(void)

arch/x86/math-emu/fpu_trig.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,13 @@ static void fxtract(FPU_REG *st0_ptr, u_char st0_tag)
433433
#endif /* PARANOID */
434434
}
435435

436-
static void fdecstp(void)
436+
static void fdecstp(FPU_REG *st0_ptr, u_char st0_tag)
437437
{
438438
clear_C1();
439439
top--;
440440
}
441441

442-
static void fincstp(void)
442+
static void fincstp(FPU_REG *st0_ptr, u_char st0_tag)
443443
{
444444
clear_C1();
445445
top++;
@@ -1631,7 +1631,7 @@ static void fscale(FPU_REG *st0_ptr, u_char st0_tag)
16311631

16321632
static FUNC_ST0 const trig_table_a[] = {
16331633
f2xm1, fyl2x, fptan, fpatan,
1634-
fxtract, fprem1, (FUNC_ST0) fdecstp, (FUNC_ST0) fincstp
1634+
fxtract, fprem1, fdecstp, fincstp,
16351635
};
16361636

16371637
void FPU_triga(void)

arch/x86/math-emu/reg_constant.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,13 @@ static void fldz(int rc)
108108

109109
typedef void (*FUNC_RC) (int);
110110

111+
static void FPU_RC_illegal(int unused)
112+
{
113+
FPU_illegal();
114+
}
115+
111116
static FUNC_RC constants_table[] = {
112-
fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, (FUNC_RC) FPU_illegal
117+
fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, FPU_RC_illegal
113118
};
114119

115120
void fconst(void)

0 commit comments

Comments
 (0)