]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
super1.c: use ROUND_UP/ROUND_UP_PTR
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 20 Mar 2012 21:06:35 +0000 (08:06 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 20 Mar 2012 21:06:35 +0000 (08:06 +1100)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
super1.c

index 416ecfed9ed97d16cccda0a83c7b3cd590225869..0a3b6d0ebc819ecd5b736f9510540b10a2c022b0 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -179,7 +179,7 @@ static int aread(struct align_fd *afd, void *buf, int len)
                                "invalid block size\n");
                return -1;
        }
-       b = (char*)(((long)(abuf+4096))&~4095UL);
+       b = ROUND_UP_PTR((char *)abuf, 4096);
 
        for (iosize = 0; iosize < len; iosize += bsize)
                ;
@@ -212,7 +212,7 @@ static int awrite(struct align_fd *afd, void *buf, int len)
                                "invalid block size\n");
                return -1;
        }
-       b = (char*)(((long)(abuf+4096))&~4095UL);
+       b = ROUND_UP_PTR((char *)abuf, 4096);
 
        for (iosize = 0; iosize < len ; iosize += bsize)
                ;
@@ -1044,8 +1044,7 @@ static int store_super1(struct supertype *st, int fd)
        if (lseek64(fd, sb_offset << 9, 0)< 0LL)
                return 3;
 
-       sbsize = sizeof(*sb) + 2 * __le32_to_cpu(sb->max_dev);
-       sbsize = (sbsize+511)&(~511UL);
+       sbsize = ROUND_UP(sizeof(*sb) + 2 * __le32_to_cpu(sb->max_dev), 512);
 
        if (awrite(&afd, sb, sbsize) != sbsize)
                return 4;