Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3878205ybz; Mon, 4 May 2020 11:21:38 -0700 (PDT) X-Google-Smtp-Source: APiQypI/b0l9t+a0nsH0AiyexD02aEw+PkBUTpzt3Uw6cjYoaXhzf5pJ0lqzdbJwQT3gbazaCqxY X-Received: by 2002:a50:99c4:: with SMTP id n4mr16372731edb.187.1588616497805; Mon, 04 May 2020 11:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588616497; cv=none; d=google.com; s=arc-20160816; b=V9bVpCune1z02SAj8XUfAncP99eb6oNDZMaWZiO8QIgCW6xJRoo5GaRiJKsV0PyWCc rnMDJapPMAgZBGKerdC1PEv8vD6lflkecEgdQtMJSGxxz0UNUv7RlSDKkAi9unX9oekS Y/izfaI+lLr3iADPPWiyEsbY5oJY6fbgdgsPtJ/3FoLe0WPbs8uN4Bs+4EFGaIiDOWeF rP8BWvGvflj93TYSsc7gwYN+czf8x6Pha39pXGp7OXTwx7vtoHZQ+lTX9k97aD4A8X1/ xGPVevvTbvhp/UsHj5NUg8m0aFNGgLXKV56SaQQq1cAp72STfihTWIbML8vjDx2Cwhce 3sLQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KKM9r+VoznRZvKRr9gwCP0na9JHdtZto5VlQIsTspL0=; b=Z3490WyYjOenRjRsENjsOPKuK3EU95tIpK3qgLw3AO5Xvp2QVM2Egd9NniZyhmjzmx 6qMYsXaGJz0dyE650PJoP0gGUEHgk9bjnu6eeeZxfyK9QdcDO17M5caUNF19YxbtA33P pH7u07JKlvQS9TPBeQ3yVTQY0aXTjK5CL9/tzYaPnPpy9mPa1SbfA+LouILvK461DWIa j9+lrfym5WkP6lHEgGhaW7lri/rbgXjGsVoIuLshdmwBbSMAMdDamDRHttBmrNMiPXFu jbRKuI5rdJ9/U2TSGu/9/zpyo6REwPagE5uJU0ew3066Ft1c6aJLmN/My70TUooyANps mnCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bk9PNNUO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s8si6417041edw.484.2020.05.04.11.21.13; Mon, 04 May 2020 11:21:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bk9PNNUO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730585AbgEDR6x (ORCPT + 99 others); Mon, 4 May 2020 13:58:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:51716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729977AbgEDR6u (ORCPT ); Mon, 4 May 2020 13:58:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 439D520707; Mon, 4 May 2020 17:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588615128; bh=wbkp8qqavz27ErAdxGpNXAyCPktsf8JUg0achhI6Gds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bk9PNNUODumqxZGFZ3WiAnr1JafCPyi+2DJYuOsQo+6iJQl/UtoR90RodDvp/HJUb LBUrUMCxTKLvy5F1EpMdbybG3P9ICY7pdDBMu/1ejHEnC5A6P/Uo2S63nbQAhA6Qbg BHY+Kt2fz61qdcXNJrXh9bL2B2tPFa+bBVZwt99U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Takashi Iwai Subject: [PATCH 4.4 07/18] ALSA: opti9xx: shut up gcc-10 range warning Date: Mon, 4 May 2020 19:57:05 +0200 Message-Id: <20200504165443.273457509@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200504165441.533160703@linuxfoundation.org> References: <20200504165441.533160703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann commit 5ce00760a84848d008554c693ceb6286f4d9c509 upstream. gcc-10 points out a few instances of suspicious integer arithmetic leading to value truncation: sound/isa/opti9xx/opti92x-ad1848.c: In function 'snd_opti9xx_configure': sound/isa/opti9xx/opti92x-ad1848.c:322:43: error: overflow in conversion from 'int' to 'unsigned char' changes value from '(int)snd_opti9xx_read(chip, 3) & -256 | 240' to '240' [-Werror=overflow] 322 | (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ sound/isa/opti9xx/opti92x-ad1848.c:351:3: note: in expansion of macro 'snd_opti9xx_write_mask' 351 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff); | ^~~~~~~~~~~~~~~~~~~~~~ sound/isa/opti9xx/miro.c: In function 'snd_miro_configure': sound/isa/opti9xx/miro.c:873:40: error: overflow in conversion from 'int' to 'unsigned char' changes value from '(int)snd_miro_read(chip, 3) & -256 | 240' to '240' [-Werror=overflow] 873 | (snd_miro_read(chip, reg) & ~(mask)) | ((value) & (mask))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ sound/isa/opti9xx/miro.c:1010:3: note: in expansion of macro 'snd_miro_write_mask' 1010 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff); | ^~~~~~~~~~~~~~~~~~~ These are all harmless here as only the low 8 bit are passed down anyway. Change the macros to inline functions to make the code more readable and also avoid the warning. Strictly speaking those functions also need locking to make the read/write pair atomic, but it seems unlikely that anyone would still run into that issue. Fixes: 1841f613fd2e ("[ALSA] Add snd-miro driver") Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20200429190216.85919-1-arnd@arndb.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/isa/opti9xx/miro.c | 9 ++++++--- sound/isa/opti9xx/opti92x-ad1848.c | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -875,10 +875,13 @@ static void snd_miro_write(struct snd_mi spin_unlock_irqrestore(&chip->lock, flags); } +static inline void snd_miro_write_mask(struct snd_miro *chip, + unsigned char reg, unsigned char value, unsigned char mask) +{ + unsigned char oldval = snd_miro_read(chip, reg); -#define snd_miro_write_mask(chip, reg, value, mask) \ - snd_miro_write(chip, reg, \ - (snd_miro_read(chip, reg) & ~(mask)) | ((value) & (mask))) + snd_miro_write(chip, reg, (oldval & ~mask) | (value & mask)); +} /* * Proc Interface --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -327,10 +327,13 @@ static void snd_opti9xx_write(struct snd } -#define snd_opti9xx_write_mask(chip, reg, value, mask) \ - snd_opti9xx_write(chip, reg, \ - (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) +static inline void snd_opti9xx_write_mask(struct snd_opti9xx *chip, + unsigned char reg, unsigned char value, unsigned char mask) +{ + unsigned char oldval = snd_opti9xx_read(chip, reg); + snd_opti9xx_write(chip, reg, (oldval & ~mask) | (value & mask)); +} static int snd_opti9xx_configure(struct snd_opti9xx *chip, long port,