From owner-freebsd-bugs@FreeBSD.ORG Wed Apr 10 18:00:00 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B2F2E527 for ; Wed, 10 Apr 2013 18:00:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 9A002EAE for ; Wed, 10 Apr 2013 18:00:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r3AI001M087419 for ; Wed, 10 Apr 2013 18:00:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r3AI00XW087418; Wed, 10 Apr 2013 18:00:00 GMT (envelope-from gnats) Resent-Date: Wed, 10 Apr 2013 18:00:00 GMT Resent-Message-Id: <201304101800.r3AI00XW087418@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Luiz Otavio O Souza Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 16259339 for ; Wed, 10 Apr 2013 17:53:43 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id E9D6EE5E for ; Wed, 10 Apr 2013 17:53:42 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r3AHrdvm087811 for ; Wed, 10 Apr 2013 17:53:39 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id r3AHrdAg087810; Wed, 10 Apr 2013 17:53:39 GMT (envelope-from nobody) Message-Id: <201304101753.r3AHrdAg087810@red.freebsd.org> Date: Wed, 10 Apr 2013 17:53:39 GMT From: Luiz Otavio O Souza To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: kern/177759: [gpio] wrong check for unwanted flags X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Apr 2013 18:00:00 -0000 >Number: 177759 >Category: kern >Synopsis: [gpio] wrong check for unwanted flags >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Apr 10 18:00:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Luiz Otavio O Souza >Release: HEAD r247891 >Organization: >Environment: FreeBSD devel 10.0-CURRENT FreeBSD 10.0-CURRENT #7 r247891M: Wed Mar 6 10:16:45 BRT 2013 root@devel:/usr/obj/usr/src/sys/GENERIC amd64 >Description: clang warns about this badly written code (which got copied all over the tree): 11:47 <@dim> sys/arm/allwinner/a10_gpio.c:304:13: error: unsequenced modification and access to 'flags' [-Werror,-Wunsequenced] 11:47 <@dim> if ((flags &= sc->sc_gpio_pins[i].gp_caps) != flags) 11:47 <@dim> ^ ~~~~~ >How-To-Repeat: >Fix: Apply the attached patch. It changes the check to not modify the flags variable (which isn't really needed since the function will return if flags has any invalid bit set). Patch attached with submission follows: Index: arm/allwinner/a10_gpio.c =================================================================== --- arm/allwinner/a10_gpio.c (revision 248943) +++ arm/allwinner/a10_gpio.c (working copy) @@ -300,8 +300,8 @@ if (i >= sc->sc_gpio_npins) return (EINVAL); - /* Filter out unwanted flags. */ - if ((flags &= sc->sc_gpio_pins[i].gp_caps) != flags) + /* Check out for unwanted flags. */ + if ((flags & sc->sc_gpio_pins[i].gp_caps) != flags) return (EINVAL); /* Can't mix input/output together. */ Index: arm/broadcom/bcm2835/bcm2835_gpio.c =================================================================== --- arm/broadcom/bcm2835/bcm2835_gpio.c (revision 248943) +++ arm/broadcom/bcm2835/bcm2835_gpio.c (working copy) @@ -385,8 +385,8 @@ if (bcm_gpio_pin_is_ro(sc, pin)) return (EINVAL); - /* Filter out unwanted flags. */ - if ((flags &= sc->sc_gpio_pins[i].gp_caps) != flags) + /* Check out for unwanted flags. */ + if ((flags & sc->sc_gpio_pins[i].gp_caps) != flags) return (EINVAL); /* Can't mix input/output together. */ Index: arm/freescale/imx/imx51_gpio.c =================================================================== --- arm/freescale/imx/imx51_gpio.c (revision 248943) +++ arm/freescale/imx/imx51_gpio.c (working copy) @@ -261,8 +261,8 @@ if (i >= sc->gpio_npins) return (EINVAL); - /* Filter out unwanted flags */ - if ((flags &= sc->gpio_pins[i].gp_caps) != flags) + /* Check out for unwanted flags. */ + if ((flags & sc->gpio_pins[i].gp_caps) != flags) return (EINVAL); /* Can't mix input/output together */ Index: arm/xscale/ixp425/avila_gpio.c =================================================================== --- arm/xscale/ixp425/avila_gpio.c (revision 248943) +++ arm/xscale/ixp425/avila_gpio.c (working copy) @@ -220,8 +220,8 @@ if (pin >= IXP4XX_GPIO_PINS || !(sc->sc_valid & mask)) return (EINVAL); - /* Filter out unwanted flags */ - if ((flags &= sc->sc_pins[pin].gp_caps) != flags) + /* Check out for unwanted flags. */ + if ((flags & sc->sc_pins[pin].gp_caps) != flags) return (EINVAL); /* Can't mix input/output together */ Index: arm/xscale/ixp425/cambria_gpio.c =================================================================== --- arm/xscale/ixp425/cambria_gpio.c (revision 248943) +++ arm/xscale/ixp425/cambria_gpio.c (working copy) @@ -317,8 +317,8 @@ if (pin >= GPIO_PINS) return (EINVAL); - /* Filter out unwanted flags */ - if ((flags &= sc->sc_pins[pin].gp_caps) != flags) + /* Check out for unwanted flags. */ + if ((flags & sc->sc_pins[pin].gp_caps) != flags) return (EINVAL); /* Can't mix input/output together */ Index: mips/atheros/ar71xx_gpio.c =================================================================== --- mips/atheros/ar71xx_gpio.c (revision 248950) +++ mips/atheros/ar71xx_gpio.c (working copy) @@ -219,8 +219,8 @@ if (i >= sc->gpio_npins) return (EINVAL); - /* Filter out unwanted flags */ - if ((flags &= sc->gpio_pins[i].gp_caps) != flags) + /* Check out for unwanted flags. */ + if ((flags & sc->gpio_pins[i].gp_caps) != flags) return (EINVAL); /* Can't mix input/output together */ Index: mips/cavium/octeon_gpio.c =================================================================== --- mips/cavium/octeon_gpio.c (revision 248943) +++ mips/cavium/octeon_gpio.c (working copy) @@ -219,8 +219,8 @@ if (i >= sc->gpio_npins) return (EINVAL); - /* Filter out unwanted flags */ - if ((flags &= sc->gpio_pins[i].gp_caps) != flags) + /* Check out for unwanted flags. */ + if ((flags & sc->gpio_pins[i].gp_caps) != flags) return (EINVAL); /* Can't mix input/output together */ Index: mips/rt305x/rt305x_gpio.c =================================================================== --- mips/rt305x/rt305x_gpio.c (revision 248943) +++ mips/rt305x/rt305x_gpio.c (working copy) @@ -242,8 +242,8 @@ if (i >= sc->gpio_npins) return (EINVAL); - /* Filter out unwanted flags */ - if ((flags &= sc->gpio_pins[i].gp_caps) != flags) + /* Check out for unwanted flags. */ + if ((flags & sc->gpio_pins[i].gp_caps) != flags) return (EINVAL); /* Can't mix input/output together */ >Release-Note: >Audit-Trail: >Unformatted: