From owner-freebsd-hackers@FreeBSD.ORG Mon May 21 19:29:21 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C9631065693 for ; Mon, 21 May 2012 19:29:21 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from anubis.delphij.net (anubis.delphij.net [IPv6:2001:470:1:117::25]) by mx1.freebsd.org (Postfix) with ESMTP id 4D7D58FC1B for ; Mon, 21 May 2012 19:29:21 +0000 (UTC) Received: from delta.delphij.net (drawbridge.ixsystems.com [206.40.55.65]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by anubis.delphij.net (Postfix) with ESMTPSA id 9BDB7C656; Mon, 21 May 2012 12:29:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=delphij.net; s=anubis; t=1337628560; bh=BY++wY+MgJ+bh4eGjpgv+XutDZiFvy1ptlDzOmQ09Dk=; h=Date:From:Reply-To:To:CC:Subject:References:In-Reply-To; b=AM/JIQJrUgtL7vod+B0wfOi+MC2ZC1g5j3zR/lJb/ZQcFZ+MzKGnhIGs+fATtSIXP 2zsEXh+omTrFS+M9JQNJKDk9xCi+JkWESe+gCaFFkUMnEbrm5vNngn0sjFqiRkYMvO 6jH/SUjPRUN2QoUwAiiYCCPpez7J+800DlQUu68g= Message-ID: <4FBA978F.2030908@delphij.net> Date: Mon, 21 May 2012 12:29:19 -0700 From: Xin Li Organization: The FreeBSD Project MIME-Version: 1.0 To: Guy Helmer References: <4EE466CC-5F93-485C-8E1F-907F8049FD61@palisadesys.com> <4FB6D698.9030305@delphij.net> In-Reply-To: X-Enigmail-Version: 1.5pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org, d@delphij.net Subject: Re: Review of changes for getnetgrent.c X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2012 19:29:21 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 05/21/12 12:02, Guy Helmer wrote: > > On May 18, 2012, at 6:09 PM, Xin Li wrote: > >> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 >> >> On 05/18/12 14:58, Guy Helmer wrote: >>> To close PR bin/83340, I have this change worked up to resolve >>> memory allocation failure handling and avoid creating bad >>> entries in the grp list due to memory allocation failures while >>> building a new entry. >>> >>> Before committing, I wanted to run it past others to see if >>> there were any problems with it. >> >> %%% @@ -477,6 +475,13 @@ if (len > 0) { grp->ng_str[strpos] = >> (char *) malloc(len + 1); + if (grp->ng_str[strpos] == NULL) >> { + for (freepos = 0; freepos < strpos; freepos++) + >> if (grp->ng_str[freepos] != NULL) + >> free(grp->ng_str[freepos]); + free(grp); + >> return(1); + } bcopy(spos, grp->ng_str[strpos], len + 1); >> %%% > > Like this? > > if (len > 0) { grp->ng_str[strpos] = (char *) malloc(len + 1); + > if (grp->ng_str[strpos] == NULL) { + int freepos; + for > (freepos = 0; freepos < strpos; freepos++) + > free(grp->ng_str[freepos]); + free(grp); + return(1); + > } bcopy(spos, grp->ng_str[strpos], len + 1); } >> >> There are a few return without space between the keyword and >> return value. > > Do you recommend I fix all those instances in the file, or just the > instances in this patch? I'd recommend fixing them all (note that you could run into a bigger commit as the switch() is not style(9) conformant at this time) and we normally do it in two different commits (one style, and another functional) when possible. Cheers, - -- Xin LI https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQEcBAEBCAAGBQJPupePAAoJEG80Jeu8UPuz52wH/RVJXpCyea+ep08XDx82D7tG us+ujKa1aNOUumzwJRsJ4SNVBiyc+hqCtb8s7FjjeF4/SJk8oei/I1/M1JIyMuIh FawSB8rNJCbn/u9Od19iOeh/f/IDeCN+q8OrUK5mqQ7G1KDcHs12h86AFlm9HA7K 8UyxneTkPfKhED6hkgSll6bqYAJLeR5jJ3CCGvBeXxNgzJyyAhICWv0UgzUpcY9d l2beuIXc57toDaLrbWkooLfQclDWPWyyPXq7okexQAq8OUjqmQFE+EhcYsIbtBkH uBW67jhH81MZf/Ryl83VeqT9IChOySAU0YiwOQxaxdlqR53VAenAY0sWS1QvuX8= =drgy -----END PGP SIGNATURE-----