Subject: utime(3) related warnings

From: Michail Vidiassov <[email-masked]>
Date: Tue, 9 Dec 2003 17:08:57 +0300 (MSK)

Dear All,

while compiling in a custom patch for pine 4.58 on FreeBSD 4.9,
I have turned on warnings and noticed, that
1) utime function remains undeclared
2) when necessary files are included, compiler warns about
 passing arg 2 of `utime' from incompatible pointer type

It seems to be caused by treating utime(3) according to
the following declaration:

       #include <sys/types.h>

       utime(file, timep)
       char *file;
       time_t timep[2];

and not the modern (POSIX) one

       #include <sys/types.h>
       #include <utime.h>

       int utime(const char *filename, struct utimbuf *buf);

While the methods seem to be binary compatible (it was a warning message
only), why not to clean up the code a bit?

                           Sincerely, Michail

--- pico/osdep/os-bsf.h.orig	Tue Dec  9 15:43:58 2003
+++ pico/osdep/os-bsf.h	Tue Dec  9 15:42:33 2003
@@ -35,6 +35,9 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <netdb.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <utime.h>

--- pine/adrbklib.c.orig	Tue Nov  4 21:36:26 2003
+++ pine/adrbklib.c	Tue Nov  4 21:40:31 2003
@@ -939,7 +939,7 @@
     /* copy ab->filename to ab->our_filecopy, preserving mtime */
     if(ab->filename != ab->our_filecopy){
 	struct stat sbuf;
-	time_t tp[2];
+	struct utimbuf tp;
 	int valid_stat = 0;

 	dprint(7, (debugfile, "Before abook copies\n"));
@@ -957,8 +957,8 @@
 	}
 	else{
 	    valid_stat++;
-	    tp[0] = sbuf.st_atime;
-	    tp[1] = sbuf.st_mtime;
+	    tp.actime  = sbuf.st_atime;
+	    tp.modtime = sbuf.st_mtime;
 	}

 	while((c = getc(fp_read)) != EOF)
@@ -967,7 +967,7 @@

 	(void)fclose(fp_write);
 	fp_write = (FILE *)NULL;
-	if(valid_stat && utime(ab->our_filecopy, tp)){
+	if(valid_stat && utime(ab->our_filecopy, &tp)){
 	    q_status_message1(SM_INFO, 0, 3,
 		 "Error: can't set mtime for \"%.200s\"",
 		 (lc=last_cmpnt(ab->filename)) ? lc : ab->our_filecopy);

-- 
-----------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/pine/pine-info/
-----------------------------------------------------------------