From owner-svn-src-head@FreeBSD.ORG Fri Oct 24 05:58:26 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 71E293D5; Fri, 24 Oct 2014 05:58:26 +0000 (UTC) Received: from mail-wi0-x235.google.com (mail-wi0-x235.google.com [IPv6:2a00:1450:400c:c05::235]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 928D5B1C; Fri, 24 Oct 2014 05:58:25 +0000 (UTC) Received: by mail-wi0-f181.google.com with SMTP id n3so361943wiv.14 for ; Thu, 23 Oct 2014 22:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=sYr2SRa/Bolm+OozhGB3tM0eX7Amlyr9vL6FhS5Rc04=; b=iUp0GTZLPY2aeXc5X4YqJok2o43ArV0EIDlqOS95gBEKwGVNXAFmmp8Ypmm6nypKr+ 9a/XNpRGRwyKpGp3nHocRTYU7CEP8BTPvCypJ3pYbERRHniJfkBmB/6vly3zICFnKMye Ar2vBxko7E+/fS1lLz7VKBCoQHKGv0h1UqxtXnnyWY7DapEN1ORQjWNPM4PKAbtyjj5B PUItDaphJyBJDrE9JYbwp7/hSbhMwyjkQLx55l8b2eru1KvzolO9IBJ2/lMKMVsV3Rgl Cmm8syraUWvhOgfwOqtshXSF6DpmoMwaHkpF2OoFphkZ3KWXCXsNuLwjOtD3fgPfnDPV PqQg== X-Received: by 10.180.72.243 with SMTP id g19mr1761433wiv.64.1414130303862; Thu, 23 Oct 2014 22:58:23 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id fx2sm4405222wjb.37.2014.10.23.22.58.22 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 23 Oct 2014 22:58:23 -0700 (PDT) Date: Fri, 24 Oct 2014 07:58:20 +0200 From: Mateusz Guzik To: Marcelo Araujo Subject: Re: svn commit: r273576 - head/sys/dev/uart Message-ID: <20141024055820.GI11222@dft-labs.eu> References: <201410240539.s9O5dWWK002150@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201410240539.s9O5dWWK002150@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) 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.18-1 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: Fri, 24 Oct 2014 05:58:26 -0000 On Fri, Oct 24, 2014 at 05:39:32AM +0000, Marcelo Araujo wrote: > Author: araujo (ports committer) > Date: Fri Oct 24 05:39:32 2014 > New Revision: 273576 > URL: https://svnweb.freebsd.org/changeset/base/273576 > > Log: > Fix a leaked Storage Variable. > > int > uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class) > { > - const char *spec; > + const char *cp, *spec; > bus_addr_t addr = ~0U; > int error; > > @@ -214,12 +214,12 @@ uart_getenv(int devtype, struct uart_dev > * port (resp). > */ > if (devtype == UART_DEV_CONSOLE) > - spec = kern_getenv("hw.uart.console"); > + cp = kern_getenv("hw.uart.console"); > else if (devtype == UART_DEV_DBGPORT) > - spec = kern_getenv("hw.uart.dbgport"); > + cp = kern_getenv("hw.uart.dbgport"); > else > - spec = NULL; > - if (spec == NULL) > + cp = NULL; > + if (cp == NULL) > return (ENXIO); [..] > default: > + freeenv(__DECONST(char *, cp)); > return (EINVAL); > } > if (*spec == '\0') > break; > - if (*spec != ',') > + if (*spec != ',') { > + freeenv(__DECONST(char *, cp)); > return (EINVAL); > + } > spec++; > } > + freeenv(__DECONST(char *, cp)); > Why not 'char *cp;'? That would avoid __DECONST entirely and would not require spec to change type. There are some cosmetics around that may be worth fixing (e.g. if, else-if instead of switch, while (1) instead of for (;;)). -- Mateusz Guzik