Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1564796ybz; Thu, 30 Apr 2020 01:25:42 -0700 (PDT) X-Google-Smtp-Source: APiQypKprUutvyKD9Vso46FwAgsuoNi//LUeB++3g7OWk4d41cKKYChbPy2u02vmkpMMLO5R1g9o X-Received: by 2002:a05:6402:1d38:: with SMTP id dh24mr1651173edb.9.1588235142282; Thu, 30 Apr 2020 01:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588235142; cv=none; d=google.com; s=arc-20160816; b=sOu6U/kzOBOZU7VHeC3skQlUZx63Kx2tYv0KcPtLL722UyqUrvMGfDRBGRHajjV9un 1q6HE0+6oAX3VH9990uP6SLWnFSk3S/ijnLJzyQOhGV9FYXLzZnPA5vzW8/AUKsxGAuE zB0gVGWD3TVBbP0n5FeKnhau77SxTf8ns/5uqdwDBemc/k1w6lbk056AdC+TS+BbFudJ NBk1H9AyUPQoEfroXXGzL0wX38utN3Egu0Y/bdOjuEqaRfMVCtwyBmUACEFbNPlPJvpv CgsTnUPtqiwz1OR+/V3x/naYkfxDTr9vcji8MzmY9/cOyMJtmt49Osmx/qWyUo57FZRL upVg== 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=Go+pP6soksF7nqb2Gmv0JFrUuqYlZnZPYtRpSN0z+z0=; b=vCU7at+gZuDqjXZT0tgYx6BXC+1WGVS/wKubH7OAz28pRRQluM5dtOrCu3rOY1IDt7 6jp0nlG8Y6brWVrhdyFxSf9IMIHuqGaXRZjfMp5JWZyyOraGVlACVKW4mLnVzCoUjwoP 67eB5ErCoJBs7dSeMuDjPs/R68rH5hk3011qFOO75ug/U/eyNLicb4t2eGZT1km+j5xq NimYhkBysY8Wn5OC4ECvTmZU2d18hAg3y/IcRn8YcHOhe7Ek+5j905qqCUDVqlpYRfrP 4cm8stTb8mJK5mL5ljn9HxRzBHSKrm8BeQkfZ84bCWHjbxVUjSvesD+6lSG0ZX8cysj1 o+fA== 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 b26si4767513edw.447.2020.04.30.01.25.18; Thu, 30 Apr 2020 01:25:42 -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 S1726798AbgD3IWi (ORCPT + 99 others); Thu, 30 Apr 2020 04:22:38 -0400 Received: from mx2.suse.de ([195.135.220.15]:50096 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726412AbgD3IWh (ORCPT ); Thu, 30 Apr 2020 04:22:37 -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 73FCFABB2; Thu, 30 Apr 2020 08:22:34 +0000 (UTC) Date: Thu, 30 Apr 2020 10:22:34 +0200 Message-ID: From: Takashi Iwai To: Arnd Bergmann Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Takashi Iwai Subject: Re: [PATCH] ALSA: opti9xx: shut up gcc-10 range warning In-Reply-To: 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 Thu, 30 Apr 2020 08:12:07 +0200, Takashi Iwai wrote: > > 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. BTW, the lack of locking is no problem in this code. Those lines are called only at the initialization in the probe function, so can't race. thanks, Takashi