diff options
author | NeilBrown <neilb@suse.de> | 2009-04-29 11:44:02 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-04-29 11:44:02 +1000 |
commit | caa0f6c623214231380c5ef0de91b53cc43d1e0b (patch) | |
tree | f2a986154d8c5e4e72aca7754dc67d788105e3a6 /super1.c | |
parent | 667e66d329168f205f0f67674910287fed982d87 (diff) | |
download | mdadm-caa0f6c623214231380c5ef0de91b53cc43d1e0b.tar.gz mdadm-caa0f6c623214231380c5ef0de91b53cc43d1e0b.tar.xz mdadm-caa0f6c623214231380c5ef0de91b53cc43d1e0b.zip |
Fix gcc-4.4 compiler warning.
Apparently the dereferencing of a type-punned pointer breaks strict
aliasing rules. And we wouldn't want to do that.
So just make a different array of the appropriate type and use memcpy.
Resolves-Debian-bug: 505375
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'super1.c')
-rw-r--r-- | super1.c | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -612,10 +612,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info, if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 || read(rfd, sb->device_uuid, 16) != 16) { - *(__u32*)(sb->device_uuid) = random(); - *(__u32*)(sb->device_uuid+4) = random(); - *(__u32*)(sb->device_uuid+8) = random(); - *(__u32*)(sb->device_uuid+12) = random(); + __u32 r[4] = {random(), random(), random(), random()}; + memcpy(sb->device_uuid, r, 16); } sb->dev_roles[i] = @@ -735,10 +733,8 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info, else { if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 || read(rfd, sb->set_uuid, 16) != 16) { - *(__u32*)(sb->set_uuid) = random(); - *(__u32*)(sb->set_uuid+4) = random(); - *(__u32*)(sb->set_uuid+8) = random(); - *(__u32*)(sb->set_uuid+12) = random(); + __u32 r[4] = {random(), random(), random(), random()}; + memcpy(sb->set_uuid, r, 16); } if (rfd >= 0) close(rfd); } @@ -912,11 +908,10 @@ static int write_init_super1(struct supertype *st, if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 || read(rfd, sb->device_uuid, 16) != 16) { - *(__u32*)(sb->device_uuid) = random(); - *(__u32*)(sb->device_uuid+4) = random(); - *(__u32*)(sb->device_uuid+8) = random(); - *(__u32*)(sb->device_uuid+12) = random(); + __u32 r[4] = {random(), random(), random(), random()}; + memcpy(sb->device_uuid, r, 16); } + if (rfd >= 0) close(rfd); sb->events = 0; |