x86: math-emu: fix function cast warnings
PATCH 1/1 x86: math-emu: fix function cast warnings
From: Arnd Bergmann <[email protected]>
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.
--- arch/x86/math-emu/fpu_etc.c | 9 +++++++-- arch/x86/math-emu/fpu_trig.c | 6 +++--- arch/x86/math-emu/reg_constant.c | 7 ++++++- 3 files changed, 16 insertions(+), 6 deletions(-)
arch/x86/math-emu/fpu_etc.c +7 -2
@@ -120,9 +120,14 @@ static void fxam(FPU_REG *st0_ptr, u_char st0tag)setcc (c); } +static void FPU_ST0_illegal (FPU_REG *st0_ptr,u_char st0_tag) +{ +FPU_illegal (); +} +static FUNC_ST0 const fp_etc_table[] = { - fchs, fabs, (FUNC_ST0 ) FPU_illegal, (FUNC_ST0 ) FPU_illegal, - ftst_, fxam, (FUNC_ST0 ) FPU_illegal, (FUNC_ST0 ) FPU_illegal + fchs, fabs, FPU_ST0_illegal, FPU_ST0_illegal, + ftst_, fxam, FPU_ST0_illegal, FPU_ST0_illegal, };void FPU_etc (void )
arch/x86/math-emu/fpu_trig.c +3 -3
@@ -433,13 +433,13 @@ static void fxtract(FPU_REG *st0_ptr, u_char st0_tag)#endif /* PARANOID */ } -static void fdecstp (void ) +static void fdecstp (FPU_REG *st0_ptr,u_char st0_tag) {clear_C1 (); top--; } -static void fincstp (void ) +static void fincstp (FPU_REG *st0_ptr,u_char st0_tag) {clear_C1 (); top++;
@@ -1631,7 +1631,7 @@ static void fscale(FPU_REG *st0_ptr, u_char st0_tag)static FUNC_ST0 const trig_table_a[] = { f2xm1, fyl2x, fptan, fpatan, - fxtract, fprem1, (FUNC_ST0 ) fdecstp, (FUNC_ST0 ) fincstp + fxtract, fprem1, fdecstp, fincstp, };void FPU_triga (void )
arch/x86/math-emu/reg_constant.c +6 -1
@@ -108,8 +108,13 @@ static void fldz(int rc)typedef void (*FUNC_RC ) (int ); +static void FPU_RC_illegal (int unused) +{ +FPU_illegal (); +} +static FUNC_RC constants_table[] = { - fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, (FUNC_RC ) FPU_illegal + fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, FPU_RC_illegal };void fconst (void )
Signature · 1 line
2.39.2
[tip: x86/cleanups] x86/math-emu: Fix function cast warnings
The following commit has been merged into the x86/cleanups branch of tip:
The following commit has been merged into the x86/cleanups branch of tip:
Commit-ID: e0ca9353a86c0459a9c3fc8d65f7c88e96217cea Gitweb: https://git.kernel.org/tip/e0ca9353a86c0459a9c3fc8d65f7c88e96217cea Author: Arnd Bergmann <[email protected]> AuthorDate: Thu, 04 Apr 2024 18:17:24 +02:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Mon, 08 Apr 2024 16:06:22 +02:00
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_illegalChange the fdecstp() and fincstp() functions to actually have the correct prototypes based on the caller, and add wrappers around FPU_illegal() for adapting those.
--- arch/x86/math-emu/fpu_etc.c | 9 +++++++-- arch/x86/math-emu/fpu_trig.c | 6 +++--- arch/x86/math-emu/reg_constant.c | 7 ++++++- 3 files changed, 16 insertions(+), 6 deletions(-)
arch/x86/math-emu/fpu_etc.c +7 -2
@@ -120,9 +120,14 @@ static void fxam(FPU_REG *st0_ptr, u_char st0tag)setcc (c); } +static void FPU_ST0_illegal (FPU_REG *st0_ptr,u_char st0_tag) +{ +FPU_illegal (); +} +static FUNC_ST0 const fp_etc_table[] = { - fchs, fabs, (FUNC_ST0 ) FPU_illegal, (FUNC_ST0 ) FPU_illegal, - ftst_, fxam, (FUNC_ST0 ) FPU_illegal, (FUNC_ST0 ) FPU_illegal + fchs, fabs, FPU_ST0_illegal, FPU_ST0_illegal, + ftst_, fxam, FPU_ST0_illegal, FPU_ST0_illegal, };void FPU_etc (void )
arch/x86/math-emu/fpu_trig.c +3 -3
@@ -433,13 +433,13 @@ static void fxtract(FPU_REG *st0_ptr, u_char st0_tag)#endif /* PARANOID */ } -static void fdecstp (void ) +static void fdecstp (FPU_REG *st0_ptr,u_char st0_tag) {clear_C1 (); top--; } -static void fincstp (void ) +static void fincstp (FPU_REG *st0_ptr,u_char st0_tag) {clear_C1 (); top++;
@@ -1631,7 +1631,7 @@ static void fscale(FPU_REG *st0_ptr, u_char st0_tag)static FUNC_ST0 const trig_table_a[] = { f2xm1, fyl2x, fptan, fpatan, - fxtract, fprem1, (FUNC_ST0 ) fdecstp, (FUNC_ST0 ) fincstp + fxtract, fprem1, fdecstp, fincstp, };void FPU_triga (void )
arch/x86/math-emu/reg_constant.c +6 -1
@@ -108,8 +108,13 @@ static void fldz(int rc)typedef void (*FUNC_RC ) (int ); +static void FPU_RC_illegal (int unused) +{ +FPU_illegal (); +} +static FUNC_RC constants_table[] = { - fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, (FUNC_RC ) FPU_illegal + fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, FPU_RC_illegal };void fconst (void )