From owner-cvs-all Thu Mar 7 4:11:14 2002 Delivered-To: cvs-all@freebsd.org Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.139.170]) by hub.freebsd.org (Postfix) with ESMTP id 8AE2437B41D; Thu, 7 Mar 2002 04:10:54 -0800 (PST) Received: (from uucp@localhost) by storm.FreeBSD.org.uk (8.11.6/8.11.6) with UUCP id g27CArA52227; Thu, 7 Mar 2002 12:10:53 GMT (envelope-from mark@grimreaper.grondar.za) Received: from grimreaper (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.2/8.12.2) with ESMTP id g27CA8RV010023; Thu, 7 Mar 2002 12:10:08 GMT (envelope-from mark@grimreaper.grondar.za) Message-Id: <200203071210.g27CA8RV010023@grimreaper.grondar.org> To: obrien@FreeBSD.org Cc: Mark Murray , Mark Murray , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.bin/rwall rwall.c References: <20020307033328.A64158@dragon.nuxi.com> In-Reply-To: <20020307033328.A64158@dragon.nuxi.com> ; from "David O'Brien" "Thu, 07 Mar 2002 03:33:28 PST." Date: Thu, 07 Mar 2002 12:10:08 +0000 From: Mark Murray Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > On Thu, Mar 07, 2002 at 11:27:02AM +0000, Mark Murray wrote: > > > - if ((fd = mkstemp(tmpname)) == -1 || !(fp = fdopen(fd, "r+"))) > > > + fd = mkstemp(tmpname); > > > + fp = fdopen(fd, "r+"); > > > + if (fd == -1 || !fp) > > > > > > Why did you need to do such code restructuring? > > > > "Assignment statement in conditional". I also happens to be more readable. > > Feh. Please back this type of changes out. The logic is not the same > before and after. Here is the clearer fix: @@ -137,8 +136,10 @@ snprintf(tmpname, sizeof(tmpname), "%s/wall.XXXXXX", _PATH_TMP); fd = mkstemp(tmpname); - fp = fdopen(fd, "r+"); - if (fd == -1 || !fp) + fp = NULL; + if (fd != -1) + fp = fdopen(fd, "r+"); + if (fp == NULL) err(1, "can't open temporary file"); unlink(tmpname); M -- o Mark Murray \_ O.\_ Warning: this .sig is umop ap!sdn To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message