From owner-freebsd-stable@FreeBSD.ORG Wed May 20 14:18:30 2009 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0537B1065698; Wed, 20 May 2009 14:18:30 +0000 (UTC) (envelope-from avg@freebsd.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id D13618FC2B; Wed, 20 May 2009 14:18:28 +0000 (UTC) (envelope-from avg@freebsd.org) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id RAA18094; Wed, 20 May 2009 17:18:27 +0300 (EEST) (envelope-from avg@freebsd.org) Message-ID: <4A141132.5010308@freebsd.org> Date: Wed, 20 May 2009 17:18:26 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.21 (X11/20090406) MIME-Version: 1.0 To: John Baldwin References: <4A1165A0.6000800@icyb.net.ua> <4A1167A2.6040407@freebsd.org> <4A13F30A.2090401@freebsd.org> <200905200832.00771.jhb@freebsd.org> In-Reply-To: <200905200832.00771.jhb@freebsd.org> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: freebsd-stable@freebsd.org, Chagin Dmitry Subject: Re: stack abuse by linux_ioctl_cdrom X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 14:18:30 -0000 on 20/05/2009 15:32 John Baldwin said the following: > On Wednesday 20 May 2009 8:09:46 am Andriy Gapon wrote: >> This is a patch that I currently use to fix the problem for myself - both 2KB >> structs are allocated on the heap. >> I am not sure what is the proper style for chained calls using chained if-else, >> but I think that the chaining is the best way to organize that piece of code, so >> that there is only one exit point from case-block to make sure that FREE is always >> called. > > I usually use goto for that. Error handling does seem to be one of the few > appropriate uses of goto. In this case you would basically be replacing all > the 'break's with 'goto out' or some such. Also, please do not use the MALLOC() > or FREE() macros in new code as they are deprecated (I think they are completely > removed in 8). I used MALLOC/FREE only because I saw that this is what was used in that file before. I will fix this. I was reluctant to use goto and label within a case block. In my personal taste that looks uglier and less safe (e.g. accidental goto from another case or from outside of switch). I would preferred goto if label was outside of switch/case. But maybe it's my personal prejudice. I will follow the style that you will recommend. -- Andriy Gapon