--- mdadm-3.1.1/Grow.c.warn 2010-02-08 01:26:18.000000000 -0500 +++ mdadm-3.1.1/Grow.c 2010-02-17 14:58:43.615427833 -0500 @@ -1096,7 +1096,7 @@ int Grow_reshape(char *devname, int fd, /* set them all just in case some old 'new_*' value * persists from some earlier problem */ - int err; + int err = 0; if (sysfs_set_num(sra, NULL, "chunk_size", nchunk) < 0) rv = 1, err = errno; if (!rv && sysfs_set_num(sra, NULL, "layout", nlayout) < 0) @@ -1269,6 +1269,7 @@ int grow_backup(struct mdinfo *sra, int odata = disks; int rv = 0; int i; + int ret; unsigned long long new_degraded; //printf("offset %llu\n", offset); if (level >= 4) @@ -1334,10 +1335,10 @@ int grow_backup(struct mdinfo *sra, ((char*)&bsb.sb_csum2)-((char*)&bsb)); lseek64(destfd[i], destoffsets[i] - 4096, 0); - write(destfd[i], &bsb, 512); + ret = write(destfd[i], &bsb, 512); if (destoffsets[i] > 4096) { lseek64(destfd[i], destoffsets[i]+stripes*chunk*odata, 0); - write(destfd[i], &bsb, 512); + ret = write(destfd[i], &bsb, 512); } fsync(destfd[i]); } @@ -1368,6 +1369,7 @@ int wait_backup(struct mdinfo *sra, int fd = sysfs_get_fd(sra, NULL, "sync_completed"); unsigned long long completed; int i; + int ret; if (fd < 0) return -1; @@ -1406,7 +1408,7 @@ int wait_backup(struct mdinfo *sra, bsb.sb_csum2 = bsb_csum((char*)&bsb, ((char*)&bsb.sb_csum2)-((char*)&bsb)); lseek64(destfd[i], destoffsets[i]-4096, 0); - write(destfd[i], &bsb, 512); + ret = write(destfd[i], &bsb, 512); fsync(destfd[i]); } return 0; @@ -1414,8 +1416,9 @@ int wait_backup(struct mdinfo *sra, static void fail(char *msg) { - write(2, msg, strlen(msg)); - write(2, "\n", 1); + int ret; + ret = write(2, msg, strlen(msg)); + ret = write(2, "\n", 1); exit(1); } @@ -1452,8 +1455,10 @@ static void validate(int afd, int bfd, u free(abuf); free(bbuf); abuflen = len; - posix_memalign((void**)&abuf, 4096, abuflen); - posix_memalign((void**)&bbuf, 4096, abuflen); + if (posix_memalign((void**)&abuf, 4096, abuflen) != 0) + fail("unable to allocate aligned memory"); + if (posix_memalign((void**)&bbuf, 4096, abuflen) != 0) + fail("unable to allocate aligned memory"); } lseek64(bfd, offset, 0); @@ -1486,7 +1491,11 @@ static void validate(int afd, int bfd, u free(bbuf); abuflen = len; abuf = malloc(abuflen); + if (abuf == NULL) + fail("unable to allocate memory"); bbuf = malloc(abuflen); + if (bbuf == NULL) + fail("unable to allocate memory"); } lseek64(bfd, offset+__le64_to_cpu(bsb2.devstart2)*512, 0); @@ -1508,7 +1517,8 @@ static int child_grow(int afd, struct md char *buf; int degraded = 0; - posix_memalign((void**)&buf, 4096, disks * chunk); + if (posix_memalign((void**)&buf, 4096, disks * chunk) != 0) + fail("unable to allocate aligned memory"); sysfs_set_num(sra, NULL, "suspend_hi", 0); sysfs_set_num(sra, NULL, "suspend_lo", 0); grow_backup(sra, 0, stripes, @@ -1536,7 +1546,8 @@ static int child_shrink(int afd, struct int rv; int degraded = 0; - posix_memalign((void**)&buf, 4096, disks * chunk); + if (posix_memalign((void**)&buf, 4096, disks * chunk) != 0) + fail("unable to allocate alinged memory"); start = sra->component_size - stripes * chunk/512; sysfs_set_num(sra, NULL, "sync_max", start); sysfs_set_str(sra, NULL, "sync_action", "reshape"); @@ -1575,7 +1586,8 @@ static int child_same_size(int afd, stru int degraded = 0; - posix_memalign((void**)&buf, 4096, disks * chunk); + if (posix_memalign((void**)&buf, 4096, disks * chunk) != 0) + fail("unable to allocate alinged memory"); sysfs_set_num(sra, NULL, "suspend_lo", 0); sysfs_set_num(sra, NULL, "suspend_hi", 0); --- mdadm-3.1.1/restripe.c.warn 2010-02-08 01:26:18.000000000 -0500 +++ mdadm-3.1.1/restripe.c 2010-02-17 14:58:43.615427833 -0500 @@ -565,7 +565,10 @@ int restore_stripes(int *dest, unsigned int data_disks = raid_disks - (level == 0 ? 0 : level <= 5 ? 1 : 2); - posix_memalign((void**)&stripe_buf, 4096, raid_disks * chunk_size); + if (posix_memalign((void**)&stripe_buf, 4096, raid_disks * chunk_size) != 0) { + fprintf(stderr, "unable to allocate aligned memory\n"); + exit(1); + } if (zero == NULL) { zero = malloc(chunk_size); if (zero) --- mdadm-3.1.1/mdmon.c.warn 2010-02-08 01:26:18.000000000 -0500 +++ mdadm-3.1.1/mdmon.c 2010-02-17 14:58:43.616427642 -0500 @@ -176,7 +176,7 @@ static void try_kill_monitor(pid_t pid, fl = fcntl(sock, F_GETFL, 0); fl &= ~O_NONBLOCK; fcntl(sock, F_SETFL, fl); - read(sock, buf, 100); + n = read(sock, buf, 100); } void remove_pidfile(char *devname) --- mdadm-3.1.1/super-intel.c.warn 2010-02-17 14:59:16.757425375 -0500 +++ mdadm-3.1.1/super-intel.c 2010-02-17 15:00:15.309803578 -0500 @@ -698,7 +698,7 @@ static void print_imsm_dev(struct imsm_d printf(" <-- %s", map_state_str[map->map_state]); printf("\n Checkpoint : %u (%llu)", __le32_to_cpu(dev->vol.curr_migr_unit), - blocks_per_migr_unit(dev)); + (unsigned long long)blocks_per_migr_unit(dev)); } printf("\n"); printf(" Dirty State : %s\n", dev->vol.dirty ? "dirty" : "clean");