From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benoit Parrot Subject: Re: [PATCH v2 5/7] media: use the BIT() macro Date: Fri, 23 Aug 2019 07:12:05 -0500 Message-ID: <20190823121204.ze4m6m3dxevjpjp6@ti.com> References: <20190823000829.GN5027@pendragon.ideasonboard.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" To: Mauro Carvalho Chehab Cc: Kate Stewart , Richard Fontana , "Lad, Prabhakar" , Thierry Reding , Bluecherry Maintainers , Laurent Pinchart , Sylwester Nawrocki , devel@driverdev.osuosl.org, Krzysztof Kozlowski , Michal Simek , Andrey Utkin , Jonathan Hunter , Kukjin Kim , linux-arm-kernel@lists.infradead.org, Ismael Luceno , Linux Media Mailing List , Mauro Carvalho Chehab , linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, Thomas Gleixner , Anton Sviridenko List-Id: linux-tegra@vger.kernel.org Mauro Carvalho Chehab wrote on Fri [2019-Aug-23 06:47:30 -0300]: > As warned by cppcheck: > > [drivers/media/dvb-frontends/cx24123.c:434]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > [drivers/media/pci/bt8xx/bttv-input.c:87]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > [drivers/media/pci/bt8xx/bttv-input.c:98]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > ... > [drivers/media/v4l2-core/v4l2-ioctl.c:1391]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > > There are lots of places where we're doing 1 << 31. That's bad, > as, depending on the architecture, this has an undefined behavior. > > The BIT() macro is already prepared to handle this, so, let's > just switch all "1 << number" macros by BIT(number) at the header files > with has 1 << 31. > > Signed-off-by: Mauro Carvalho Chehab > --- > > v2: > As suggested by Laurent: > - Don't touch multi-bit masks > - remove explicit casts > For: drivers/media/platform/am437x/am437x-vpfe_regs.h drivers/media/platform/ti-vpe/vpe_regs.h Reviewed-by: Benoit Parrot 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=-5.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 57CD7C41514 for ; Fri, 23 Aug 2019 12:11:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D5CF233FD for ; Fri, 23 Aug 2019 12:11:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="UQHxIVwQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405320AbfHWMLK (ORCPT ); Fri, 23 Aug 2019 08:11:10 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:52614 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403942AbfHWMLK (ORCPT ); Fri, 23 Aug 2019 08:11:10 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x7NCA7of063660; Fri, 23 Aug 2019 07:10:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1566562207; bh=33v/B/ZJqA3blXO/RNp5dWHGOqZq1+rFXfXmdj5+Gds=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=UQHxIVwQKzurgl2CECBwOQG7NM1InTkeNUfGSo/z0TGdBNxqcoKLm7TPWzmreURv2 QDPOdOE1YT846Id7C3NGPUwpbZ01PtnlpDOo30p5Jhddm/jo1TBUJbLSuAK5dvwGkH zOsfD1LRRPAdR6lP8Rx08uphXBi3hStfy8W2L+k0= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x7NCA7r7088500 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 23 Aug 2019 07:10:07 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 23 Aug 2019 07:10:07 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Fri, 23 Aug 2019 07:10:07 -0500 Received: from ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with SMTP id x7NCA6x4092204; Fri, 23 Aug 2019 07:10:07 -0500 Date: Fri, 23 Aug 2019 07:12:05 -0500 From: Benoit Parrot To: Mauro Carvalho Chehab CC: Linux Media Mailing List , Mauro Carvalho Chehab , Hans Verkuil , Andy Walls , Bluecherry Maintainers , Anton Sviridenko , Andrey Utkin , Ismael Luceno , "Lad, Prabhakar" , Kyungmin Park , Sylwester Nawrocki , Kukjin Kim , Krzysztof Kozlowski , Laurent Pinchart , Thierry Reding , Jonathan Hunter , Kieran Bingham , Hyun Kwon , Michal Simek , Sakari Ailus , Greg Kroah-Hartman , Richard Fontana , Kate Stewart , Allison Randal , Thomas Gleixner , , , , , Subject: Re: [PATCH v2 5/7] media: use the BIT() macro Message-ID: <20190823121204.ze4m6m3dxevjpjp6@ti.com> References: <20190823000829.GN5027@pendragon.ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Mauro Carvalho Chehab wrote on Fri [2019-Aug-23 06:47:30 -0300]: > As warned by cppcheck: > > [drivers/media/dvb-frontends/cx24123.c:434]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > [drivers/media/pci/bt8xx/bttv-input.c:87]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > [drivers/media/pci/bt8xx/bttv-input.c:98]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > ... > [drivers/media/v4l2-core/v4l2-ioctl.c:1391]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > > There are lots of places where we're doing 1 << 31. That's bad, > as, depending on the architecture, this has an undefined behavior. > > The BIT() macro is already prepared to handle this, so, let's > just switch all "1 << number" macros by BIT(number) at the header files > with has 1 << 31. > > Signed-off-by: Mauro Carvalho Chehab > --- > > v2: > As suggested by Laurent: > - Don't touch multi-bit masks > - remove explicit casts > For: drivers/media/platform/am437x/am437x-vpfe_regs.h drivers/media/platform/ti-vpe/vpe_regs.h Reviewed-by: Benoit Parrot 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=-5.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 28F07C3A5A3 for ; Fri, 23 Aug 2019 12:10:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F189821897 for ; Fri, 23 Aug 2019 12:10:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="K3DfT5vw"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ti.com header.i=@ti.com header.b="UQHxIVwQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F189821897 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4XAGqy8jhw/7xJ7Zhpx4fwWlos+mhKq2ndX63QWYXkc=; b=K3DfT5vwtF9IfH GZr7QKhp3SLswcYAx9VBW6larm0pvkMNlcOh2z818Q8P6PVrD8MG1MbhQB1TrGdgWshHdG/B8oF/X TkTzgc4Sz3AkO6a/XGB8LoBKaYe9YwYTUwgoFTQD7chsutHAXmJIYsjE1ia30rP0/snQRHFJsjWov R+MNOLEzGu9s6T35lJfClZdaYx3sDpGN3UUv8B1ggNo8lrMaFruCboDG6hViFBuKf05aZO8G2fP5K H/MxGC4N3l4lb5P10rQpDOV3TOylAYSHyPSsNw1nUsyjQkv7tMZcNNfzeKpR+YkxMIBEGEMVMrrHQ SHQIveH7nTyF6ySltciw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i18P9-0002KJ-Ko; Fri, 23 Aug 2019 12:10:55 +0000 Received: from lelv0143.ext.ti.com ([198.47.23.248]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i18P7-0002J0-BY for linux-arm-kernel@lists.infradead.org; Fri, 23 Aug 2019 12:10:54 +0000 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x7NCA7of063660; Fri, 23 Aug 2019 07:10:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1566562207; bh=33v/B/ZJqA3blXO/RNp5dWHGOqZq1+rFXfXmdj5+Gds=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=UQHxIVwQKzurgl2CECBwOQG7NM1InTkeNUfGSo/z0TGdBNxqcoKLm7TPWzmreURv2 QDPOdOE1YT846Id7C3NGPUwpbZ01PtnlpDOo30p5Jhddm/jo1TBUJbLSuAK5dvwGkH zOsfD1LRRPAdR6lP8Rx08uphXBi3hStfy8W2L+k0= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x7NCA7r7088500 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 23 Aug 2019 07:10:07 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 23 Aug 2019 07:10:07 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Fri, 23 Aug 2019 07:10:07 -0500 Received: from ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with SMTP id x7NCA6x4092204; Fri, 23 Aug 2019 07:10:07 -0500 Date: Fri, 23 Aug 2019 07:12:05 -0500 From: Benoit Parrot To: Mauro Carvalho Chehab Subject: Re: [PATCH v2 5/7] media: use the BIT() macro Message-ID: <20190823121204.ze4m6m3dxevjpjp6@ti.com> References: <20190823000829.GN5027@pendragon.ideasonboard.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190823_051053_481233_0E7C966E X-CRM114-Status: GOOD ( 11.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kate Stewart , Richard Fontana , "Lad, Prabhakar" , Thierry Reding , Bluecherry Maintainers , Laurent Pinchart , Sylwester Nawrocki , devel@driverdev.osuosl.org, Krzysztof Kozlowski , Michal Simek , Andrey Utkin , Jonathan Hunter , Kukjin Kim , linux-arm-kernel@lists.infradead.org, Ismael Luceno , Linux Media Mailing List , Mauro Carvalho Chehab , linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, Thomas Gleixner , Anton Sviridenko , Allison Randal , Andy Walls , Hyun Kwon , Greg Kroah-Hartman , linux-renesas-soc@vger.kernel.org, Kyungmin Park , Kieran Bingham , Sakari Ailus , Hans Verkuil Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Mauro Carvalho Chehab wrote on Fri [2019-Aug-23 06:47:30 -0300]: > As warned by cppcheck: > > [drivers/media/dvb-frontends/cx24123.c:434]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > [drivers/media/pci/bt8xx/bttv-input.c:87]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > [drivers/media/pci/bt8xx/bttv-input.c:98]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > ... > [drivers/media/v4l2-core/v4l2-ioctl.c:1391]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour > > There are lots of places where we're doing 1 << 31. That's bad, > as, depending on the architecture, this has an undefined behavior. > > The BIT() macro is already prepared to handle this, so, let's > just switch all "1 << number" macros by BIT(number) at the header files > with has 1 << 31. > > Signed-off-by: Mauro Carvalho Chehab > --- > > v2: > As suggested by Laurent: > - Don't touch multi-bit masks > - remove explicit casts > For: drivers/media/platform/am437x/am437x-vpfe_regs.h drivers/media/platform/ti-vpe/vpe_regs.h Reviewed-by: Benoit Parrot _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel