efopen.c

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Mon Oct 14 10:21:39 AEST 1985


> /* Open a file, aborting on failure */
> 
> /* Written by Bernie Roehl, June 1985 */
> 
> #include <stdio.h>
> #include <sys.h>
^^^^^ NONSTANDARD INCLUDE FILE ^^^^^
> 
> efopen(fn, mode)
^^^^^ WRONG RESULT TYPE; should be (FILE *) ^^^^^
> 	char *fn, *mode;
> 	{
> 	FILE *unit;
> 	if ((unit = fopen(fn, mode)) == NULL)
> 		error("Cannot open file %s", fn);
^^^^^ IMPLICITLY DECLARES error() AN (int)-VALUED FUNCTION ^^^^^
> 	else
> 		return unit;
> 	}
> 
> extern char *progname;
^^^^^ NONSTANDARD GLOBAL DATUM; this package should allocate it
				and provide a function to set it ^^^^^
> 
> error(s1, s2)
^^^^^ WRONG RESULT TYPE; should be (void) ^^^^^
^^^^^ INSUFFICIENTLY GENERAL TO BE GLOBAL; should be changed to
			use varargs or else be made file-static ^^^^^
> 	char *s1, *s2;
> 	{
> 	fprintf(stderr, "%s: ", progname);
> 	fprintf(stderr, s1, s2);
> 	exit(1);
^^^^^ IMPLICITLY DECLARES exit() AN (int)-VALUED FUNCTION ^^^^^
> 	}

Nice try, but no cigar.
Please, folks, de-lint your code before posting!



More information about the Comp.sources.bugs mailing list