butc: avoid testing stack garbage; remove dead initializer
[openafs.git] / src / butc / tcudbprocs.c
index 82b3d04..b4424d8 100644 (file)
 #include <afsconfig.h>
 #include <afs/param.h>
 
+#include <afs/procmgmt.h>
+#include <roken.h>
+
 #ifdef IGNORE_SOME_GCC_WARNINGS
 # pragma GCC diagnostic warning "-Wimplicit-function-declaration"
 #endif
 
-#include <sys/types.h>
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#include <io.h>
-#else
-#include <sys/time.h>
-#include <sys/file.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#endif
-#include <errno.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <afs/afsint.h>
-#include <stdio.h>
-#include <string.h>
-#include <afs/procmgmt.h>
 #include <afs/afs_assert.h>
 #include <afs/prs_fs.h>
-#include <fcntl.h>
 #include <afs/nfs.h>
 #include <lwp.h>
 #include <lock.h>
@@ -54,6 +39,7 @@
 #include <afs/butm_prototypes.h>
 #include <afs/budb_prototypes.h>
 #include <afs/afsutil.h>
+
 #include "butc_internal.h"
 #include "error_macros.h"
 
@@ -139,7 +125,6 @@ GetDBTape(afs_int32 taskId, Date expires, struct butm_tapeInfo *tapeInfoPtr,
     char tapeName[BU_MAXTAPELEN];
     char strlevel[5];
     struct timeval tp;
-    struct timezone tzp;
     afs_int32 curTime;
     int tapecount = 1;
 
@@ -253,7 +238,7 @@ GetDBTape(afs_int32 taskId, Date expires, struct butm_tapeInfo *tapeInfoPtr,
             */
            else {
                /* Check the tape's expiration date. Use the expiration on the label */
-               gettimeofday(&tp, &tzp);
+               gettimeofday(&tp, NULL);
                curTime = tp.tv_sec;
                if (curTime < oldTapeLabel.expirationDate) {
                    TLog(taskId, "This tape has not expired\n");
@@ -643,7 +628,7 @@ void *
 saveDbToTape(void *param)
 {
     struct saveDbIf *saveDbIfPtr = (struct saveDbIf *)param;
-    afs_int32 code = 0;
+    afs_int32 code;
     afs_int32 i;
     int wroteLabel;
     afs_uint32 taskId;
@@ -655,8 +640,10 @@ saveDbToTape(void *param)
     extern struct deviceSyncNode *deviceLatch;
     extern struct tapeConfig globalTapeConfig;
 
+    afs_pthread_setname_self("Db save");
     expires = (saveDbIfPtr->archiveTime ? NEVERDATE : 0);
     taskId = saveDbIfPtr->taskId;
+    dumpEntry.id = 0;
 
     setStatus(taskId, DRIVE_WAIT);
     EnterDeviceQueue(deviceLatch);     /* lock tape device */
@@ -1037,6 +1024,7 @@ restoreDbFromTape(void *param)
     extern struct tapeConfig globalTapeConfig;
     extern struct deviceSyncNode *deviceLatch;
 
+    afs_pthread_setname_self("Db restore");
     setStatus(taskId, DRIVE_WAIT);
     EnterDeviceQueue(deviceLatch);     /* lock tape device */
     clearStatus(taskId, DRIVE_WAIT);
@@ -1134,6 +1122,7 @@ KeepAlive(void *unused)
 
     extern struct udbHandleS udbHandle;
 
+    afs_pthread_setname_self("Keep-alive");
     while (1) {
 #ifdef AFS_PTHREAD_ENV
        sleep(5);
@@ -1452,11 +1441,7 @@ restoreText(struct butm_tapeInfo *tapeInfo,
 
     /* open the text file */
     sprintf(filename, "%s/bu_XXXXXX", gettmpdir());
-#if defined (HAVE_MKSTEMP)
     fid = mkstemp(filename);
-#else
-    fid = open(mktemp(filename), O_RDWR | O_CREAT | O_EXCL, 0600);
-#endif
     if (fid < 0) {
        ErrorLog(0, rstTapeInfoPtr->taskId, errno, 0,
                 "Can't open temporary text file: %s\n", filename);