bucoord: Set but not used variables
[openafs.git] / src / bucoord / commands.c
index a7e598c..8fd4a0e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 #include <afs/stds.h>
 #if defined(AFS_LINUX24_ENV)
 #define _REGEX_RE_COMP
 #endif
 #include <sys/types.h>
-#if defined(AFS_LINUX24_ENV)
-#include <regex.h>
-#endif
 #include <afs/cmd.h>
 #ifdef AFS_NT40_ENV
 #include <winsock2.h>
@@ -31,49 +26,56 @@ RCSID
 #endif
 #include <errno.h>
 #include <afs/com_err.h>
+#include <afs/afsutil.h>
 #include <afs/budb.h>
+#include <afs/budb_prototypes.h>
 #include <afs/butc.h>
 #include <afs/bubasics.h>      /* PA */
 #include <afs/volser.h>
 #include <afs/voldefs.h>       /* PA */
 #include <afs/vldbint.h>       /* PA */
 #include <afs/ktime.h>         /* PA */
+#include <ubik.h>
 #include <time.h>
-
 #include <lock.h>
 #include <afs/butc.h>
 #include <afs/tcdata.h>
 #include <afs/butx.h>
+#include <afs/vsutils_prototypes.h>
+#ifdef HAVE_POSIX_REGEX                /* use POSIX regexp library */
+#include <regex.h>
+#endif
 #include "bc.h"
 #include "error_macros.h"
-
+#include "bucoord_internal.h"
+#include "bucoord_prototypes.h"
 
 extern struct bc_config *bc_globalConfig;
-extern struct bc_dumpSchedule *bc_FindDumpSchedule();
-extern struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *cfg,
-                                            char *name);
 extern struct bc_dumpTask bc_dumpTasks[BC_MAXSIMDUMPS];
 extern struct ubik_client *cstruct;
-extern int bc_Dumper();                /* function to do dumps */
-extern int bc_Restorer();      /* function to do restores */
 extern char *whoami;
-extern struct ktc_token ttoken;
-extern char *tailCompPtr();
-extern statusP createStatusNode();
 
 char *loadFile;
 extern afs_int32 lastTaskCode;
 
 #define HOSTADDR(sockaddr) (sockaddr)->sin_addr.s_addr
 
+static int EvalVolumeSet1(struct bc_config *aconfig, struct bc_volumeSet *avs,
+                         struct bc_volumeDump **avols,
+                         struct ubik_client *uclient);
+
+static int EvalVolumeSet2(struct bc_config *aconfig, struct bc_volumeSet *avs,
+                         struct bc_volumeDump **avols,
+                         struct ubik_client *uclient);
+static int DBLookupByVolume(char *volumeName);
+
 int
-bc_EvalVolumeSet(aconfig, avs, avols, uclient)
-     struct bc_config *aconfig;
-     register struct bc_volumeSet *avs;
-     struct bc_volumeDump **avols;
-     struct ubik_client *uclient;
+bc_EvalVolumeSet(struct bc_config *aconfig,
+                struct bc_volumeSet *avs,
+                struct bc_volumeDump **avols,
+                struct ubik_client *uclient)
 {                              /*bc_EvalVolumeSet */
-    int code;
+    int code = -1;
     static afs_int32 use = 2;
 
     if (use == 2) {            /* Use EvalVolumeSet2() */
@@ -102,11 +104,10 @@ struct serversort {
 };
 
 afs_int32
-getSPEntries(server, partition, serverlist, ss, ps)
-     afs_uint32 server;
-     afs_int32 partition;
-     struct serversort **serverlist, **ss;
-     struct partitionsort **ps;
+getSPEntries(afs_uint32 server, afs_int32 partition,
+            struct serversort **serverlist,
+            struct serversort **ss,
+            struct partitionsort **ps)
 {
     if (!(*ss) || ((*ss)->ipaddr != server)) {
        *ps = 0;
@@ -119,7 +120,7 @@ getSPEntries(server, partition, serverlist, ss, ps)
     if (!(*ss)) {
        *ss = (struct serversort *)malloc(sizeof(struct serversort));
        if (!(*ss)) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            *ss = 0;
            return (BC_NOMEM);
        }
@@ -140,7 +141,7 @@ getSPEntries(server, partition, serverlist, ss, ps)
     if (!(*ps)) {
        *ps = (struct partitionsort *)malloc(sizeof(struct partitionsort));
        if (!(*ps)) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            free(*ss);
            *ps = 0;
            *ss = 0;
@@ -155,9 +156,8 @@ getSPEntries(server, partition, serverlist, ss, ps)
 }
 
 afs_int32
-randSPEntries(serverlist, avols)
-     struct serversort *serverlist;
-     struct bc_volumeDump **avols;
+randSPEntries(struct serversort *serverlist,
+             struct bc_volumeDump **avols)
 {
     struct serversort *ss, **pss;
     struct partitionsort *ps, **pps;
@@ -197,12 +197,11 @@ randSPEntries(serverlist, avols)
     return 0;
 }
 
-int
-EvalVolumeSet2(aconfig, avs, avols, uclient)
-     struct bc_config *aconfig;
-     struct bc_volumeSet *avs;
-     struct bc_volumeDump **avols;
-     struct ubik_client *uclient;
+static int
+EvalVolumeSet2(struct bc_config *aconfig,
+              struct bc_volumeSet *avs,
+              struct bc_volumeDump **avols,
+              struct ubik_client *uclient)
 {                              /*EvalVolumeSet2 */
     struct bc_volumeEntry *tve;
     struct bc_volumeDump *tavols;
@@ -214,7 +213,7 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
     struct bc_volumeDump *tvd;
     afs_int32 code = 0, tcode;
     afs_int32 count = 0;
-    struct serversort *servers = 0, *lastserver = 0, *ss = 0;
+    struct serversort *servers = 0, *ss = 0;
     struct partitionsort *ps = 0;
 
     *avols = (struct bc_volumeDump *)0;
@@ -223,7 +222,7 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
 
     /* For each of the volume set entries - collect the volumes that match it */
     for (tve = avs->ventries; tve; tve = tve->next) {
-       /* Put together a call to the vlserver for this vlentry. The 
+       /* Put together a call to the vlserver for this vlentry. The
         * performance gain is from letting the vlserver expand the
         * volumeset and not this routine.
         */
@@ -287,7 +286,7 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
                                 entries[e].serverPartition[ei], &servers,
                                 &ss, &ps);
                if (tcode) {
-                   afs_com_err(whoami, tcode, "");
+                   afs_com_err(whoami, tcode, NULL);
                    ERROR(tcode);
                }
 
@@ -319,14 +318,14 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
                    tvd = (struct bc_volumeDump *)
                        malloc(sizeof(struct bc_volumeDump));
                    if (!tvd) {
-                       afs_com_err(whoami, BC_NOMEM, "");
+                       afs_com_err(whoami, BC_NOMEM, NULL);
                        ERROR(BC_NOMEM);
                    }
                    memset(tvd, 0, sizeof(*tvd));
 
                    tvd->name = (char *)malloc(strlen(entries[e].name) + 10);
                    if (!(tvd->name)) {
-                       afs_com_err(whoami, BC_NOMEM, "");
+                       afs_com_err(whoami, BC_NOMEM, NULL);
                        free(tvd);
                        ERROR(BC_NOMEM);
                    }
@@ -382,29 +381,29 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
  * EvalVolumeSetOld
  *
  * Description:
- *     Takes the entries in a volumeset and expands them into a list of 
+ *     Takes the entries in a volumeset and expands them into a list of
  *      volumes. Every VLDB volume entry is looked at and compared to the
  *      volumeset entries.
  *
- *      When matching a VLDB volume entry to a volumeset entry, 
+ *      When matching a VLDB volume entry to a volumeset entry,
  *       1. If the RW volume entry matches, that RW volume is used.
  *       2. Otherwise, if the BK volume entry matches, the BK volume is used.
  *       3. Finally, if the RO volume entry matches, the RO volume is used.
- *      For instance: A volumeset entry of ".* .* user.t.*" will match volume 
- *                    "user.troy" and "user.troy.backup". The rules will use 
+ *      For instance: A volumeset entry of ".* .* user.t.*" will match volume
+ *                    "user.troy" and "user.troy.backup". The rules will use
  *                    the RW volume "user.troy".
  *
  *      When a VLDB volume entry matches a volumeset entry (be it RW, BK or RO),
- *      that volume is used and matches against any remaining volumeset entries 
+ *      that volume is used and matches against any remaining volumeset entries
  *      are not even done.
  *      For instance: A 1st volumeset entry ".* .* .*.backup" will match with
- *                    "user.troy.backup". Its 2nd volumeset entry ".* .* .*" 
- *                    would have matched its RW volume "user.troy", but the first 
+ *                    "user.troy.backup". Its 2nd volumeset entry ".* .* .*"
+ *                    would have matched its RW volume "user.troy", but the first
  *                    match is used and the second match isn't even done.
  *
  * Arguments:
  *     aconfig : Global configuration info.
- *     avs     : 
+ *     avs     :
  *     avols   : Ptr to linked list of entries describing volumes to dump.
  *     uclient : Ptr to Ubik client structure.
  *
@@ -419,15 +418,13 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
  *     None.
  *-----------------------------------------------------------------------------
  */
-int
-EvalVolumeSet1(aconfig, avs, avols, uclient)
-     struct bc_config *aconfig;
-     struct bc_volumeSet *avs;
-     struct bc_volumeDump **avols;
-     struct ubik_client *uclient;
+static int
+EvalVolumeSet1(struct bc_config *aconfig,
+              struct bc_volumeSet *avs,
+              struct bc_volumeDump **avols,
+              struct ubik_client *uclient)
 {                              /*EvalVolumeSet1 */
     afs_int32 code;            /*Result of various calls */
-    char *errm;
     struct bc_volumeDump *tvd; /*Ptr to new dump instance */
     struct bc_volumeEntry *tve, *ctve; /*Ptr to new volume entry instance */
     char patt[256];            /*Composite regex; also, target string */
@@ -442,6 +439,12 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
     int foundentry = 0;
     struct serversort *servers = 0, *ss = 0;
     struct partitionsort *ps = 0;
+#ifdef HAVE_POSIX_REGEX
+    regex_t re;
+    int need_regfree = 0;
+#else
+    char *errm;
+#endif
 
     *avols = (struct bc_volumeDump *)0;
     ctve = (struct bc_volumeEntry *)0; /* no compiled entry */
@@ -488,6 +491,13 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                /* If the volume entry is not compiled, then compile it */
                if (ctve != tve) {
                    sprintf(patt, "^%s$", tve->name);
+#ifdef HAVE_POSIX_REGEX
+                   if (regcomp(&re, patt, REG_NOSUB) != 0) {
+                     afs_com_err(whoami, 0, "Can't compile regular expression '%s'", patt);
+                     return (-1);
+                   }
+                   need_regfree = 1;
+#else
                    errm = (char *)re_comp(patt);
                    if (errm) {
                        afs_com_err(whoami, 0,
@@ -495,6 +505,7 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                                patt, errm);
                        return (-1);
                    }
+#endif
                    ctve = tve;
                }
 
@@ -504,8 +515,13 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                if (entry.serverFlags[srvpartpair] & ITSRWVOL) {
                    if (entry.flags & RW_EXISTS) {
                        sprintf(patt, "%s", entry.name);
+#ifdef HAVE_POSIX_REGEX
+                       code = regexec(&re, patt, 0, NULL, 0);
+                       if (code == 0) {
+#else
                        code = re_exec(patt);
                        if (code == 1) {
+#endif
                            found = 1;
                            foundentry = srvpartpair;
                            volType = RWVOL;
@@ -513,13 +529,18 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                        }
                    }
 
-                   /* If the BK name matches the volume set entry, take 
+                   /* If the BK name matches the volume set entry, take
                     * it and exit. Second choice is to use the BK volume.
                     */
                    if (entry.flags & BACK_EXISTS) {
                        sprintf(patt, "%s.backup", entry.name);
+#ifdef HAVE_POSIX_REGEX
+                       code = regexec(&re, patt, 0, NULL, 0);
+                       if (code == 0) {
+#else
                        code = re_exec(patt);
                        if (code == 1) {
+#endif
                            found = 1;
                            foundentry = srvpartpair;
                            volType = BACKVOL;
@@ -535,8 +556,13 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                else if (!found && (entry.serverFlags[srvpartpair] & ITSROVOL)
                         && (entry.flags & RO_EXISTS)) {
                    sprintf(patt, "%s.readonly", entry.name);
+#ifdef HAVE_POSIX_REGEX
+                   code = regexec(&re, patt, 0, NULL, 0);
+                   if (code == 0) {
+#else
                    code = re_exec(patt);
                    if (code == 1) {
+#endif
                        found = 1;
                        foundentry = srvpartpair;
                        volType = ROVOL;
@@ -555,7 +581,7 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                                 entry.serverPartition[foundentry], &servers,
                                 &ss, &ps);
                if (code) {
-                   afs_com_err(whoami, code, "");
+                   afs_com_err(whoami, code, NULL);
                    return (code);
                }
 
@@ -563,14 +589,14 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                tvd = (struct bc_volumeDump *)
                    malloc(sizeof(struct bc_volumeDump));
                if (!tvd) {
-                   afs_com_err(whoami, BC_NOMEM, "");
+                   afs_com_err(whoami, BC_NOMEM, NULL);
                    return (BC_NOMEM);
                }
                memset(tvd, 0, sizeof(*tvd));
 
                tvd->name = (char *)malloc(strlen(entry.name) + 10);
                if (!(tvd->name)) {
-                   afs_com_err(whoami, BC_NOMEM, "");
+                   afs_com_err(whoami, BC_NOMEM, NULL);
                    free(tvd);
                    return (BC_NOMEM);
                }
@@ -598,6 +624,10 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
            }                   /*f */
        }                       /*ve */
     }                          /*w */
+#ifdef HAVE_POSIX_REGEX
+    if (need_regfree)
+       regfree(&re);
+#endif
 
     /* Randomly link the volumedump entries together */
     randSPEntries(servers, avols);
@@ -606,38 +636,41 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
     return (0);
 }                              /*EvalVolumeSet1 */
 
-/* compactDateString
- *     print out a date in compact format, 16 chars, format is
- *     mm/dd/yyyy hh:mm
- * entry:
- *     date_long - ptr to a long containing the time
- * exit:
- *     ptr to a string containing a representation of the date
- */
 char *
-compactDateString(date_long, string, size)
-     afs_int32 *date_long, size;
-     char *string;
+compactTimeString(time_t *date, char *string, afs_int32 size)
 {
     struct tm *ltime;
 
     if (!string)
-       return 0;
+       return NULL;
 
-    if (*date_long == NEVERDATE) {
+    if (*date == NEVERDATE) {
        sprintf(string, "NEVER");
     } else {
-        time_t t = *date_long;
-       ltime = localtime(&t);
-       /* prints date in U.S. format of mm/dd/yyyy */
+       ltime = localtime(date);
        strftime(string, size, "%m/%d/%Y %H:%M", ltime);
     }
     return (string);
 }
 
+/* compactDateString
+ *     print out a date in compact format, 16 chars, format is
+ *     mm/dd/yyyy hh:mm
+ * entry:
+ *     date_long - ptr to a long containing the time
+ * exit:
+ *     ptr to a string containing a representation of the date
+ */
+char *
+compactDateString(afs_uint32 *date_long, char *string, afs_int32 size)
+{
+    time_t t = *date_long;
+    return compactTimeString(&t, string, size);
+}
+
+
 afs_int32
-bc_SafeATOI(anum)
-     char *anum;
+bc_SafeATOI(char *anum)
 {
     afs_int32 total = 0;
 
@@ -655,8 +688,7 @@ bc_SafeATOI(anum)
  *    Return the size in KBytes.
  */
 afs_int32
-bc_FloatATOI(anum)
-     char *anum;
+bc_FloatATOI(char *anum)
 {
     float total = 0;
     afs_int32 rtotal;
@@ -702,8 +734,7 @@ bc_FloatATOI(anum)
 
 /* make a copy of a string so that it can be freed later */
 char *
-bc_CopyString(astring)
-     char *astring;
+bc_CopyString(char *astring)
 {
     afs_int32 tlen;
     char *tp;
@@ -713,7 +744,7 @@ bc_CopyString(astring)
     tlen = strlen(astring);
     tp = (char *)malloc(tlen + 1);     /* don't forget the terminating null */
     if (!tp) {
-       afs_com_err(whoami, BC_NOMEM, "");
+       afs_com_err(whoami, BC_NOMEM, NULL);
        return (tp);
     }
     strcpy(tp, astring);
@@ -721,14 +752,13 @@ bc_CopyString(astring)
 }
 
 /* concatParams
- * 
+ *
  *    Concatenates the parameters of an option and returns the string.
  *
  */
 
 char *
-concatParams(itemPtr)
-     struct cmd_item *itemPtr;
+concatParams(struct cmd_item *itemPtr)
 {
     struct cmd_item *tempPtr;
     afs_int32 length = 0;
@@ -747,7 +777,7 @@ concatParams(itemPtr)
 
     string = (char *)malloc(length);   /* allocate the string */
     if (!string) {
-       afs_com_err(whoami, BC_NOMEM, "");
+       afs_com_err(whoami, BC_NOMEM, NULL);
        return (NULL);
     }
     string[0] = 0;
@@ -766,14 +796,13 @@ concatParams(itemPtr)
 /* printIfStatus
  *     print out an interface status node as received from butc
  */
+
 void
-printIfStatus(statusPtr)
-     struct tciStatusS *statusPtr;
+printIfStatus(struct tciStatusS *statusPtr)
 {
     printf("Task %d: %s: ", statusPtr->taskId, statusPtr->taskName);
     if (statusPtr->nKBytes)
-       printf("%ld Kbytes transferred", statusPtr->nKBytes);
+       printf("%ld Kbytes transferred", (long unsigned int) statusPtr->nKBytes);
     if (strlen(statusPtr->volumeName) != 0) {
        if (statusPtr->nKBytes)
            printf(", ");
@@ -803,8 +832,7 @@ printIfStatus(statusPtr)
 }
 
 afs_int32
-getPortOffset(port)
-     char *port;
+getPortOffset(char *port)
 {
     afs_int32 portOffset;
 
@@ -888,11 +916,10 @@ extern struct Lock dispatchLock;
 /* bc_WaitForNoJobs
  *     wait for all jobs to terminate
  */
-bc_WaitForNoJobs()
+int
+bc_WaitForNoJobs(void)
 {
-    afs_int32 wcode = 0;
     int i;
-    int waitmsg = 1;
     int usefulJobRunning = 1;
 
     extern dlqlinkT statusHead;
@@ -951,7 +978,7 @@ bc_JobsCmd(struct cmd_syndesc *as, void *arock)
            if (statusPtr->dbDumpId)
                printf(": DumpID %u", statusPtr->dbDumpId);
            if (statusPtr->nKBytes)
-               printf(", %ld Kbytes", statusPtr->nKBytes);
+               printf(", %ld Kbytes", afs_printable_int32_ld(statusPtr->nKBytes));
            if (strlen(statusPtr->volumeName) != 0)
                printf(", volume %s", statusPtr->volumeName);
 
@@ -976,7 +1003,7 @@ bc_JobsCmd(struct cmd_syndesc *as, void *arock)
        }
     }
 
-    /* 
+    /*
      * Now print the scheduled dumps.
      */
     if (!dlqEmpty(&statusHead) && as)
@@ -996,11 +1023,11 @@ bc_JobsCmd(struct cmd_syndesc *as, void *arock)
        }
 
        /* Print token expiration time */
-       if ((ttoken.endTime > prevTime)
-           && (ttoken.endTime <= youngest->scheduledDump) && as
-           && (ttoken.endTime != NEVERDATE)) {
-           if (ttoken.endTime > time(0)) {
-               compactDateString(&ttoken.endTime, ds, 50);
+       if ((tokenExpires > prevTime)
+           && (tokenExpires <= youngest->scheduledDump) && as
+           && (tokenExpires != NEVERDATE)) {
+           if (tokenExpires > time(0)) {
+               compactTimeString(&tokenExpires, ds, 50);
                printf("       %16s: TOKEN EXPIRATION\n", ds);
            } else {
                printf("       TOKEN HAS EXPIRED\n");
@@ -1020,11 +1047,11 @@ bc_JobsCmd(struct cmd_syndesc *as, void *arock)
     }
 
     /* Print token expiration time if havn't already */
-    if ((ttoken.endTime == NEVERDATE) && as)
+    if ((tokenExpires == NEVERDATE) && as)
        printf("     : TOKEN NEVER EXPIRES\n");
-    else if ((ttoken.endTime > prevTime) && as) {
-       if (ttoken.endTime > time(0)) {
-           compactDateString(&ttoken.endTime, ds, 50);
+    else if ((tokenExpires > prevTime) && as) {
+       if (tokenExpires > time(0)) {
+           compactTimeString(&tokenExpires, ds, 50);
            printf("       %16s: TOKEN EXPIRATION\n", ds);
        } else {
            printf("     : TOKEN HAS EXPIRED\n");
@@ -1048,8 +1075,6 @@ bc_KillCmd(struct cmd_syndesc *as, void *arock)
     statusP statusPtr;
 
     extern dlqlinkT statusHead;
-    extern statusP findStatus();
-
 
     tp = as->parms[0].items->data;
     if (strchr(tp, '.') == 0) {
@@ -1170,14 +1195,14 @@ bc_VolRestoreCmd(struct cmd_syndesc *as, void *arock)
        /* build list of volume items */
        tvol = (struct bc_volumeDump *)malloc(sizeof(struct bc_volumeDump));
        if (!tvol) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
        memset(tvol, 0, sizeof(struct bc_volumeDump));
 
        tvol->name = (char *)malloc(VOLSER_MAXVOLNAME + 1);
        if (!tvol->name) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
        strncpy(tvol->name, ti->data, VOLSER_OLDMAXVOLNAME);
@@ -1210,14 +1235,14 @@ bc_VolRestoreCmd(struct cmd_syndesc *as, void *arock)
     oldFlag = 0;
 
     /* Read all the port offsets into the ports array. The first element in the
-     * array is for full restore and the rest are for incremental restores 
+     * array is for full restore and the rest are for incremental restores
      */
     if (as->parms[5].items) {
        for (ti = as->parms[5].items; ti; ti = ti->next)
            portCount++;
        ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
        if (!ports) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
 
@@ -1236,7 +1261,7 @@ bc_VolRestoreCmd(struct cmd_syndesc *as, void *arock)
        if (dumpID <= 0)
          dumpID = 0;
       }
-    
+
     /*
      * Perform the call to start the restore.
      */
@@ -1284,7 +1309,7 @@ bc_DiskRestoreCmd(struct cmd_syndesc *as, void *arock)
 
     /* parm 0 is the server to restore
      * parm 1 is the partition to restore
-     
+
      * parm 8 and above as in VolRestoreCmd:
      * parm 8 is the new server to restore to
      * parm 9 is the new partition to restore to
@@ -1347,7 +1372,7 @@ bc_DiskRestoreCmd(struct cmd_syndesc *as, void *arock)
            portCount++;
        ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
        if (!ports) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
 
@@ -1372,7 +1397,7 @@ bc_DiskRestoreCmd(struct cmd_syndesc *as, void *arock)
        return (-1);
     }
 
-    /* Since we want only RW volumes, remove any 
+    /* Since we want only RW volumes, remove any
      * BK or RO volumes from the list.
      */
     for (prev = 0, tvol = volsToRestore; tvol; tvol = nextvol) {
@@ -1429,7 +1454,6 @@ bc_VolsetRestoreCmd(struct cmd_syndesc *as, void *arock)
     afs_int32 *ports = NULL;
     afs_int32 portCount = 0;
     afs_int32 code = 0;
-    afs_int32 portoffset = 0;
     char *volsetName;
     struct bc_volumeSet *volsetPtr;    /* Ptr to list of generated volume info */
     struct bc_volumeDump *volsToRestore = (struct bc_volumeDump *)0;
@@ -1519,7 +1543,7 @@ bc_VolsetRestoreCmd(struct cmd_syndesc *as, void *arock)
 
            tvol->name = (char *)malloc(VOLSER_MAXVOLNAME + 1);
            if (!tvol->name) {
-               afs_com_err(whoami, BC_NOMEM, "");
+               afs_com_err(whoami, BC_NOMEM, NULL);
                return BC_NOMEM;
            }
            strncpy(tvol->name, volume, VOLSER_OLDMAXVOLNAME);
@@ -1545,7 +1569,7 @@ bc_VolsetRestoreCmd(struct cmd_syndesc *as, void *arock)
            portCount++;
        ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
        if (!ports) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
 
@@ -1602,7 +1626,6 @@ int dontExecute;
 int
 bc_DumpCmd(struct cmd_syndesc *as, void *arock)
 {                              /*bc_DumpCmd */
-    static char rn[] = "bc_DumpCmd";   /*Routine name */
     char *dumpPath = NULL;
     char *vsName = NULL;      /*Ptrs to various names */
     struct bc_volumeSet *tvs = NULL; /*Ptr to list of generated volume info */
@@ -1617,7 +1640,6 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
     afs_int32 problemFindingDump;      /* can't find parent(s) */
 
     afs_int32 *portp = NULL;
-    afs_int32 portCount = 0;
     afs_int32 doAt, atTime;    /* Time a timed-dump is to start at */
     afs_int32 length;
     char *timeString;
@@ -1628,8 +1650,6 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
     statusP statusPtr;
 
     extern struct bc_dumpTask bc_dumpTasks[];
-    extern afs_int32 bcdb_FindLastVolClone();
-    extern afs_int32 volImageTime();
 
     code = bc_UpdateDumpSchedule();
     if (code) {
@@ -1647,10 +1667,10 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
        return (code);
     }
 
-    /* 
+    /*
      * Some parameters cannot be specified together
-     * The "-file" option cannot exist with the "-volume", "-dump", 
-     * "-portoffset", or "-append" option 
+     * The "-file" option cannot exist with the "-volume", "-dump",
+     * "-portoffset", or "-append" option
      */
     if (as->parms[6].items) {
        loadfile = 1;
@@ -1668,7 +1688,7 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
        }
     }
 
-    /* 
+    /*
      * Get the time we are to perform this dump
      */
     if (as->parms[3].items) {
@@ -1693,7 +1713,7 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
 
     dontExecute = (as->parms[5].items ? 1 : 0);        /* -n */
 
-    /* 
+    /*
      * If this dump is not a load file, then check the parameters.
      */
     if (!loadfile) {           /*6 */
@@ -1702,10 +1722,9 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
 
        /* get the port number, if one was specified */
        if (as->parms[2].items) {
-           portCount = 1;
            portp = (afs_int32 *) malloc(sizeof(afs_int32));
            if (!portp) {
-               afs_com_err(whoami, BC_NOMEM, "");
+               afs_com_err(whoami, BC_NOMEM, NULL);
                return BC_NOMEM;
            }
 
@@ -1737,12 +1756,12 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
 
     /*6 */
     /*
-     * If given the "-at" option, then add this to the jobs list and return 
+     * If given the "-at" option, then add this to the jobs list and return
      * with no error.
      *
      * Create a status node for this timed dump.
      * Fill in the time to dump and the cmd line for the dump leaving off
-     * the -at option.  If the -n option is there, it is scheduled with 
+     * the -at option.  If the -n option is there, it is scheduled with
      * the Timed dump as opposed to not scheduling the time dump at all.
      */
     if (doAt) {
@@ -1786,7 +1805,7 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
            statusPtr->scheduledDump = atTime;
            statusPtr->cmdLine = (char *)malloc(length);
            if (!statusPtr->cmdLine) {
-               afs_com_err(whoami, BC_NOMEM, "");
+               afs_com_err(whoami, BC_NOMEM, NULL);
                return BC_NOMEM;
            }
 
@@ -1819,7 +1838,7 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
                strcat(statusPtr->cmdLine, " -n");
 
            printf("Add scheduled dump as job %d\n", statusPtr->jobNumber);
-           if ((atTime > ttoken.endTime) && (ttoken.endTime != NEVERDATE))
+           if ((atTime > tokenExpires) && (tokenExpires != NEVERDATE))
                afs_com_err(whoami, 0,
                        "Warning: job %d starts after expiration of AFS token",
                        statusPtr->jobNumber);
@@ -1830,7 +1849,7 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
        return (0);
     }
 
-    /* 
+    /*
      * Read and execute the load file if specified.  The work of reading is done
      * in the main routine prior the dispatch call. loadFile and dontExecute are
      * global variables so this can take place in main.
@@ -1838,14 +1857,14 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
     if (loadfile) {
        loadFile = (char *)malloc(strlen(as->parms[6].items->data) + 1);
        if (!loadFile) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
        strcpy(loadFile, as->parms[6].items->data);
        return 0;
     }
 
-    /* 
+    /*
      * We are doing a real dump (no load file or timed dump).
      */
     printf("Starting dump of volume set '%s' (dump level '%s')\n", vsName,
@@ -1868,9 +1887,9 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
        }
 
        /* We found the most recent dump at this level. Now check
-        * if we should use it by seeing if its full dump hierarchy 
+        * if we should use it by seeing if its full dump hierarchy
         * exists. If it doesn't, we don't want to base our incremental
-        * off of this dump. 
+        * off of this dump.
         */
        if (!parent || (dumpEntry.id > parent)) {
            /* Follow the parent dumps to see if they are all there */
@@ -1896,7 +1915,7 @@ bc_DumpCmd(struct cmd_syndesc *as, void *arock)
        }
     }
 
-    /* If the problemflag was raise, it means we are not doing the 
+    /* If the problemflag was raise, it means we are not doing the
      * dump at the level we requested it be done at.
      */
     if (problemFindingDump) {
@@ -2158,10 +2177,8 @@ bc_ScanDumpsCmd(struct cmd_syndesc *as, void *arock)
  */
 
 afs_int32
-bc_ParseExpiration(paramPtr, expType, expDate)
-     struct cmd_parmdesc *paramPtr;
-     afs_int32 *expType;
-     afs_int32 *expDate;
+bc_ParseExpiration(struct cmd_parmdesc *paramPtr, afs_int32 *expType,
+                  afs_int32 *expDate)
 {
     struct cmd_item *itemPtr;
     struct ktime_date kt;
@@ -2297,10 +2314,10 @@ bc_dbVerifyCmd(struct cmd_syndesc *as, void *arock)
 /* deleteDump:
  * Delete a dump. If port is >= 0, it means try to delete from XBSA server
  */
-deleteDump(dumpid, port, force)
-     afs_uint32 dumpid;                /* The dumpid to delete */
-     afs_int32 port;           /* port==-1 means don't go to butc */
-     afs_int32 force;
+int
+deleteDump(afs_uint32 dumpid,          /* The dumpid to delete */
+          afs_int32 port,              /* port==-1 means don't go to butc */
+          afs_int32 force)
 {
     afs_int32 code = 0, tcode;
     struct budb_dumpEntry dumpEntry;
@@ -2329,7 +2346,7 @@ deleteDump(dumpid, port, force)
 
        /* If dump is to an XBSA server, connect to butc and send it
         * the dump to delete. Butc will contact the XBSA server.
-        * The dump will not be an appended dump because XBSA butc 
+        * The dump will not be an appended dump because XBSA butc
         * does not support the append option.
         */
        if (xbsadump && dumpEntry.nVolumes) {
@@ -2389,7 +2406,7 @@ deleteDump(dumpid, port, force)
        /* Display the dumps that were deleted - includes appended dumps */
        for (i = 0; i < dumps.budb_dumpsList_len; i++)
            printf("     %u%s\n", dumps.budb_dumpsList_val[i],
-                  (i > 0) ? " Appended Dump" : "");
+                  (i > 0) ? " Appended Dump" : NULL);
        if (dumps.budb_dumpsList_val)
            free(dumps.budb_dumpsList_val);
     }
@@ -2410,11 +2427,11 @@ bc_deleteDumpCmd(struct cmd_syndesc *as, void *arock)
     afs_int32 rcode = 0;
     afs_int32 groupId = 0, havegroupid, sflags, noexecute;
     struct cmd_item *ti;
-    afs_uint32 fromTime = 0, toTime = 0, havetime = 0;
+    afs_int32 fromTime = 0, toTime = 0, havetime = 0;
     char *timeString;
     budb_dumpsList dumps, flags;
     int i;
-    afs_int32 port = -1, dbonly = 0, force;
+    afs_int32 port = -1, force;
 
     /* Must specify at least one of -dumpid, -from, or -to */
     if (!as->parms[0].items && !as->parms[1].items && !as->parms[2].items
@@ -2672,7 +2689,7 @@ bc_restoreDbCmd(struct cmd_syndesc *as, void *arock)
 }
 
 /* ----------------------------------
- * supporting routines for database examination 
+ * supporting routines for database examination
  * ----------------------------------
  */
 
@@ -2706,8 +2723,8 @@ struct dumpedVol {
  *     volumeName - volume to lookup
  */
 
-DBLookupByVolume(volumeName)
-     char *volumeName;
+static int
+DBLookupByVolume(char *volumeName)
 {
     struct budb_dumpEntry dumpEntry;
     struct budb_volumeEntry volumeEntry[DBL_MAX_VOLUMES];
@@ -2819,7 +2836,7 @@ DBLookupByVolume(volumeName)
     }
 
     if (code)
-       afs_com_err(whoami, code, "");
+       afs_com_err(whoami, code, NULL);
     return (code);
 }
 
@@ -2842,9 +2859,7 @@ struct tapeLink {
  */
 
 afs_int32
-dumpInfo(dumpid, detailFlag)
-     afs_int32 dumpid;
-     afs_int32 detailFlag;
+dumpInfo(afs_int32 dumpid, afs_int32 detailFlag)
 {
     struct budb_dumpEntry dumpEntry;
     struct tapeLink *head = 0;
@@ -2909,7 +2924,7 @@ dumpInfo(dumpid, detailFlag)
     for (tapeNumber = dumpEntry.tapes.b; tapeNumber <= dumpEntry.tapes.maxTapes; tapeNumber++) {       /*f */
        tapeLinkPtr = (struct tapeLink *)malloc(sizeof(struct tapeLink));
        if (!tapeLinkPtr) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            ERROR(BC_NOMEM);
        }
 
@@ -2961,7 +2976,7 @@ dumpInfo(dumpid, detailFlag)
                volumeLinkPtr =
                    (struct volumeLink *)malloc(sizeof(struct volumeLink));
                if (!volumeLinkPtr) {
-                   afs_com_err(whoami, BC_NOMEM, "");
+                   afs_com_err(whoami, BC_NOMEM, NULL);
                    ERROR(BC_NOMEM);
                }
                memset(volumeLinkPtr, 0, sizeof(*volumeLinkPtr));
@@ -3050,8 +3065,7 @@ dumpInfo(dumpid, detailFlag)
 }
 
 int
-compareDump(ptr1, ptr2)
-     struct budb_dumpEntry *ptr1, *ptr2;
+compareDump(struct budb_dumpEntry *ptr1, struct budb_dumpEntry *ptr2)
 {
     if (ptr1->created < ptr2->created)
        return (-1);
@@ -3061,8 +3075,7 @@ compareDump(ptr1, ptr2)
 }
 
 afs_int32
-printRecentDumps(ndumps)
-     int ndumps;
+printRecentDumps(int ndumps)
 {
     afs_int32 code = 0;
     afs_int32 nextindex, index = 0;
@@ -3073,7 +3086,6 @@ printRecentDumps(ndumps)
     char ds[50];
 
     extern struct udbHandleS udbHandle;
-    extern compareDump();
 
     do {                       /* while (nextindex != -1) */
        /* initialize the dump list */
@@ -3123,7 +3135,7 @@ printRecentDumps(ndumps)
     return (code);
 }
 
-/* bc_dumpInfoCmd 
+/* bc_dumpInfoCmd
  *     list the dumps and contens of the dumps.
  * params:
  *     as - name of tape
@@ -3137,8 +3149,6 @@ bc_dumpInfoCmd(struct cmd_syndesc *as, void *arock)
     afs_int32 ndumps;
     afs_int32 code = 0;
 
-    afs_int32 dumpInfo();
-
     if (as->parms[0].items) {
        if (as->parms[1].items) {
            afs_com_err(whoami, 0,