From owner-svn-src-head@FreeBSD.ORG Sat May 25 18:11:20 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 816175F2; Sat, 25 May 2013 18:11:20 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-qe0-f43.google.com (mail-qe0-f43.google.com [209.85.128.43]) by mx1.freebsd.org (Postfix) with ESMTP id 129E8DCD; Sat, 25 May 2013 18:11:19 +0000 (UTC) Received: by mail-qe0-f43.google.com with SMTP id k5so3142156qej.16 for ; Sat, 25 May 2013 11:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=ZQrP8WL3cGyFNwGMOsmDDjNYz/ZrhS1K0PrK3oDcOW0=; b=FWdyJQINP5T2vt60ykaNqZ357DUv7c4J0LVPJ1zG4BE7W4tCGpszUOsKheDZ3uuCDN UVu7/sE88ZDR+L17w8BKKICzkiCtwWCWZEaK/W3qTCE5pqPtNpc/eGU8f8wIwPjtrZwb HIZ9P75HJn38VHEeEq8xVufy8dYknYt4IrV8OcRc4NRQy6gF8nzWb2EO8RaIOB1LXYJz IkH38+pHmebTS/K54sY1V8gBWJrQZFexQZqR0XHE1Mzyh0HVczQ7JO4QYoZXXz71qHYg VqCjqtuWny1XFFcDN00XA+SP5VTra39quBlNgQOD1zk3ROEtgqtwqCLTbkAKfmm4Byyr 2s4A== MIME-Version: 1.0 X-Received: by 10.224.60.73 with SMTP id o9mr20520949qah.90.1369505016799; Sat, 25 May 2013 11:03:36 -0700 (PDT) Sender: mdf356@gmail.com Received: by 10.229.142.11 with HTTP; Sat, 25 May 2013 11:03:36 -0700 (PDT) In-Reply-To: <201305251709.r4PH9xfv015285@svn.freebsd.org> References: <201305251709.r4PH9xfv015285@svn.freebsd.org> Date: Sat, 25 May 2013 11:03:36 -0700 X-Google-Sender-Auth: zTmcRdVZcR8EVeBKbm4pQ8eOeDI Message-ID: Subject: Re: svn commit: r250986 - head/sys/dev/usb From: mdf@FreeBSD.org To: Hans Petter Selasky Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 May 2013 18:11:20 -0000 On Sat, May 25, 2013 at 10:09 AM, Hans Petter Selasky wrote: > Author: hselasky > Date: Sat May 25 17:09:58 2013 > New Revision: 250986 > URL: http://svnweb.freebsd.org/changeset/base/250986 > > Log: > Fix some statical clang analyzer warnings. > > Modified: > head/sys/dev/usb/usb_device.c > head/sys/dev/usb/usb_hub.c > head/sys/dev/usb/usb_msctest.c > > Modified: head/sys/dev/usb/usb_device.c > > ============================================================================== > --- head/sys/dev/usb/usb_device.c Sat May 25 16:58:12 2013 > (r250985) > +++ head/sys/dev/usb/usb_device.c Sat May 25 17:09:58 2013 > (r250986) > @@ -799,9 +799,6 @@ usb_config_parse(struct usb_device *udev > /* find maximum number of endpoints */ > if (ep_max < temp) > ep_max = temp; > - > - /* optimalisation */ > - id = (struct usb_interface_descriptor *)ed; > } > } > > > Modified: head/sys/dev/usb/usb_hub.c > > ============================================================================== > --- head/sys/dev/usb/usb_hub.c Sat May 25 16:58:12 2013 (r250985) > +++ head/sys/dev/usb/usb_hub.c Sat May 25 17:09:58 2013 (r250986) > @@ -341,7 +341,6 @@ uhub_reattach_port(struct uhub_softc *sc > > DPRINTF("reattaching port %d\n", portno); > > - err = 0; > timeout = 0; > udev = sc->sc_udev; > child = usb_bus_port_get_device(udev->bus, > > Modified: head/sys/dev/usb/usb_msctest.c > > ============================================================================== > --- head/sys/dev/usb/usb_msctest.c Sat May 25 16:58:12 2013 > (r250985) > +++ head/sys/dev/usb/usb_msctest.c Sat May 25 17:09:58 2013 > (r250986) > @@ -802,7 +802,6 @@ usb_msc_eject(struct usb_device *udev, u > if (sc == NULL) > return (USB_ERR_INVAL); > > - err = 0; > switch (method) { > case MSC_EJECT_STOPUNIT: > err = bbb_command_start(sc, DIR_IN, 0, NULL, 0, > @@ -844,6 +843,7 @@ usb_msc_eject(struct usb_device *udev, u > break; > default: > DPRINTF("Unknown eject method (%d)\n", method); > + err = 0; > break; > } > DPRINTF("Eject CD command status: %s\n", usbd_errstr(err)); > I don't know about the top one, but the bottom two are the safer way to code, and should not have been changed. Unless we feel guaranteed the compiler can detect all uninitialized use and will break the build, an early initialization to a sane value is absolutely the right thing to do, even if it will be overwritten. If the compiler feels sure the initialization isn't needed, it does not have to emit the code. But any coding change after the (missing) initialization can create a bug now (well, it depends on how the code is structured, but from the three lines of context svn diff provides it's not clear a bug couldn't easily be introduced). Thanks, matthew