Subject: bin/8328: lint cannot handle more than one .c file
To: None <gnats-bugs@gnats.netbsd.org>
From: None <Anders.Hjalmarsson@economics.gu.se>
List: netbsd-bugs
Date: 09/05/1999 16:21:22
>Number:         8328
>Category:       bin
>Synopsis:       lint cannot handle more than one .c file
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Sep  5 16:20:01 1999
>Last-Modified:
>Originator:     Anders Hjalmarsson
>Organization:
>Release:        NetBSD-current 19990903
>Environment:
System: NetBSD econahja.econ.gu.se 1.4K NetBSD 1.4K (ECONAHJA) #167: Sun Sep 5 11:01:02 CEST 1999 econahja@econahja.econ.gu.se:/usr/src/sys/arch/i386/compile/ECONAHJA i386


>Description:
	lint cannot handle more than one .c file.
	The second and following .c files are run through cpp with
	output going to stdout, because the cpp output file is closed
	after the first file. lint reuses the preprocessed output of
	the first file for the following files.
>How-To-Repeat:
	lint a.c b.c
>Fix:

Patch for /usr/src/usr.bin/xlint/xlint/xlint.c 1.13

--- xlint.c.old	Mon Sep  6 00:45:42 1999
+++ xlint.c	Mon Sep  6 00:38:13 1999
@@ -541,6 +541,15 @@
 	int is_stdin;
 	int	fd;
 
+	if (lseek(cppoutfd, SEEK_SET, (off_t)0) != 0) {
+		warn("lseek");
+		terminate(-1);
+	}
+	if (ftruncate(cppoutfd, (off_t)0) != 0) {
+		warn("ftruncate");
+		terminate(-1);
+	}
+
 	is_stdin = (strcmp(name, "-") == 0);
 	bn = basename(name, '/');
 	suff = basename(bn, '.');
@@ -604,8 +613,6 @@
 	runchild(path, args, cppout, cppoutfd);
 	free(path);
 	freelst(&args);
-	if (cppoutfd != -1)
-		(void)close(cppoutfd);
 
 	/* run lint1 */
 
>Audit-Trail:
>Unformatted: