salvaged: Fix "-parallel all<number>" parsing
[openafs.git] / src / vol / salvaged.c
index 6e4c87a..54c4a63 100644 (file)
 #endif
 #endif
 #else /* AFS_VFSINCL_ENV */
-#ifdef AFS_OSF_ENV
-#include <ufs/inode.h>
-#else /* AFS_OSF_ENV */
 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_DARWIN_ENV)
 #include <sys/inode.h>
 #endif
-#endif
 #endif /* AFS_VFSINCL_ENV */
 #endif /* AFS_SGI_ENV */
 #ifdef AFS_AIX_ENV
@@ -212,13 +208,16 @@ handleit(struct cmd_syndesc *opts, void *arock)
     cmd_OptionAsFlag(opts, OPT_inodes, &ListInodeOption);
     cmd_OptionAsFlag(opts, OPT_oktozap, &OKToZap);
     cmd_OptionAsFlag(opts, OPT_rootinodes, &ShowRootFiles);
+    cmd_OptionAsFlag(opts, OPT_salvagedirs, &RebuildDirs);
     cmd_OptionAsFlag(opts, OPT_blockreads, &forceR);
     if (cmd_OptionAsString(opts, OPT_parallel, &optstring) == 0) {
+       char *input = optstring;
        if (strncmp(optstring, "all", 3) == 0) {
            PartsPerDisk = 1;
+           input += 3;
        }
-       if (strlen(optstring) != 0) {
-           Parallel = atoi(optstring);
+       if (strlen(input) != 0) {
+           Parallel = atoi(input);
            if (Parallel < 1)
                Parallel = 1;
            if (Parallel > MAXPARALLEL) {
@@ -437,7 +436,7 @@ main(int argc, char **argv)
 
     err = cmd_Dispatch(argc, argv);
     Exit(err);
-    return 0; /* not reached */
+    AFS_UNREACHED(return 0);
 }
 
 static void
@@ -621,7 +620,7 @@ DoSalvageVolume(struct SalvageQueueNode * node, int slot)
      * another thread may have held the lock when fork was
      * called!
      */
-    memset(&memset, 0, sizeof(logopts));
+    memset(&logopts, 0, sizeof(logopts));
     logopts.lopt_dest = logDest_file;
     logopts.lopt_rotateStyle = logRotate_none;
     if (asprintf(&filename, "%s.%d",
@@ -707,7 +706,7 @@ SalvageChildReaperThread(void * args)
        opr_cv_broadcast(&worker_cv);
     }
 
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 static int
@@ -756,8 +755,8 @@ SalvageLogCleanupThread(void * arg)
        }
     }
 
-    opr_mutex_exit(&worker_lock);
-    return NULL;
+    AFS_UNREACHED(opr_mutex_exit(&worker_lock));
+    AFS_UNREACHED(return(NULL));
 }
 
 #define LOG_XFER_BUF_SIZE 65536
@@ -774,7 +773,7 @@ SalvageLogCleanup(int pid)
     }
 
     buf = calloc(1, LOG_XFER_BUF_SIZE);
-    if (buf != NULL) {
+    if (buf == NULL) {
        Log("Unable to write child log: out of memory\n");
        goto done;
     }