]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix some type-aliasing issues.
authorLuca Berra <bluca@comedia.it>
Fri, 17 Jun 2011 04:38:14 +0000 (14:38 +1000)
committerNeilBrown <neilb@suse.de>
Fri, 17 Jun 2011 04:38:14 +0000 (14:38 +1000)
Warnings for these are reported with -Wstrict-aliasing=2, and
avoiding the cast is certainly an improvement.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow.c
super0.c
super1.c

diff --git a/Grow.c b/Grow.c
index 7239d460986052161e1428f478a186d8f94c65b3..6e31b94b89be3ca6d295419d20558f2fea462230 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -3023,6 +3023,7 @@ int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
        int chunk = sra->array.chunk_size;
        struct mdinfo *sd;
        unsigned long stripes;
+       int uuid[4];
 
        /* set up the backup-super-block.  This requires the
         * uuid from the array.
@@ -3050,7 +3051,8 @@ int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
 
        memset(&bsb, 0, 512);
        memcpy(bsb.magic, "md_backup_data-1", 16);
-       st->ss->uuid_from_super(st, (int*)&bsb.set_uuid);
+       st->ss->uuid_from_super(st, uuid);
+       memcpy(bsb.set_uuid, uuid, 16);
        bsb.mtime = __cpu_to_le64(time(0));
        bsb.devstart2 = blocks;
 
index 440981bab9971320373af515f9882701ea60f8a1..4a165f9b7f30830dd47f53f5ef4018cf89dada0f 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -424,6 +424,7 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
         * ignored.
         */
        int rv = 0;
+       int uuid[4];
        mdp_super_t *sb = st->sb;
        if (strcmp(update, "sparc2.2")==0 ) {
                /* 2.2 sparc put the events in the wrong place
@@ -562,7 +563,8 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
                if (sb->state & (1<<MD_SB_BITMAP_PRESENT)) {
                        struct bitmap_super_s *bm;
                        bm = (struct bitmap_super_s*)(sb+1);
-                       uuid_from_super0(st, (int*)bm->uuid);
+                       uuid_from_super0(st, uuid);
+                       memcpy(bm->uuid, uuid, 16);
                }
        } else if (strcmp(update, "no-bitmap") == 0) {
                sb->state &= ~(1<<MD_SB_BITMAP_PRESENT);
@@ -988,6 +990,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
        int chunk = *chunkp;
        mdp_super_t *sb = st->sb;
        bitmap_super_t *bms = (bitmap_super_t*)(((char*)sb) + MD_SB_BYTES);
+       int uuid[4];
 
 
        min_chunk = 4096; /* sub-page chunks don't work yet.. */
@@ -1011,7 +1014,8 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
        memset(bms, 0, sizeof(*bms));
        bms->magic = __cpu_to_le32(BITMAP_MAGIC);
        bms->version = __cpu_to_le32(major);
-       uuid_from_super0(st, (int*)bms->uuid);
+       uuid_from_super0(st, uuid);
+       memcpy(bms->uuid, uuid, 16);
        bms->chunksize = __cpu_to_le32(chunk);
        bms->daemon_sleep = __cpu_to_le32(delay);
        bms->sync_size = __cpu_to_le64(size);
index 410436c8f734f20998f4b138fdd3970a46b1a809..09be351edbfb64875c3d47a298a8f6326b911830 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -1493,6 +1493,7 @@ add_internal_bitmap1(struct supertype *st,
        int room = 0;
        struct mdp_superblock_1 *sb = st->sb;
        bitmap_super_t *bms = (bitmap_super_t*)(((char*)sb) + 1024);
+       int uuid[4];
 
        switch(st->minor_version) {
        case 0:
@@ -1580,7 +1581,8 @@ add_internal_bitmap1(struct supertype *st,
        memset(bms, 0, sizeof(*bms));
        bms->magic = __cpu_to_le32(BITMAP_MAGIC);
        bms->version = __cpu_to_le32(major);
-       uuid_from_super1(st, (int*)bms->uuid);
+       uuid_from_super1(st, uuid);
+       memcpy(bms->uuid, uuid, 16);
        bms->chunksize = __cpu_to_le32(chunk);
        bms->daemon_sleep = __cpu_to_le32(delay);
        bms->sync_size = __cpu_to_le64(size);