From patchwork Fri Jul 12 09:08:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 168917 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp599499ilk; Fri, 12 Jul 2019 02:08:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbQLCpjxg9zEtLdUubGJXzENtm1+bQ6aB4z7lfNMhEmMfbmjPeE8a1gr7TqLL5MsGcmmmG X-Received: by 2002:a17:902:28:: with SMTP id 37mr9398389pla.188.1562922537206; Fri, 12 Jul 2019 02:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562922537; cv=none; d=google.com; s=arc-20160816; b=t/h3A4EJJqdRpP0AI07x8PeE5FDr9R5PqAcuuYkS8OPwC4oa27H1yAuhWUlo8N066u LHwCgKE5sOtRqAkGbDwPNTAUYiKM4cyhapUb0PGXDn1fBG+RHMgJUKowwFZV2Pwfk79N No/8eaWRlxmhPFhr42h6wQVne7yJR5zzupopVoVO9ARBHoeEC2O6q+H+UZsSPH+qgblU rXyJGVQjAHLpnpUv2urGu14Hg2H2CdcB3XGBvN3vocK67Kn2q7vSEylEAztagy+Hil/D DWfOdwhyabpV2dqrVxWDeKlvuJWQAq1KnFshA28VygOhrXXArK3h3pje1QBhUJeX7qIv 494A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=vYDc5/Lqjd+Tuqx4WSF+XbJHJdfScRV6ypj+2PR7VSc=; b=TF6eAsxIfmVQVW+dDyiSAJuvY5i7j/1HFthfwiT9gebY5OQHI/0pBN+ZwZOqWgB3cg EocMIf4fOt7/CmFSbJinBV0d57/KHjB/8T+fyo+Y9UtvgmCef64W6qSNJLiajgSmTbkE bPZyDP4XXEzCO9jBkq6kboHgp7WujXFFiD3000C17D0CVI9RDpEu/05+OacMLAaU+yVa pkLOyx8uBD7M8+xT6GAf5uzz9xEiFaqzkqcRIQUNw24DO/6le3DYQARiGHIWJvDHYlc0 wQxnLTNVk33E4BQ5NAbUQ+i/L5csG0ktlhm3ccpN5+xhFVATTO4GGAvMkd6/bNLd+EB4 vbeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g190si7355803pgc.131.2019.07.12.02.08.56; Fri, 12 Jul 2019 02:08:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726560AbfGLJIz (ORCPT + 29 others); Fri, 12 Jul 2019 05:08:55 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:39345 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726069AbfGLJIz (ORCPT ); Fri, 12 Jul 2019 05:08:55 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MplTn-1iG0uE1AyL-00qEvZ; Fri, 12 Jul 2019 11:08:19 +0200 From: Arnd Bergmann To: Bill Metzenthen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org Cc: Arnd Bergmann , "H. Peter Anvin" , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] x86: math-emu: hide clang warnings for 16-bit overflow Date: Fri, 12 Jul 2019 11:08:05 +0200 Message-Id: <20190712090816.350668-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:uhLktPXipGj6UjosCrqPbx7X8MXcIoq8JHYIteyEjX5+chvN09m nduPEVAS3tXz5QEMuMJoSbjgSPxubfKqoNq9gelCGmZ4qUcJyCjVAX9IlCU44FSmVGd0kOY tJC59GiELBqUb7DBFtQomOTdVxux6lsCsNW2atgevOUK1GdUy3EXPCSuoI8GapZZHRoahDN 1qkYo7cqbXOMbc9IYCY+A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:o6PG+rhksf0=:NUqwYYsc9m85a6HXmY8xe4 7zgquXhqavLN5KLe0gnzkonSgYCYfpwXzsxMl0eFOuLzOu+AmbiF1os3kde3o9QMlRDdYumbJ U3zYPXsHexYZK87gPKiAYu0UlXwb9dmWNtnQeHaDDejnbTwK0SkHWPW+6ZSbCXQxgOoJr0+Eb tCt8/zLTRmC+aLS7az9vebwvzcp+/1AN45cOLO4lCW3DZwI0fwZRFMAsaVk2xO8cGoVQlHP1F izhaIeYKUPmyg/MCGRB80t+z2RpHp35cRsx6wBSKplzaVKxYKqz3qA9mJqfhMDnhFezfnwosc +n3gHYuXWeK0/CWg1WFf64huWV9nX7MrLNzf4gCDAFNK1T0SuavAc/tNRqSr18PEjOEHGtBDi Gp20XDw0xEfJ7BX7twyKru3tqq26WA8Gn2SoGqSZwskmYbHZSbQWRIZscitRClxy4xC5fCazT /Me3/1RnoFTttx6qvNalRXsIkOO/XI/pFY54+VNbI0zeQxPOxSRCXuyNMYqfFZb3KxTCn5zsD GX+bLZ/LV0w78NeLYXeNZgERNjsdsspk3kZd0NZKed+Ux6zxMT1zFBDtCztzauJPyPMN8ODdq wQ4FfXIXq7L5kU53y0I7PEnVoZ1dHnAkQrVAu44rrqgzd0sscFCNTf/3oP9EW+TejYK0+jEMJ peMJ5gky6ORCtVi8E2v8TNS9GMB00r8VJUivNYTaWwRe6iH/PakRraYWVOOsnXgOyyOaANonm XmYI7hDW5Jc6WDJkl6UUgJPbeK5jFBGXwwLhZQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org clang warns about a few parts of the math-emu implementation where a 16-bit integer becomes negative during assignment: arch/x86/math-emu/poly_tan.c:88:35: error: implicit conversion from 'int' to 'short' changes value from 49216 to -16320 [-Werror,-Wconstant-conversion] (0x41 + EXTENDED_Ebias) | SIGN_Negative); ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ arch/x86/math-emu/fpu_emu.h:180:58: note: expanded from macro 'setexponent16' #define setexponent16(x,y) { (*(short *)&((x)->exp)) = (y); } ~ ^ arch/x86/math-emu/reg_constant.c:37:32: error: implicit conversion from 'int' to 'short' changes value from 49085 to -16451 [-Werror,-Wconstant-conversion] FPU_REG const CONST_PI2extra = MAKE_REG(NEG, -66, ^~~~~~~~~~~~~~~~~~ arch/x86/math-emu/reg_constant.c:21:25: note: expanded from macro 'MAKE_REG' ((EXTENDED_Ebias+(e)) | ((SIGN_##s != 0)*0x8000)) } ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/math-emu/reg_constant.c:48:28: error: implicit conversion from 'int' to 'short' changes value from 65535 to -1 [-Werror,-Wconstant-conversion] FPU_REG const CONST_QNaN = MAKE_REG(NEG, EXP_OVER, 0x00000000, 0xC0000000); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/math-emu/reg_constant.c:21:25: note: expanded from macro 'MAKE_REG' ((EXTENDED_Ebias+(e)) | ((SIGN_##s != 0)*0x8000)) } ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ The code seems correct to me, so add a typecast to shut up the warnings. Signed-off-by: Arnd Bergmann --- arch/x86/math-emu/fpu_emu.h | 2 +- arch/x86/math-emu/reg_constant.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.20.0 diff --git a/arch/x86/math-emu/fpu_emu.h b/arch/x86/math-emu/fpu_emu.h index a5a41ec58072..0c122226ca56 100644 --- a/arch/x86/math-emu/fpu_emu.h +++ b/arch/x86/math-emu/fpu_emu.h @@ -177,7 +177,7 @@ static inline void reg_copy(FPU_REG const *x, FPU_REG *y) #define setexponentpos(x,y) { (*(short *)&((x)->exp)) = \ ((y) + EXTENDED_Ebias) & 0x7fff; } #define exponent16(x) (*(short *)&((x)->exp)) -#define setexponent16(x,y) { (*(short *)&((x)->exp)) = (y); } +#define setexponent16(x,y) { (*(short *)&((x)->exp)) = (u16)(y); } #define addexponent(x,y) { (*(short *)&((x)->exp)) += (y); } #define stdexp(x) { (*(short *)&((x)->exp)) += EXTENDED_Ebias; } diff --git a/arch/x86/math-emu/reg_constant.c b/arch/x86/math-emu/reg_constant.c index 8dc9095bab22..742619e94bdf 100644 --- a/arch/x86/math-emu/reg_constant.c +++ b/arch/x86/math-emu/reg_constant.c @@ -18,7 +18,7 @@ #include "control_w.h" #define MAKE_REG(s, e, l, h) { l, h, \ - ((EXTENDED_Ebias+(e)) | ((SIGN_##s != 0)*0x8000)) } + (u16)((EXTENDED_Ebias+(e)) | ((SIGN_##s != 0)*0x8000)) } FPU_REG const CONST_1 = MAKE_REG(POS, 0, 0x00000000, 0x80000000); #if 0