]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - repair/progress.c
xfsprogs: make static things static
[thirdparty/xfsprogs-dev.git] / repair / progress.c
index c6630e524fa1293b97457e0487c755fa74bef974..5ee08229c07ecf682cf6d8a51926249bb6c0bfff 100644 (file)
@@ -1,5 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 
-#include <libxfs.h>
+#include "libxfs.h"
 #include "globals.h"
 #include "progress.h"
 #include "err_protos.h"
@@ -75,18 +76,18 @@ progress_rpt_t progress_rpt_reports[] = {
 {FMT2, N_("moving disconnected inodes to lost+found"),         /* 12 */
        &rpt_fmts[FMT2], &rpt_types[TYPE_INODE]},
 {FMT1, N_("verify and correct link counts"),                   /* 13 */
-       &rpt_fmts[FMT1], &rpt_types[TYPE_INODE]},
+       &rpt_fmts[FMT1], &rpt_types[TYPE_AG]},
 {FMT1, N_("verify link counts"),                               /* 14 */
-       &rpt_fmts[FMT1], &rpt_types[TYPE_INODE]}
+       &rpt_fmts[FMT1], &rpt_types[TYPE_AG]}
 };
 
-pthread_t      report_thread;
+static pthread_t       report_thread;
 
 typedef struct msg_block_s {
        pthread_mutex_t mutex;
        progress_rpt_t  *format;
-       __uint64_t      *done;
-       __uint64_t      *total;
+       uint64_t        *done;
+       uint64_t        *total;
        int             count;
        int             interval;
 } msg_block_t;
@@ -96,14 +97,14 @@ typedef struct phase_times_s {
        time_t          start;
        time_t          end;
        time_t          duration;
-       __uint64_t      item_counts[4];
+       uint64_t        item_counts[4];
 } phase_times_t;
 static phase_times_t phase_times[8];
 
 static void *progress_rpt_thread(void *);
 static int current_phase;
 static int running;
-static __uint64_t prog_rpt_total;
+static uint64_t prog_rpt_total;
 
 void
 init_progress_rpt (void)
@@ -113,17 +114,18 @@ init_progress_rpt (void)
         *  allocate the done vector
         */
 
-       if ((prog_rpt_done = (__uint64_t *)
-               malloc(sizeof(__uint64_t)*glob_agcount)) == NULL ) {
+       if ((prog_rpt_done = (uint64_t *)
+               malloc(sizeof(uint64_t)*glob_agcount)) == NULL) {
                do_error(_("cannot malloc pointer to done vector\n"));
        }
-       bzero(prog_rpt_done, sizeof(__uint64_t)*glob_agcount);
+       bzero(prog_rpt_done, sizeof(uint64_t)*glob_agcount);
 
        /*
         *  Setup comm block, start the thread
         */
 
        pthread_mutex_init(&global_msgs.mutex, NULL);
+       global_msgs.format = NULL;
        global_msgs.count = glob_agcount;
        global_msgs.interval = report_interval;
        global_msgs.done   = prog_rpt_done;
@@ -164,10 +166,14 @@ progress_rpt_thread (void *p)
        timer_t timerid;
        struct itimerspec timespec;
        char *msgbuf;
-       __uint64_t *donep;
-       __uint64_t sum;
+       uint64_t *donep;
+       uint64_t sum;
        msg_block_t *msgp = (msg_block_t *)p;
-       __uint64_t percent;
+       uint64_t percent;
+
+       /* It's possible to get here very early w/ no progress msg set */
+       if (!msgp->format)
+               return NULL;
 
        if ((msgbuf = (char *)malloc(DURATION_BUF_SIZE)) == NULL)
                do_error (_("progress_rpt: cannot malloc progress msg buffer\n"));
@@ -178,10 +184,9 @@ progress_rpt_thread (void *p)
         * Specify a repeating timer that fires each MSG_INTERVAL seconds.
         */
 
+       memset(&timespec, 0, sizeof(timespec));
        timespec.it_value.tv_sec = msgp->interval;
-       timespec.it_value.tv_nsec = 0;
        timespec.it_interval.tv_sec = msgp->interval;
-       timespec.it_interval.tv_nsec = 0;
 
        if (timer_create (CLOCK_REALTIME, NULL, &timerid))
                do_error(_("progress_rpt: cannot create timer\n"));
@@ -261,7 +266,7 @@ progress_rpt_thread (void *p)
                                current_phase, duration(elapsed, msgbuf),
                                (int) (60*sum/(elapsed)), *msgp->format->type);
                        do_log(
-                               _("\t- %02d:%02d:%02d: Phase %d: %llu%% done - estimated remaining time %s\n"),
+       _("\t- %02d:%02d:%02d: Phase %d: %" PRIu64 "%% done - estimated remaining time %s\n"),
                                tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
                                current_phase, percent,
                                duration((int) ((*msgp->total - sum) * (elapsed)/sum), msgbuf));
@@ -282,7 +287,7 @@ progress_rpt_thread (void *p)
 }
 
 int
-set_progress_msg (int report, __uint64_t total)
+set_progress_msg(int report, uint64_t total)
 {
 
        if (!ag_stride)
@@ -296,7 +301,7 @@ set_progress_msg (int report, __uint64_t total)
 
        /* reset all the accumulative totals */
        if (prog_rpt_done)
-               bzero(prog_rpt_done, sizeof(__uint64_t)*glob_agcount);
+               bzero(prog_rpt_done, sizeof(uint64_t)*glob_agcount);
 
        if (pthread_mutex_unlock(&global_msgs.mutex))
                do_error(_("set_progress_msg: cannot unlock progress mutex\n"));
@@ -304,14 +309,14 @@ set_progress_msg (int report, __uint64_t total)
        return (0);
 }
 
-__uint64_t
+uint64_t
 print_final_rpt(void)
 {
        int i;
        struct tm *tmp;
        time_t now;
-       __uint64_t *donep;
-       __uint64_t sum;
+       uint64_t *donep;
+       uint64_t sum;
        msg_block_t     *msgp = &global_msgs;
        char            msgbuf[DURATION_BUF_SIZE];
 
@@ -360,7 +365,7 @@ print_final_rpt(void)
        return(sum);
 }
 
-void
+static void
 timediff(int phase)
 {
        phase_times[phase].duration =