summaryrefslogtreecommitdiff
path: root/mdadm/mdadm-2.6.9-gcc44.patch
blob: bb9f7fa37bc07882bdc9c93c37c820976cfb7825 (plain)
    1 From caa0f6c623214231380c5ef0de91b53cc43d1e0b Mon Sep 17 00:00:00 2001
    2 From: NeilBrown <neilb@suse.de>
    3 Date: Wed, 29 Apr 2009 11:44:02 +1000
    4 Subject: [PATCH] Fix gcc-4.4 compiler warning.
    5 
    6 Apparently the dereferencing of a type-punned pointer breaks strict
    7 aliasing rules.   And we wouldn't want to do that.
    8 So just make a different array of the appropriate type and use memcpy.
    9 
   10 Resolves-Debian-bug: 505375
   11 Signed-off-by: NeilBrown <neilb@suse.de>
   12 ---
   13  bitmap.c |   28 +++++++++++++++-------------
   14  super1.c |   19 +++++++------------
   15  2 files changed, 22 insertions(+), 25 deletions(-)
   16 
   17 diff --git a/bitmap.c b/bitmap.c
   18 index 352be5d..5618087 100644
   19 --- a/bitmap.c
   20 +++ b/bitmap.c
   21 @@ -270,6 +270,7 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
   22  	int rv = 1;
   23  	char buf[64];
   24  	int swap;
   25 +	__u32 uuid32[4];
   26  
   27  	info = bitmap_file_read(filename, brief, &st);
   28  	if (!info)
   29 @@ -297,19 +298,20 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
   30  #else
   31  		swap = 1;
   32  #endif
   33 -	if (swap) {
   34 -	printf("            UUID : %08x:%08x:%08x:%08x\n",
   35 -					swapl(*(__u32 *)(sb->uuid+0)),
   36 -					swapl(*(__u32 *)(sb->uuid+4)),
   37 -					swapl(*(__u32 *)(sb->uuid+8)),
   38 -					swapl(*(__u32 *)(sb->uuid+12)));
   39 -	} else {
   40 -	printf("            UUID : %08x:%08x:%08x:%08x\n",
   41 -					*(__u32 *)(sb->uuid+0),
   42 -					*(__u32 *)(sb->uuid+4),
   43 -					*(__u32 *)(sb->uuid+8),
   44 -					*(__u32 *)(sb->uuid+12));
   45 -	}
   46 +	memcpy(uuid32, sb->uuid, 16);
   47 +	if (swap)
   48 +		printf("            UUID : %08x:%08x:%08x:%08x\n",
   49 +		       swapl(uuid32[0]),
   50 +		       swapl(uuid32[1]),
   51 +		       swapl(uuid32[2]),
   52 +		       swapl(uuid32[3]));
   53 +	else
   54 +		printf("            UUID : %08x:%08x:%08x:%08x\n",
   55 +		       uuid32[0],
   56 +		       uuid32[1],
   57 +		       uuid32[2],
   58 +		       uuid32[3]);
   59 +
   60  	printf("          Events : %llu\n", (unsigned long long)sb->events);
   61  	printf("  Events Cleared : %llu\n", (unsigned long long)sb->events_cleared);
   62  	printf("           State : %s\n", bitmap_state(sb->state));
   63 diff --git a/super1.c b/super1.c
   64 index 1342412..037c5eb 100644
   65 --- a/super1.c
   66 +++ b/super1.c
   67 @@ -612,10 +612,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
   68  
   69  		if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 ||
   70  		    read(rfd, sb->device_uuid, 16) != 16) {
   71 -			*(__u32*)(sb->device_uuid) = random();
   72 -			*(__u32*)(sb->device_uuid+4) = random();
   73 -			*(__u32*)(sb->device_uuid+8) = random();
   74 -			*(__u32*)(sb->device_uuid+12) = random();
   75 +			__u32 r[4] = {random(), random(), random(), random()};
   76 +			memcpy(sb->device_uuid, r, 16);
   77  		}
   78  
   79  		sb->dev_roles[i] =
   80 @@ -735,10 +733,8 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info,
   81  	else {
   82  		if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 ||
   83  		    read(rfd, sb->set_uuid, 16) != 16) {
   84 -			*(__u32*)(sb->set_uuid) = random();
   85 -			*(__u32*)(sb->set_uuid+4) = random();
   86 -			*(__u32*)(sb->set_uuid+8) = random();
   87 -			*(__u32*)(sb->set_uuid+12) = random();
   88 +			__u32 r[4] = {random(), random(), random(), random()};
   89 +			memcpy(sb->set_uuid, r, 16);
   90  		}
   91  		if (rfd >= 0) close(rfd);
   92  	}
   93 @@ -912,11 +908,10 @@ static int write_init_super1(struct supertype *st,
   94  
   95  	if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 ||
   96  	    read(rfd, sb->device_uuid, 16) != 16) {
   97 -		*(__u32*)(sb->device_uuid) = random();
   98 -		*(__u32*)(sb->device_uuid+4) = random();
   99 -		*(__u32*)(sb->device_uuid+8) = random();
  100 -		*(__u32*)(sb->device_uuid+12) = random();
  101 +		__u32 r[4] = {random(), random(), random(), random()};
  102 +		memcpy(sb->device_uuid, r, 16);
  103  	}
  104 +	
  105  	if (rfd >= 0) close(rfd);
  106  	sb->events = 0;
  107  
  108 -- 
  109 1.6.2

Generated by cgit