Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/17/84; site elsie.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!zehntel!hplabs!hao!seismo!umcp-cs!cvl!elsie!ado
From: ado@elsie.UUCP (Arthur David Olson)
Newsgroups: net.unix-wizards,net.lang.c
Subject: Re: lint enhancement for 4.?bsd (and others?)
Message-ID: <3@elsie.UUCP>
Date: Sun, 23-Sep-84 16:44:26 EDT
Article-I.D.: elsie.3
Posted: Sun Sep 23 16:44:26 1984
Date-Received: Wed, 26-Sep-84 08:07:53 EDT
References: <1260@elsie.UUCP>
Organization: NIH-LEC, Bethesda, MD
Lines: 51

Another odd lint lapse, shown up by "xfopen" in the 2.10.2 news software:

> FILE *
> xfopen(name, fmode)
> register char *name, *fmode;
> {
> 	register FILE *fp;
> 	.
> 	.
> 	.
> 	if ((fp = fopen(name, fmode)) == NULL) {
> 	.
> 	.
> 	.
> 	}
> 	/* kludge for setuid not being honored for root */
> 	if ((uid == 0) && (duid != 0) && ((fmode == "a") || (fmode == "w")))
> 		chown(name, duid, dgid);
> 	return(fp);
> }

Since YOU can find the bug in the above code by inspection, so can lint.
Adding the check to the other checks added yesterday, we have:

> ed lint.c
> /case LE:/a
> #ifndef OLDVERSION
> 		if (p->in.right->in.op == ICON &&
> 			p->in.right->tn.type == (PTR | CHAR) &&
> 			p->in.right->tn.rval < 0)
> 				werror("comparison with doubly-quoted string");
> 		else if (p->in.left->in.op == ICON &&
> 			p->in.right->in.op == ICON)
> 				werror("comparison of constants");
> 		else if (p->in.op != EQ && p->in.op != NE)
> 			if (ISPTR(p->in.left->in.type) &&
> 			    ISFTN(DECREF(p->in.left->in.type)) ||
> 			    ISPTR(p->in.right->in.type) &&
> 			    ISFTN(DECREF(p->in.right->in.type))	)
> 				werror("function address in comparison");
> #endif
> .
> w
> q

I trust some more knowing person will set things aright if this is worng.
--
UNIX is at AT&T Bell Laboratories trademark.
--
	...decvax!seismo!umcp-cs!elsie!ado	(301) 496-5688
	(DEC, VAX and Elsie are Digital Equipment Corp. and Borden's trademarks)