]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super0.c
Compile with -Wextra by default
[thirdparty/mdadm.git] / super0.c
index a0c7eb4f15db90063ccffdf9055ff0ac70e9bf05..ae3e8855193f9d6183776f346779b6d29ba5ef5c 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -113,7 +113,7 @@ static void examine_super0(struct supertype *st, char *homehost)
        printf("  Creation Time : %.24s\n", ctime(&atime));
        c=map_num(pers, sb->level);
        printf("     Raid Level : %s\n", c?c:"-unknown-");
-       if ((int)sb->level >= 0) {
+       if ((int)sb->level > 0) {
                int ddsks=0;
                printf("  Used Dev Size : %d%s\n", sb->size,
                       human_size((long long)sb->size<<10));
@@ -389,7 +389,7 @@ static void getinfo_super0(struct supertype *st, struct mdinfo *info)
        /* work_disks is calculated rather than read directly */
        for (i=0; i < MD_SB_DISKS; i++)
                if ((sb->disks[i].state & (1<<MD_DISK_SYNC)) &&
-                   (sb->disks[i].raid_disk < info->array.raid_disks) &&
+                   (sb->disks[i].raid_disk < (unsigned)info->array.raid_disks) &&
                    (sb->disks[i].state & (1<<MD_DISK_ACTIVE)) &&
                    !(sb->disks[i].state & (1<<MD_DISK_FAULTY)))
                        working ++;
@@ -427,7 +427,7 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
                                devname, info->array.md_minor);
        }
        if (strcmp(update, "summaries") == 0) {
-               int i;
+               unsigned int i;
                /* set nr_disks, active_disks, working_disks,
                 * failed_disks, spare_disks based on disks[]
                 * array in superblock.
@@ -487,7 +487,7 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
                         */
                        add = (1<<MD_DISK_SYNC);
                if (((sb->disks[d].state & ~mask) | add)
-                   != info->disk.state) {
+                   != (unsigned)info->disk.state) {
                        sb->disks[d].state = info->disk.state | wonly;
                        rv = 1;
                }
@@ -593,7 +593,7 @@ static int init_super0(struct supertype *st, mdu_array_info_t *info,
        sb->gvalid_words = 0; /* ignored */
        sb->ctime = time(0);
        sb->level = info->level;
-       if (size != info->size)
+       if (size != (unsigned long long)info->size)
                return 0;
        sb->size = info->size;
        sb->nr_disks = info->nr_disks;
@@ -922,6 +922,9 @@ static struct supertype *match_metadata_desc0(char *arg)
        while (arg[0] == '0' && arg[1] == '0')
                arg++;
        if (strcmp(arg, "0") == 0 ||
+#ifdef DEFAULT_OLD_METADATA /* ifndef in super1.c */
+           strcmp(arg, "default") == 0 ||
+#endif /* DEFAULT_OLD_METADATA */
            strcmp(arg, "0.90") == 0 ||
            strcmp(arg, "") == 0 /* no metadata  - i.e. non_persistent */
                )
@@ -959,7 +962,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
         * size is in sectors,  chunk is in bytes !!!
         */
        unsigned long long bits;
-       unsigned long long max_bits = 60*1024*8;
+       unsigned long long max_bits = (60*1024 - sizeof(bitmap_super_t))*8;
        unsigned long long min_chunk;
        int chunk = *chunkp;
        mdp_super_t *sb = st->sb;
@@ -979,7 +982,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
                chunk = min_chunk;
                if (chunk < 64*1024*1024)
                        chunk = 64*1024*1024;
-       } else if (chunk < min_chunk)
+       } else if ((unsigned long long)chunk < min_chunk)
                return 0; /* chunk size too small */
 
        sb->state |= (1<<MD_SB_BITMAP_PRESENT);
@@ -1045,7 +1048,7 @@ static int write_bitmap0(struct supertype *st, int fd)
 
        memset(buf, 0xff, 4096);
        memcpy(buf,  ((char*)sb)+MD_SB_BYTES, sizeof(bitmap_super_t));
-       towrite = 64*1024;
+       towrite = 60*1024;
        while (towrite > 0) {
                n = towrite;
                if (n > 4096)