Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2945275rdb; Tue, 13 Feb 2024 01:58:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUymVcEFRuF5X3CoNhOe5Kr9taRl9L75thq0B//Ktvi000nDkUiZm6RrNtsg28AP9kdR2s8tBhTzUm4RUxpnCzdB34UcKhAs6eqIllEAw== X-Google-Smtp-Source: AGHT+IEWZmagrrPViIK/vtkOaUEIada3gb3lR6VKDxRmLg19S0EhqlkuR3qHT8kA5m2Y43FmmTCw X-Received: by 2002:a05:622a:211:b0:42c:7c0e:1dda with SMTP id b17-20020a05622a021100b0042c7c0e1ddamr5992508qtx.6.1707818326497; Tue, 13 Feb 2024 01:58:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707818326; cv=pass; d=google.com; s=arc-20160816; b=cbVOkI5Jy0/4LQ73/qtfZF+vT75h8YO//Up9zkFRPq48LbY2kmbXDAMYxBaSGSIRjI 18uvU4sE19zl4RIkKxibWvrXnGfFz1tBUyCBCKdJEEa3iD7cZF6HPKbFicRhpFFwQ2UY eeLypkpbG/G8MYuOAl5fVzQEhyJc7AyPa7SPaIgOk4V7LfYfa7FTtu6ku4nHil0veG+I LnLV2cECuadX2tBtoDgMLBSjxMqHzvqdaee8KKEHnEm7P2sFmZeXVt3v50NH9cBY5VGv jxz6aXosuNMov396R41UOGSr3RkDEwKg7hGTpeZ0xWtTzFySHbyl9iw1owjXbvCEX8Gy D2Aw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=c3/HPgyCrNUYsp1FEg1ipxWjOli+WPhdmD/eOd5o/Qo=; fh=vaGyGC/gIvJvV/tvSku1Gp5MqvE15v1XY8gS0QPodNM=; b=QCW+fj3SkpzULjD/+CSdoY/V9FlCV+jnG+6Bp4iRtTagSlKhbnAZl5zxDnjaGFngrJ QFue+obh7lNwaNPnMhkoTnzKUPxyzKNM1QBGRmlV7SS6UbMu2ECwjPVAn8UQkGC3v1aL GwxVw3w+XrkuXLXV6pEoMmpQc2l+V7yI3dXJPP9c9NnNkfDAny8AUORvKNyNNOBy748x Efj9SlKzUzfGylWLV38DGZPpz+J+cTiq9iDM55gaAo8+sG8DPo49mE8Fu/YnnFYHtb4Z BAndTcIs/9Y8Gs9DN+Trh1/NDMA7WctUjqPNMpu7Fu9HDhdQyPWGePIfOdhuZJP4FN/R g+2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VJt5Is3z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63280-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63280-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWtx/wVSy1+8WgLXl1smn0qMHiU56/rWNk7duFmsv2PX2MoG6s2WnKksDziQho6G4XKA1wyS0uPp3ymfRVZSwnBfgvAV2r3qr5zMJhjaw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w13-20020ac843cd000000b0042c3cf56d1csi2280042qtn.65.2024.02.13.01.58.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:58:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63280-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VJt5Is3z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63280-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63280-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 08EC31C21938 for ; Tue, 13 Feb 2024 09:57:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC7E42BB0C; Tue, 13 Feb 2024 09:56:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VJt5Is3z" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00EAD2BB03; Tue, 13 Feb 2024 09:56:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707818198; cv=none; b=NkvBj1BrSCpbRlMfHcd4mXtv9JtPYXGmY7T9tbMmaubbDPPX292w1W5CMW5FNyMS+aTJ++D1mzjBvbkhLFkoLRdq7VY0Lp5011YvXl7PRBKRqxNbQxYCBZ4DFwlO7oXtNsAzalIyXBPTeypD61B2PxFU1jm2BXjS59Dr6kxMuUU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707818198; c=relaxed/simple; bh=vb+KBTnTSXAaZj4rUNtfS8bhDG7fD2FUJ5wHxmolX/E=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=fmgzXFa51Ne0/9oRsGdNgC0btrCLDyBdEoq/cFdGCMtAHiChlIs1XghMfLZt1sEpfbDI5GiO5OXfjt8nNsKygG7w+xJR4M5g8f6rjKoQPXUtZIARVbjZn+Vqlqjth8T2yaLCfucua95slO8wNXWUusNNIR0IF22QxQdVCzqxtpo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VJt5Is3z; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B311C433F1; Tue, 13 Feb 2024 09:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707818197; bh=vb+KBTnTSXAaZj4rUNtfS8bhDG7fD2FUJ5wHxmolX/E=; h=From:To:Cc:Subject:Date:From; b=VJt5Is3zeq/Zjfhdhjq8lEVPdZGh9L98WDNDPu7YIB/pra9bf1JMk+PkxRtLD72Gp mteiCp8/9APkYVFjHL3prsi4G+T3O/kR4aasJs7NxYovDHmx5aHQOP+3qDUjD92tOB Vjgw2uq3LJ77tCCvbEEOdYkY3ObnM0ABaKvIS3cAZSF1CrJwiUI79HYWUI5QUXY3kD cdf37TIDn/ZXNojU9QUqRlEFdMWp9Grs0c2n/GdVTHH1mu6AFk9B6VuAQP7EWsJPxh v6AXbU/kPsJj5dpXWOtVEuvYE4uZUwJ5Ve10QMBCCrpfX3SW1MGoxsNVITLP2LvVbM BWv8cg4PPfTqg== From: Arnd Bergmann To: Bill Metzenthen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: Arnd Bergmann , "H. Peter Anvin" , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] x86: math-emu: fix function cast warnings Date: Tue, 13 Feb 2024 10:56:18 +0100 Message-Id: <20240213095631.454543-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann 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 --- 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(-) diff --git a/arch/x86/math-emu/fpu_etc.c b/arch/x86/math-emu/fpu_etc.c index 1b118fd93140..39423ec409e1 100644 --- a/arch/x86/math-emu/fpu_etc.c +++ b/arch/x86/math-emu/fpu_etc.c @@ -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) diff --git a/arch/x86/math-emu/fpu_trig.c b/arch/x86/math-emu/fpu_trig.c index 990d847ae902..85daf98c81c3 100644 --- a/arch/x86/math-emu/fpu_trig.c +++ b/arch/x86/math-emu/fpu_trig.c @@ -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) diff --git a/arch/x86/math-emu/reg_constant.c b/arch/x86/math-emu/reg_constant.c index 742619e94bdf..003a0b2753e6 100644 --- a/arch/x86/math-emu/reg_constant.c +++ b/arch/x86/math-emu/reg_constant.c @@ -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) -- 2.39.2