Subject: Re: Vi still can't remove its own vi-recover files from NFS /var/tmp
To: NetBSD-current Discussion List <current-users@NetBSD.org>
From: Greywolf <greywolf@starwolf.com>
List: netbsd-users
Date: 01/23/2004 13:46:30
Thus spake Greg A. Woods ("GAW> ") sometime Today...

GAW> Following the code path....
GAW>
GAW> 	if (fp->_file < 0 || fstat(fp->_file, &st) < 0) {
GAW>
GAW> [[...]]
GAW>
GAW> 	/* could be a tty iff it is a character device */
GAW> 	*couldbetty = S_ISCHR(st.st_mode);
GAW>
GAW> [[...]]
GAW>
GAW> 	if (couldbetty && isatty(fp->_file))

Disregarding that we're trying to compare a pointer with a value
(does it really say *couldbetty?), shouldn't that be rewritten as

	if (!(couldbetty || isatty(fp->_file)))

[AND-positive and NOR-negative aren't identical operations]

[Yes, I know that's not your code, Greg, so I'm not correcting your
statement. :-)]

GAW> (makebuf.c hasn't changed since 1999/09/20, so long before my first post)

The fix seems trivial...

				--*greywolf;
--
22 Ways to Get Yourself Killed While Watching 'The Lord Of The Rings':

#15: Start an Orc sing-a-long.