Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Aug 1999 13:20:28 -0500
From:      "Jeffrey J. Mountin" <jeff-ml@mountin.net>
To:        John Hay <jhay@mikom.csir.co.za>, obrien@FreeBSD.ORG
Cc:        cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG
Subject:   Re: cvs commit: src/bin/rm rm.1 rm.c
Message-ID:  <3.0.3.32.19990831132028.0155c100@207.227.119.2>
In-Reply-To: <199908291927.VAA37960@zibbi.mikom.csir.co.za>
References:  <19990829114222.B14701@dragon.nuxi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
At 09:27 PM 8/29/99 +0200, John Hay wrote:
>> > >   Reviewed by:	obrien
>> > 
>> > Either of you care to make any comments about this: (There is a second
>> > report of it as well)
>> 
>> Na.  I'd rather just fix it.
>>  
>
>This seems to fix it for me.
>
>John
>-- 
>John Hay -- John.Hay@mikom.csir.co.za
>
>Index: rm.c
>===================================================================
>RCS file: /home/ncvs/src/bin/rm/rm.c,v
>retrieving revision 1.22
>diff -u -r1.22 rm.c
>--- rm.c	1999/08/29 02:20:26	1.22
>+++ rm.c	1999/08/29 18:57:59
>@@ -235,7 +235,7 @@
> 			switch (p->fts_info) {
> 			case FTS_DP:
> 			case FTS_DNR:
>-				if ((e=rmdir(p->fts_accpath)) || (fflag && errno == ENOENT)) {
>+				if (!(e=rmdir(p->fts_accpath)) || (fflag && errno == ENOENT)) {
> 					if (e == 0 && vflag)
> 						(void)printf("%s\n", p->fts_accpath);
> 					continue;

Certainly don't care to start any style(9) wars here, but using '!' rather
than '== [NULL|'\0'] isn't as obvious when reviewing code.  Quite easy to
miss.

OTOH, using '!' is less typing and can be made more clear if a space were
using in front eg:

if ( !(e-rmdir(p->ftp_accpath))

This applies especially when there are several parenthesis in a complex
comparison.


I realize that using an explicit comparison adds a number of characters to
the code (recalling past discussions on bloating the size of the source)
and the increase in line lengths (to split or not to split).  This makes
sense of there is a space after the 'if' and elsewhere to increase clarity.


I'm a neophyte to C, but surely anyone can miss the '!' when doing a quick
review of code they are not initimate with.  Certainly seen enough code to
shudder at some practices, alibeit they are mostly located in the ports
collection.  Regardless it's not for me to judge, only suggest.

Now, is the 'e=' supposed to be 'e=='?

Must be -current code, so there might be a reason.


Jeff Mountin - jeff@mountin.net
Systems/Network Administrator
FreeBSD - the power to serve
'86 Yamaha MaxiumX (not FBSD powered)



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?3.0.3.32.19990831132028.0155c100>