From owner-svn-src-head@FreeBSD.ORG Fri Oct 24 06:59:37 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 26970464; Fri, 24 Oct 2014 06:59:37 +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 60451CF; Fri, 24 Oct 2014 06:59:36 +0000 (UTC) Received: by mail-wi0-f181.google.com with SMTP id n3so466657wiv.8 for ; Thu, 23 Oct 2014 23:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=GvRd4uRzKNVj1sDS+uteuC9QbBhzjlQynKPPTOvDti0=; b=nYJt7vbRLykSWBZRB1oM4iTSCxSHorpBEhhABR41y5hNIdFQVy+SETatsH05BpdxXG 2I3jkPiTWHIN9MmXT0L4vR8jJ8D8KrrOtwSirdmD1UWVuz9VY3mdkd/VpndLyA7BIPGs KiotisVL86QLH7fxCs/9YRz7TYXRjreSjtAuVWoP6bD0aMJRdY2loYIeRHTsDSr7r1YV hDjDyrc0ucRXjguBDWMIcizF0wKq5LB1/E7Ulc26Fbzz4aEmqBnWi4DRime5a3gmhOdi zunohGM7PPrrLX4uYEoK2f9FEbLYKh7pLWBaljB+5JuacB5asY0Wsax5EzXVu3m9f9bI NUPA== MIME-Version: 1.0 X-Received: by 10.194.157.137 with SMTP id wm9mr2634213wjb.5.1414133974707; Thu, 23 Oct 2014 23:59:34 -0700 (PDT) Received: by 10.216.159.193 with HTTP; Thu, 23 Oct 2014 23:59:34 -0700 (PDT) Reply-To: araujo@FreeBSD.org In-Reply-To: <20141024055820.GI11222@dft-labs.eu> References: <201410240539.s9O5dWWK002150@svn.freebsd.org> <20141024055820.GI11222@dft-labs.eu> Date: Fri, 24 Oct 2014 14:59:34 +0800 Message-ID: Subject: Re: svn commit: r273576 - head/sys/dev/uart From: Marcelo Araujo To: Mateusz Guzik Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 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 06:59:37 -0000 2014-10-24 13:58 GMT+08:00 Mateusz Guzik : > 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. > Well, it might be possible to use 'char *cp', however as I'm not aware of all uart implementation, I just followed the previous 'spec' declaration type that is a constant too. I'm gonna take a look on it, to check if there is any backward to only use 'char *cp'. > > There are some cosmetics around that may be worth fixing (e.g. if, > else-if instead of switch, while (1) instead of for (;;)). > Yes, that for sure makes sense and it is worth. Thanks to point all of these things. Best Regards, -- -- Marcelo Araujo (__)araujo@FreeBSD.org \\\'',)http://www.FreeBSD.org \/ \ ^ Power To Server. .\. /_)