proposed changes to eliminate P macro

Ken Pizzini tz_ at explicate.org
Wed Nov 14 02:10:51 UTC 2007


I just noticed a bug in my previous patch: my test-run compiling
logwtmp.c failed to notice that I botched the strncpy() prototype,
because my <utmp.h> file defines the OLD_TIME macro which bypasses
the branch of the source code where logwtmp() is defined.

Below is a better fix for this: #include the relevant system headers
which declare these functions, rather than inserting the prototypes
explicitly in the code.  I've also cleaned up the function declaration
for logwtmp() itself while I was at it.

		--Ken Pizzini



diff -ru tzcode2007-cleancast/logwtmp.c tzcode2007-foo/logwtmp.c
--- tzcode2007-cleancast/logwtmp.c	2007-11-13 15:08:32.000000000 -0800
+++ tzcode2007-foo/logwtmp.c	2007-11-13 17:52:54.000000000 -0800
@@ -39,20 +39,20 @@
 
 #ifndef OLD_TIME
 
+#include <string.h>
+#include <time.h>
 #include <sys/file.h>
 #include <sys/time.h>
 #include <sys/stat.h>
 
 #define WTMPFILE	"/usr/adm/wtmp"
 
-logwtmp(line, name, host)
-	char *line, *name, *host;
+void
+logwtmp(const char *line, const char *name, const char *host)
 {
 	struct utmp ut;
 	struct stat buf;
 	int fd;
-	time_t time(time_t *);
-	char *strncpy(char *, const char *);
 
 	if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0)
 		return;
diff -ru tzcode2007-cleancast/date.c tzcode2007-foo/date.c
--- tzcode2007-cleancast/date.c	2007-11-13 17:26:02.000000000 -0800
+++ tzcode2007-foo/date.c	2007-11-13 17:53:29.000000000 -0800
@@ -440,7 +440,7 @@
 #define TSPTYPES
 #include <protocols/timed.h>
 
-extern int		logwtmp();
+extern void	logwtmp(const char *line, const char *name, const char *host);
 
 #if HAVE_SETTIMEOFDAY == 1
 #define settimeofday(t, tz) (settimeofday)(t)




More information about the tz mailing list