compare_snapshots(): Add const keyword.
[dss.git] / snap.c
diff --git a/snap.c b/snap.c
index 89d6004b6cb1731a73583d0d4ac07b469b3db916..71b7e30c5f9d248c4815d0c8d0e409eb6c41254e 100644 (file)
--- a/snap.c
+++ b/snap.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2008-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -101,7 +101,7 @@ static int is_snapshot(const char *dirname, int64_t now, int unit_interval,
        free(tmp);
        if (ret < 0)
                return 0;
-       if (num > now)
+       if (num > now || num < s->creation_time)
                return 0;
        s->completion_time = num;
        s->flags = SS_COMPLETE;
@@ -146,8 +146,8 @@ static int add_snapshot(const char *dirname, void *private)
 
 static int compare_snapshots(const void *a, const void *b)
 {
-       struct snapshot *s1 = *(struct snapshot **)a;
-       struct snapshot *s2 = *(struct snapshot **)b;
+       struct snapshot *s1 = *(struct snapshot * const *)a;
+       struct snapshot *s2 = *(struct snapshot * const *)b;
        return NUM_COMPARE(s2->creation_time, s1->creation_time);
 }
 
@@ -155,11 +155,10 @@ static int compare_snapshots(const void *a, const void *b)
 void get_snapshot_list(struct snapshot_list *sl, int unit_interval,
                int num_intervals)
 {
-       struct add_snapshot_data asd = {
-               .unit_interval = unit_interval,
-               .num_intervals = num_intervals,
-               .sl = sl
-       };
+       struct add_snapshot_data asd;
+       asd.unit_interval = unit_interval;
+       asd.num_intervals = num_intervals;
+       asd.sl = sl;
        sl->now = get_current_time();
        sl->num_snapshots = 0;
        sl->array_size = 0;