]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super1.c
Release 2.5.1
[thirdparty/mdadm.git] / super1.c
index 9f07ddcc53efcf794368453faf21f6c8940a41e5..9dc66448d8c0fe1148f9b1e09612e345307c6238 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -104,7 +104,7 @@ struct mdp_superblock_1 {
 #define        MD_FEATURE_ALL                  (1|2|4)
 
 #ifndef offsetof
-#define offsetof(t,f) ((int)&(((t*)0)->f))
+#define offsetof(t,f) ((size_t)&(((t*)0)->f))
 #endif
 static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb)
 {
@@ -712,10 +712,11 @@ static int store_super1(struct supertype *st, int fd, void *sbv)
 
        if (sb->feature_map & __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET)) {
                struct bitmap_super_s *bm = (struct bitmap_super_s*)
-                       ((char*)sb)+1024;
+                       (((char*)sb)+1024);
                if (__le32_to_cpu(bm->magic) == BITMAP_MAGIC) {
                        locate_bitmap1(st, fd, sbv);
-                       write(fd, bm, sizeof(*bm));
+                       if (write(fd, bm, sizeof(*bm)) != sizeof(*bm))
+                           return 5;
                }
        }
        fsync(fd);