From owner-svn-src-all@FreeBSD.ORG Wed Dec 19 12:52:34 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D1FB2231; Wed, 19 Dec 2012 12:52:34 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail05.syd.optusnet.com.au (mail05.syd.optusnet.com.au [211.29.132.186]) by mx1.freebsd.org (Postfix) with ESMTP id 64BFC8FC12; Wed, 19 Dec 2012 12:52:33 +0000 (UTC) Received: from c122-106-175-26.carlnfd1.nsw.optusnet.com.au (c122-106-175-26.carlnfd1.nsw.optusnet.com.au [122.106.175.26]) by mail05.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id qBJCqJMb010893 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 19 Dec 2012 23:52:26 +1100 Date: Wed, 19 Dec 2012 23:52:19 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Gleb Smirnoff Subject: Re: svn commit: r244389 - head/sys/dev/wtap In-Reply-To: <20121218085306.GK94420@FreeBSD.org> Message-ID: <20121219234351.A1351@besplex.bde.org> References: <201212180844.qBI8ixdX097633@svn.freebsd.org> <20121218085306.GK94420@FreeBSD.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.0 cv=BrrFWvr5 c=1 sm=1 a=qoJ-q_1_yCsA:10 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=fu44smWAT9sA:10 a=iWf13sLgguKfD9NmPfEA:9 a=CjuIK1q_8ugA:10 a=bxQHXO5Py4tHmhUgaywp5w==:117 Cc: Monthadar Al Jaberi , svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Dec 2012 12:52:34 -0000 On Tue, 18 Dec 2012, Gleb Smirnoff wrote: > On Tue, Dec 18, 2012 at 08:44:59AM +0000, Monthadar Al Jaberi wrote: > ... > M> Modified: head/sys/dev/wtap/if_wtap.c > M> ============================================================================== > M> --- head/sys/dev/wtap/if_wtap.c Tue Dec 18 08:41:23 2012 (r244388) > M> +++ head/sys/dev/wtap/if_wtap.c Tue Dec 18 08:44:59 2012 (r244389) > M> @@ -334,6 +334,10 @@ wtap_vap_create(struct ieee80211com *ic, > M> vap = (struct ieee80211vap *) avp; > M> error = ieee80211_vap_setup(ic, vap, name, unit, IEEE80211_M_MBSS, > M> flags | IEEE80211_CLONE_NOBEACONS, bssid, mac); > M> + if (error) { > M> + free((struct wtap_vap*) vap, M_80211_VAP); > M> + return NULL; > M> + } > M> > M> /* override various methods */ > M> avp->av_recv_mgmt = vap->iv_recv_mgmt; > > You don't need to cast first argument of free(9). And you don't need a cast > before malloc(9) as well. A cast might be needed if free()'s arg is a point to constant storage. This is not the case here. > ... > Also, more stylish would be to supply to free() the same variable that was > assigned at malloc(9) call, in this particular case it is "avp". Another style bug is associated with this. free() does's take args of type struct wtap_vap*. Casting to that converts vap back to the type of avp, but not to either original type returned by malloc() or the type taken by free(). Also, in KNF: - casts are not followed by a space - '*' (in almost all contexts, including the above) is preceded by a space. Bruce