Add printf format checks to afs_com_err()
[openafs.git] / src / bucoord / dump.c
index 6c7deac..7747866 100644 (file)
@@ -14,8 +14,6 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 #include <sys/types.h>
 #include <afs/cmd.h>
@@ -23,7 +21,6 @@ RCSID
 #include <winsock2.h>
 #else
 #include <sys/param.h>
-#include <strings.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netdb.h>
@@ -40,24 +37,16 @@ RCSID
 
 #include "bc.h"
 #include "error_macros.h"
+#include "bucoord_internal.h"
+#include "bucoord_prototypes.h"
 
 struct bc_dumpTask bc_dumpTasks[BC_MAXSIMDUMPS];
 
-extern struct bc_config *bc_globalConfig;
-extern char *bc_CopyString();
-extern void bc_HandleMisc();
 extern char *whoami;
-extern char *tailCompPtr();
-extern statusP createStatusNode();
-extern afs_int32 bc_jobNumber();
 
 extern afs_int32 lastTaskCode;
 
-#ifdef AFS_DEC_ENV
-#define HOSTADDR(sockaddr) (sockaddr)->sin_addr.S_un.S_addr
-#else
 #define HOSTADDR(sockaddr) (sockaddr)->sin_addr.s_addr
-#endif
 
 /* bc_Dumper
  *     called (indirectly) to make a dump
@@ -65,13 +54,12 @@ extern afs_int32 lastTaskCode;
  *     aindex - index into dumpTask array, contains all the information 
  *              relevant to the dump
  */
-bc_Dumper(aindex)
+int
+bc_Dumper(int aindex)
 {
     struct rx_connection *tconn;
-    struct tc_dumpStat dumpStat;
     register struct bc_volumeDump *tde;
     afs_int32 count, port;
-    struct timeval tv;
     struct tc_dumpDesc *volDesc = 0;
     struct tc_dumpArray volArray;
     char *baseNamePtr;
@@ -102,7 +90,7 @@ bc_Dumper(aindex)
     volDesc =
        (struct tc_dumpDesc *)malloc(count * sizeof(struct tc_dumpDesc));
     if (!volDesc) {
-       com_err(whoami, BC_NOMEM, "");
+       afs_com_err(whoami, BC_NOMEM, NULL);
        ERROR(BC_NOMEM);
     }
 
@@ -152,11 +140,11 @@ bc_Dumper(aindex)
     printf("Starting dump\n");
     code = TC_PerformDump(tconn, tcdiPtr, &volArray, &dumpTaskPtr->dumpID);
     if (code) {
-       com_err(whoami, code, "; Failed to start dump");
+       afs_com_err(whoami, code, "; Failed to start dump");
        ERROR(code);
     }
 
-    com_err(whoami, 0, "Task %u: Dump (%s)", dumpTaskPtr->dumpID,
+    afs_com_err(whoami, 0, "Task %u: Dump (%s)", dumpTaskPtr->dumpID,
            tcdiPtr->dumpName);
 
     /* create status monitor block */
@@ -186,8 +174,8 @@ bc_Dumper(aindex)
  *     free the list of volumes used for dumps
  */
 
-freeDumpTaskVolumeList(vdptr)
-     struct bc_volumeDump *vdptr;
+void
+freeDumpTaskVolumeList(struct bc_volumeDump *vdptr)
 {
     struct bc_volumeDump *nextVdPtr;
 
@@ -206,9 +194,10 @@ freeDumpTaskVolumeList(vdptr)
  *     The other half of the dump/restore create process call. In bc_StartDmpRst, 
  *     we allocated a dumpTask entry. Here we do the task and then free the entry.
  */
-bc_DmpRstStart(aindex)
-     afs_int32 aindex;
+void *
+bc_DmpRstStart(void *param)
 {
+    afs_int32 aindex = (intptr_t)param;
     register struct bc_dumpTask *tdump;
     register afs_int32 code;
 
@@ -231,7 +220,7 @@ bc_DmpRstStart(aindex)
        free(tdump->portOffset);
     tdump->flags &= ~BC_DI_INUSE;
 
-    return code;
+    return (void *)(intptr_t)code;
 }
 
 /* bc_StartDmpRst
@@ -246,37 +235,25 @@ bc_DmpRstStart(aindex)
  *             bc_Restorer for doing restores
  */
 
-bc_StartDmpRst(aconfig, adname, avname, avolsToDump, adestServer,
-              adestPartition, afromDate, anewExt, aoldFlag, aparent, alevel,
-              aproc, ports, portCount, dsptr, append, dontExecute)
-     struct bc_config *aconfig;
-     char *adname;
-     char *avname;
-     struct bc_volumeDump *avolsToDump;
-     struct sockaddr_in *adestServer;
-     afs_int32 adestPartition;
-     afs_int32 afromDate;
-     char *anewExt;
-     int aoldFlag;
-     afs_int32 aparent, alevel;
-     int (*aproc) ();
-     afs_int32 *ports;
-     afs_int32 portCount;
-     struct bc_dumpSchedule *dsptr;
-     int append, dontExecute;
+int
+bc_StartDmpRst(struct bc_config *aconfig, char *adname, char *avname, 
+              struct bc_volumeDump *avolsToDump, 
+              struct sockaddr_in *adestServer,
+              afs_int32 adestPartition, afs_int32 afromDate, char *anewExt, 
+              int aoldFlag, afs_int32 aparent, afs_int32 alevel,
+              int (*aproc) (int), afs_int32 *ports, afs_int32 portCount, 
+              struct bc_dumpSchedule *dsptr, int append, int dontExecute)
 {
     register int i;
     register afs_int32 code;
-    char *junk;
-    int doit;
-    struct bc_volumeDump *tvol, *temp;
+    void *junk = NULL;
 
     for (i = 0; i < BC_MAXSIMDUMPS; i++)
        if (!(bc_dumpTasks[i].flags & BC_DI_INUSE))
            break;
 
     if (i >= BC_MAXSIMDUMPS) {
-       com_err(whoami, BC_NOTLOCKED,
+       afs_com_err(whoami, BC_NOTLOCKED,
                "All of the dump/restore slots are in use, try again later");
        return (BC_NOTLOCKED);
     }
@@ -312,10 +289,10 @@ bc_StartDmpRst(aconfig, adname, avname, avolsToDump, adestServer,
 
     code =
        LWP_CreateProcess(bc_DmpRstStart, 20480, LWP_NORMAL_PRIORITY,
-                         (void *)i, "helper", &junk);
+                         (void *)(intptr_t)i, "helper", junk);
     if (code) {
        bc_HandleMisc(code);
-       com_err(whoami, code, "; Can't start thread");
+       afs_com_err(whoami, code, "; Can't start thread");
 
        /* Cleanup allocated data structures */
        freeDumpTaskVolumeList(bc_dumpTasks[i].volumes);
@@ -347,9 +324,7 @@ bc_StartDmpRst(aconfig, adname, avname, avolsToDump, adestServer,
  */
 
 afs_int32
-bc_FindDumpSlot(dumpID, port)
-     afs_int32 dumpID;
-     afs_int32 port;
+bc_FindDumpSlot(afs_int32 dumpID, afs_int32 port)
 {
     int i;
 
@@ -369,11 +344,9 @@ bc_FindDumpSlot(dumpID, port)
  *     label a tape
  */
 
-bc_LabelTape(afsname, pname, size, config, port)
-     char *afsname, *pname;
-     struct bc_config *config;
-     afs_int32 port;
-     afs_int32 size;
+int
+bc_LabelTape(char *afsname, char *pname, afs_int32 size, 
+            struct bc_config *config, afs_int32 port)
 {
     struct rx_connection *tconn;
     afs_int32 code = 0;
@@ -394,7 +367,7 @@ bc_LabelTape(afsname, pname, size, config, port)
 
     code = TC_LabelTape(tconn, &label, &taskId);
     if (code) {
-       com_err(whoami, code, "; Failed to start labeltape");
+       afs_com_err(whoami, code, "; Failed to start labeltape");
        return (code);
     }
 
@@ -419,9 +392,8 @@ bc_LabelTape(afsname, pname, size, config, port)
  *     a tape
  */
 
-bc_ReadLabel(config, port)
-     struct bc_config *config;
-     afs_int32 port;
+int
+bc_ReadLabel(struct bc_config *config, afs_int32 port)
 {
     struct rx_connection *tconn;
     struct tc_tapeLabel label;
@@ -440,7 +412,7 @@ bc_ReadLabel(config, port)
            printf("Tape read was unlabelled\n");
            return 0;
        }
-       com_err(whoami, code, "; Failed to start readlabel");
+       afs_com_err(whoami, code, "; Failed to start readlabel");
        return (code);
     }
 
@@ -453,19 +425,17 @@ bc_ReadLabel(config, port)
        printf("Tape read was labelled : <NULL>  size : %u\n", label.size);
     } else if (!label.tapeId) {
        printf("Tape read was labelled : %s size : %lu Kbytes\n", tname,
-              label.size);
+              (long unsigned int) label.size);
     } else {
        printf("Tape read was labelled : %s (%lu) size : %lu Kbytes\n", tname,
-              label.tapeId, label.size);
+              (long unsigned int) label.tapeId, (long unsigned int) label.size);
     }
 
     return 0;
 }
 
-bc_ScanDumps(config, dbAddFlag, port)
-     struct bc_config *config;
-     afs_int32 dbAddFlag;
-     afs_int32 port;
+int
+bc_ScanDumps(struct bc_config *config, afs_int32 dbAddFlag, afs_int32 port)
 {
     struct rx_connection *tconn;
     statusP statusPtr;
@@ -478,7 +448,7 @@ bc_ScanDumps(config, dbAddFlag, port)
 
     code = TC_ScanDumps(tconn, dbAddFlag, &taskId);
     if (code) {
-       com_err(whoami, code, "; Failed to start scantape");
+       afs_com_err(whoami, code, "; Failed to start scantape");
        return (code);
     }
 
@@ -501,12 +471,9 @@ bc_ScanDumps(config, dbAddFlag, port)
 
 /* get a connection to the tape controller */
 afs_int32
-bc_GetConn(aconfig, aport, tconn)
-     struct bc_config *aconfig;
-     afs_int32 aport;
-     struct rx_connection **tconn;
+bc_GetConn(struct bc_config *aconfig, afs_int32 aport, 
+          struct rx_connection **tconn)
 {
-    afs_int32 code = 0;
     afs_uint32 host;
     unsigned short port;
     static struct rx_securityClass *rxsc;
@@ -544,8 +511,8 @@ bc_GetConn(aconfig, aport, tconn)
  *     -1 - not compatible
  */
 
-CheckTCVersion(tconn)
-     struct rx_connection *tconn;
+int
+CheckTCVersion(struct rx_connection *tconn)
 {
     struct tc_tcInfo tci;
     afs_int32 code;
@@ -560,16 +527,15 @@ CheckTCVersion(tconn)
     return 0;
 }
 
-ConnectButc(config, port, tconn)
-     struct bc_config *config;
-     afs_int32 port;
-     struct rx_connection **tconn;
+int
+ConnectButc(struct bc_config *config, afs_int32 port, 
+           struct rx_connection **tconn)
 {
     afs_int32 code;
 
     code = bc_GetConn(config, port, tconn);
     if (code) {
-       com_err(whoami, code,
+       afs_com_err(whoami, code,
                "; Can't connect to tape coordinator at port %d", port);
        return (code);
     }
@@ -579,10 +545,10 @@ ConnectButc(config, port, tconn)
        rx_DestroyConnection(*tconn);
 
        if (code == BC_VERSIONFAIL)
-           com_err(whoami, code,
+           afs_com_err(whoami, code,
                    "; Backup and butc are not the same version");
        else
-           com_err(whoami, code,
+           afs_com_err(whoami, code,
                    "; Can't access tape coordinator at port %d", port);
 
        return (code);