Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 07 Mar 2002 13:47:42 +0200
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        Mark Murray <mark@grondar.za>
Cc:        obrien@FreeBSD.org, Mark Murray <markm@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/usr.bin/rwall rwall.c
Message-ID:  <3C87535E.142B01AF@FreeBSD.org>
References:  <20020307030244.B63484@dragon.nuxi.com> <200203071127.g27BR2RV009394@grimreaper.grondar.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

You missed the point - fd should be checked (!=0) before it is
supplied to fdopen(), not after. Otherwise fdopen() might blow out.

-Maxim

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C87535E.142B01AF>