Re: RFC: Port of NetBSD cat(1)'s -f option.
Peter Pentchev <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.audit |
|---|---|
| Message-ID | <[email protected]> |
On Thu, May 16, 2002 at 05:40:01PM +1000, Bruce Evans wrote:
> On Thu, 16 May 2002, Giorgos Keramidas wrote:
[snip]
> > Sure, I've changed it to the following. Since this is a minor change,
> > I'll see that is gets done later tonight, if nobody objects 'til then.
> >
> > %%%
> > + if (stat(path, &st) < 0) {
> > + warn("%s", path);
> > + i++; /* Skip to next file. */
> > + continue;
> > + }
> > + if (S_ISREG(st.st_mode) == 0) {
> > + i++; /* Skip to next file. */
> > + continue;
> > + }
> > %%%
[snip]
> Style bugs:
> - nested declaration of st.
> - more verbose and bogus handling of the variable 'i'. 'i' is just the
> loop counter for a `for' loop that is obfuscated as a `while' loop.
Also, aren't we supposed to test the return values of syscalls explicitly
against -1, and not just < 0? At least that was the impression that
Ruslan gave me some time ago..
G'luck,
Peter
--
Peter Pentchev [email protected] [email protected]
PGP key: http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553
Nostalgia ain't what it used to be.
signature.asc
(application/pgp-signature, 187 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iD8DBQE844ys7Ri2jRYZRVMRArWxAKCpDS3wb5U1zAB1iiGVdA7vlYoN4QCfVpK7 jOoqby5+92LWuDNEaHalKw4= =q3r1 -----END PGP SIGNATURE-----