Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1468013ybz; Wed, 29 Apr 2020 23:15:18 -0700 (PDT) X-Google-Smtp-Source: APiQypJq3+CjwDv0swTbJ14aYKiYw1DWO4wVeoxDqqbfzq6l0HRqmpG8OFGXvpt4R7K/X76MqLyq X-Received: by 2002:a17:906:7f01:: with SMTP id d1mr1216827ejr.49.1588227318066; Wed, 29 Apr 2020 23:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588227318; cv=none; d=google.com; s=arc-20160816; b=hXJdtdcwuHSW82iL0V1gud+8mrCGj0WK5RNtOVnPFzNgvhezTl+4HT1DY3EaW1C9OP qPnfxP+3YsggTxvraK/QiJPeuo60JrIpREv2W0J/h8G6FqDo4WOnBFb/yZR/rnja3S7E QKBABiHwyX80DAnaYDeif9T+SucOLvbpXLVOYCov1oT0TdlwrZx9d2Y6YgITJRWNrEnU ZOEkiUCyxYw5bXQNy6u2AB5MzHJ3vlXxhzYQCfPoAVFEEP0MZYfDEDaI0zxQtfDXIU2V MRoQBdEdV2l2DjFgO1lpgjxwXtFQL3F9ModZTPHVRf7+yDUf8OxuKTRecjk6opMdI8r7 HFxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date; bh=xLuBzQcK551Ph3GGeD5IarP5xEy6FLce+tbc/PBcLLs=; b=0oCpcG7pHRFYvyJAxvt+cj3z8njGGDoKfUORURMb2h0M3pAICFy8TEvk0+/W2TSl1v C9FbLgt+3HFnfF9KnwCBm2V6xyabuoYVBjSj+uOEsVYVpINAT2AYP94SZB4b6esUGusP IIY9kyEP8H8AplHujpZd3qcgfL/9fty78QPWAuUJdT7ML1QnH16ifqTrfce2FyeeaneQ yixsHw30unq+MTuEHe4SHj9l1Yoi38HK+leYUlzFycKAxcRkTPQpFhxgd7+GgUgURiRg 0HAvlrTPDUw7X4T3JYlm59UishGXL5NPKFLTYn6Oh6J7XHIX7FB+vL3Vcyo2JpGexwBC WCcA== ARC-Authentication-Results: i=1; mx.google.com; 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 fi25si5316094ejb.25.2020.04.29.23.14.54; Wed, 29 Apr 2020 23:15:18 -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; 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 S1726511AbgD3GMK (ORCPT + 99 others); Thu, 30 Apr 2020 02:12:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:51532 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726180AbgD3GMJ (ORCPT ); Thu, 30 Apr 2020 02:12:09 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 880C3AC58; Thu, 30 Apr 2020 06:12:07 +0000 (UTC) Date: Thu, 30 Apr 2020 08:12:07 +0200 Message-ID: From: Takashi Iwai To: Arnd Bergmann Cc: Jaroslav Kysela , Takashi Iwai , , Subject: Re: [PATCH] ALSA: opti9xx: shut up gcc-10 range warning In-Reply-To: <20200429190216.85919-1-arnd@arndb.de> References: <20200429190216.85919-1-arnd@arndb.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 Apr 2020 21:02:03 +0200, Arnd Bergmann wrote: > > 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 Applied now, thanks. Takashi