Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3869523ybz; Mon, 4 May 2020 11:12:31 -0700 (PDT) X-Google-Smtp-Source: APiQypIm62UVYYYyKjfkPavCgrzyfkX+XcCPbz2gv/mwSgC6H7Af8kg8oAQ4/lA7owSfOQuRBwom X-Received: by 2002:a17:906:4e8f:: with SMTP id v15mr16440415eju.321.1588615951830; Mon, 04 May 2020 11:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588615951; cv=none; d=google.com; s=arc-20160816; b=xAxgl7R69cP2VvhMxgzM31C/rlycVIdVlWg45e/+JtWGodJObJEEdgF/wjANJ+QW4x FvsyOv3tiMsqjE19H/S97TBm51wViP9oPrN/buCw04W6Dkki68Lvyu3Dl1A4TRRhrej6 7lzZuO5cW1mUFp5CWw/ikXgCDmTOkgQkQ5eE9PS8sEfA+CIQIfe30AiYQjOjywBIYxgc D56Znl7dxWOoqRWLuCan5q84sEp/vQzu9QOfYjKImSZWqNFQ300vg1SuzzGWjeZsiKmC Mtj42CE1Y/yoScG9qxQgHaTOihhdXDAl8kfWMoyFgHInww2tLB844d/7EKdFemqiV11s qvGA== 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=In+Ir9OcSCYLFZ0fV7jImLiCPGklYkbuCzPosr8I7/4=; b=ZM9MNn23dZccUAjRXSu6zYSdfBlny3LJW1I6sx2SHWvdcYMlpCx1POD0E13gDk+wHM XRZpgjLfOONEcnw1ttpKuqQfe4FyiuRhvT/Z8sPl5Mlmi1dZKr8mDUCcnHwSqoBf+jzF /qUm9hwq4ktB/+0PQOCPX6YYEybV8aKRrXTeCNQkDvm1ph5oiVMmLhJwaDLqXJ3KVauQ pkzx3vhgHvN8M37M06k8tRVsQwAe+rGa2mDOBLVi6ot2ALemyZF7R2rPjXCKyR43mCVt ns3xkJodQymcMxPwGv39j78Fx7W0/FcQVPo7nOPZ3hd7F/DjbrfVjwXF6eOh/n8XkKxZ 5rww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=t6+wqBIi; 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 w14si7051647edf.402.2020.05.04.11.12.08; Mon, 04 May 2020 11:12:31 -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=t6+wqBIi; 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 S1732145AbgEDSH0 (ORCPT + 99 others); Mon, 4 May 2020 14:07:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:38140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732129AbgEDSHW (ORCPT ); Mon, 4 May 2020 14:07:22 -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 9EBE7205ED; Mon, 4 May 2020 18:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588615642; bh=1odbRtPdovn6YAvSWJSRCoNkGgKfG9Q4/MdEilrMUZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t6+wqBIiRfPqHnOOhdf+9n2SMR/s4/E+3D9cpIw0NyRF1oLh1SCzdFvuSryhsaqUY PgM6cYRH1+WXQrA3iWvxdczaJL4fuwCqsOVvj22C9mVnXXCB38fz+7vQ1dEE+bsZTJ lvQNgNoZDjCXO7IutLPnzIM+NtscWZH7INyt5db8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Takashi Iwai Subject: [PATCH 5.6 64/73] ALSA: opti9xx: shut up gcc-10 range warning Date: Mon, 4 May 2020 19:58:07 +0200 Message-Id: <20200504165510.054979600@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200504165501.781878940@linuxfoundation.org> References: <20200504165501.781878940@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 @@ -867,10 +867,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 @@ -317,10 +317,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,