From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D4D6C83001 for ; Thu, 30 Apr 2020 06:12:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 117E62173E for ; Thu, 30 Apr 2020 06:12:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726535AbgD3GMK (ORCPT ); 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