Remove warnings in the update client and server
[openafs.git] / src / update / client.c
index 9a5cdd4..333e1eb 100644 (file)
@@ -10,8 +10,6 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 #include <afs/stds.h>
 #ifdef AFS_AIX32_ENV
@@ -36,13 +34,7 @@ RCSID
 #include <sys/time.h>
 #include <dirent.h>
 #endif
-#ifdef HAVE_STRING_H
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -60,6 +52,7 @@ RCSID
 #endif
 #include "update.h"
 #include "global.h"
+#include "update_internal.h"
 
 char *whoami;
 static int verbose;
@@ -70,6 +63,10 @@ static int GetFileFromUpServer(struct rx_connection *conn, char *filename,
                               afs_int32 atime, afs_int32 mtime);
 static int RenameNewFiles(struct filestr *modFiles);
 static int PathsAreEquivalent(char *path1, char *path2);
+int FetchFile(struct rx_call *, char *, char *, int);
+int IsCompatible(char *, afs_int32, afs_int32);
+int NotOnHost(char *, struct filestr *);
+int update_ReceiveFile(int, struct rx_call *, struct stat *);
 
 afs_int32
 GetServer(char *aname)
@@ -88,7 +85,7 @@ GetServer(char *aname)
 
 
 int
-osi_audit()
+osi_audit(void)
 {
 /* this sucks but it works for now.
 */
@@ -218,7 +215,7 @@ main(int argc, char **argv)
     errcode = rx_Init(0);
     if (errcode) {
        printf("Rx initialize failed \n");
-       com_err(whoami, errcode, "calling Rx init");
+       afs_com_err(whoami, errcode, "calling Rx init");
        exit(1);
     }
 
@@ -238,7 +235,7 @@ main(int argc, char **argv)
        exit(1);
     }
     if (errcode) {
-       com_err(whoami, errcode, "Couldn't get security obect for localAuth");
+       afs_com_err(whoami, errcode, "Couldn't get security obect for localAuth");
        exit(1);
     }
 
@@ -260,7 +257,7 @@ main(int argc, char **argv)
 
            /* construct local path from canonical (wire-format) path */
            if ((errcode = ConstructLocalPath(df->name, "/", &curDir))) {
-               com_err(whoami, errcode, "Unable to construct local path");
+               afs_com_err(whoami, errcode, "Unable to construct local path");
                return errcode;
            }
 
@@ -271,7 +268,7 @@ main(int argc, char **argv)
 #else
                if (mkdir(curDir, 0700) < 0) {
 #endif
-                   com_err(whoami, errno, "can't create dir");
+                   afs_com_err(whoami, errno, "can't create dir");
                    printf("upclient: Can't update dir %s\n", curDir);
                    return -1;
                }
@@ -290,14 +287,14 @@ main(int argc, char **argv)
            error = rx_EndCall(call, 0);
            if (error && !errcode) {
                printf("could not end rx call \n");
-               com_err(whoami, error, "calling EndCall");
+               afs_com_err(whoami, error, "calling EndCall");
                goto fail;
            }
            if (errcode) {
                printf
                    ("warning: could not fetch the contents of directory %s \n",
                     df->name);
-               com_err(whoami, errcode, "calling FetchFile");
+               afs_com_err(whoami, errcode, "calling FetchFile");
                cnt++;
                goto fail;
            }
@@ -305,7 +302,7 @@ main(int argc, char **argv)
            stream = fopen(dirbuf, "r");
            if (stream == NULL) {
                printf("fopen failed on %s \n", dirbuf);
-               com_err(whoami, errno, "fopen");
+               afs_com_err(whoami, errno, "fopen");
                goto fail;
            }
            umask(00);
@@ -354,7 +351,7 @@ main(int argc, char **argv)
 
                dirp = opendir(curDir);
                if (dirp == 0) {
-                   com_err(whoami, errno, "Can't open local dir %s", curDir);
+                   afs_com_err(whoami, errno, "Can't open local dir %s", curDir);
                    goto fail;
                }
 
@@ -373,7 +370,7 @@ main(int argc, char **argv)
                        errcode = unlink(filename);
                        if (errcode) {
                            printf("could not delete file %s \n", filename);
-                           com_err(whoami, errno, "could not delete file %s",
+                           afs_com_err(whoami, errno, "could not delete file %s",
                                    filename);
                        }
                    }
@@ -415,7 +412,7 @@ IsCompatible(char *filename, afs_int32 time, afs_int32 length)
 
     /* construct a local path from canonical (wire-format) path */
     if ((error = ConstructLocalPath(filename, "/", &localname))) {
-       com_err(whoami, error, "Unable to construct local path");
+       afs_com_err(whoami, error, "Unable to construct local path");
        return error;
     }
 
@@ -448,14 +445,14 @@ FetchFile(struct rx_call *call, char *remoteFile, char *localFile, int dirFlag)
     fd = open(localFile, O_CREAT | O_TRUNC | O_WRONLY, 0666);
     if (fd < 0) {
        printf("Could not create %s\n", localFile);
-       com_err(whoami, errno, "Could not create %s", localFile);
+       afs_com_err(whoami, errno, "Could not create %s", localFile);
        error = UPDATE_ERROR;
        return error;
     }
     if (fstat(fd, &status) < 0) {
-       com_err(whoami, errno, "Could not stat %s", localFile);
+       afs_com_err(whoami, errno, "Could not stat %s", localFile);
        close(fd);
-       printf("could not stast %s\n", localFile);
+       printf("could not stat %s\n", localFile);
        return UPDATE_ERROR;
     }
     if (update_ReceiveFile(fd, call, &status))
@@ -479,7 +476,7 @@ update_ReceiveFile(register int fd, register struct rx_call *call, register stru
     struct statfs tstatfs;
 #endif
 
-    len = rx_Read(call, &length, sizeof(afs_int32));
+    len = rx_Read(call, (char *)&length, sizeof(afs_int32));
     length = ntohl(length);
     if (len != sizeof(afs_int32))
        return UPDATE_ERROR;
@@ -503,7 +500,7 @@ update_ReceiveFile(register int fd, register struct rx_call *call, register stru
        if (!nbytes)
            error = UPDATE_ERROR;
        if (write(fd, buffer, nbytes) != nbytes) {
-           com_err(whoami, errno, "File system write failed!");
+           afs_com_err(whoami, errno, "File system write failed!");
            printf("File system write failed!\n");
            error = UPDATE_ERROR;
        }
@@ -586,7 +583,7 @@ NotOnHost(char *filename, struct filestr *okhostfiles)
     for (tf = okhostfiles; tf; tf = tf->next) {
        /* construct local path from canonical (wire-format) path */
        if ((rc = ConstructLocalPath(tf->name, "/", &hostfile))) {
-           com_err(whoami, rc, "Unable to construct local path");
+           afs_com_err(whoami, rc, "Unable to construct local path");
            return -1;
        }
        if (PathsAreEquivalent(hostfile, filename)) {
@@ -613,7 +610,7 @@ RenameNewFiles(struct filestr *modFiles)
     for (tf = modFiles; tf; tf = tf->next) {
        /* construct local path from canonical (wire-format) path */
        if ((errcode = ConstructLocalPath(tf->name, "/", &fname))) {
-           com_err(whoami, errcode, "Unable to construct local path");
+           afs_com_err(whoami, errcode, "Unable to construct local path");
            return errcode;
        }
        strcpy(newname, fname);
@@ -623,7 +620,7 @@ RenameNewFiles(struct filestr *modFiles)
        errcode = renamefile(newname, fname);
        if (errcode) {
            printf("could not rename %s to %s\n", newname, fname);
-           com_err(whoami, errno, "could not rename %s to %s", newname,
+           afs_com_err(whoami, errno, "could not rename %s to %s", newname,
                    fname);
        }
        free(fname);
@@ -664,7 +661,7 @@ GetFileFromUpServer(struct rx_connection *conn,     /* handle for upserver */
     /* construct local path from canonical (wire-format) path */
     errcode = ConstructLocalPath(filename, "/", &lfile);
     if (errcode) {
-       com_err(whoami, errcode, "Unable to construct local path");
+       afs_com_err(whoami, errcode, "Unable to construct local path");
        return -1;
     }
     strcpy(newfile, lfile);
@@ -681,7 +678,8 @@ GetFileFromUpServer(struct rx_connection *conn,     /* handle for upserver */
 
     if (errcode) {
        printf("failed to fetch file %s \n", filename);
-       com_err(whoami, errcode, "fetching file");
+       afs_com_err(whoami, errcode, "fetching file");
+        unlink(newfile);
        return 1;
     }
 
@@ -690,8 +688,9 @@ GetFileFromUpServer(struct rx_connection *conn,     /* handle for upserver */
     if (errcode) {
        printf("could not change protection on %s to %u\n", newfile,
               (unsigned int)mode);
-       com_err(whoami, errno, "could not change protection on %s to %u",
+       afs_com_err(whoami, errno, "could not change protection on %s to %u",
                newfile, mode);
+        unlink(newfile);
        return 1;
     }
 #ifdef AFS_NT40_ENV
@@ -703,7 +702,7 @@ GetFileFromUpServer(struct rx_connection *conn,     /* handle for upserver */
     if (errcode) {
        printf("warning: could not change uid and gid on %s to %u and %u \n",
               newfile, gid, uid);
-       com_err(whoami, errno,
+       afs_com_err(whoami, errno,
                "warning: could not change uid and gid on %s to %u and %u",
                newfile, gid, uid);
     }
@@ -716,9 +715,10 @@ GetFileFromUpServer(struct rx_connection *conn,    /* handle for upserver */
     if (errcode) {
        printf("could not change access and modify times on %s to %u %u\n",
               newfile, (unsigned int)atime, (unsigned int)mtime);
-       com_err(whoami, errno,
+       afs_com_err(whoami, errno,
                "could not change access and modify times on %s to %u %u",
                newfile, atime, mtime);
+        unlink(newfile);
        return 1;
     }