]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mkfs.minix: fix write_all() usage
authorKarel Zak <kzak@redhat.com>
Tue, 16 Aug 2011 22:29:39 +0000 (00:29 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 16 Aug 2011 22:29:39 +0000 (00:29 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fsck.minix.c
disk-utils/mkfs.minix.c

index 49108d3c672f8a49391fc2fd61ed750e3423a3e9..0c6cfa4c59d90d2a36d6c7f446fe63617f0cbd74 100644 (file)
@@ -524,18 +524,14 @@ write_tables(void) {
        unsigned long buffsz = get_inode_buffer_size();
        unsigned long imaps = get_nimaps();
        unsigned long zmaps = get_nzmaps();
-       ssize_t rc;
 
-       rc = write_all(IN, inode_map, imaps * MINIX_BLOCK_SIZE);
-       if (rc < 0 || imaps * MINIX_BLOCK_SIZE != (size_t) rc)
+       if (write_all(IN, inode_map, imaps * MINIX_BLOCK_SIZE))
                die(_("Unable to write inode map"));
 
-       rc = write_all(IN, zone_map, zmaps * MINIX_BLOCK_SIZE);
-       if (rc < 0 || zmaps * MINIX_BLOCK_SIZE != (size_t) rc)
+       if (write_all(IN, zone_map, zmaps * MINIX_BLOCK_SIZE))
                die(_("Unable to write zone map"));
 
-       rc = write(IN,inode_buffer, buffsz);
-       if (rc < 0 || buffsz != (size_t) rc)
+       if (write_all(IN, inode_buffer, buffsz))
                die(_("Unable to write inodes"));
 }
 
index f842b0bf0ca87feb0373c3b201ed6316325a5035..257bf88995147995d721e004ad509c9fd5616e11 100644 (file)
@@ -187,7 +187,6 @@ static void write_tables(void) {
        unsigned long imaps = get_nimaps();
        unsigned long zmaps = get_nzmaps();
        unsigned long buffsz = get_inode_buffer_size();
-       ssize_t rc;
 
        /* Mark the super block valid. */
        super_set_state();
@@ -195,37 +194,29 @@ static void write_tables(void) {
        if (lseek(DEV, 0, SEEK_SET))
                err(MKFS_ERROR, _("%s: seek to boot block failed "
                                   " in write_tables"), device_name);
-       rc = write_all(DEV, boot_block_buffer, 512);
-       if (512 != rc)
+       if (write_all(DEV, boot_block_buffer, 512))
                err(MKFS_ERROR, _("%s: unable to clear boot sector"), device_name);
        if (MINIX_BLOCK_SIZE != lseek(DEV, MINIX_BLOCK_SIZE, SEEK_SET))
                err(MKFS_ERROR, _("%s: seek failed in write_tables"), device_name);
 
-       rc = write_all(DEV, super_block_buffer, MINIX_BLOCK_SIZE);
-       if (rc < 0 || MINIX_BLOCK_SIZE != (size_t) rc)
+       if (write_all(DEV, super_block_buffer, MINIX_BLOCK_SIZE))
                err(MKFS_ERROR, _("%s: unable to write super-block"), device_name);
 
-       rc = write_all(DEV, inode_map, imaps * MINIX_BLOCK_SIZE);
-       if (rc < 0 || imaps * MINIX_BLOCK_SIZE != (size_t) rc)
+       if (write_all(DEV, inode_map, imaps * MINIX_BLOCK_SIZE))
                err(MKFS_ERROR, _("%s: unable to write inode map"), device_name);
 
-       rc = write_all(DEV, zone_map, zmaps * MINIX_BLOCK_SIZE);
-       if (rc < 0 || zmaps * MINIX_BLOCK_SIZE != (size_t) rc)
+       if (write_all(DEV, zone_map, zmaps * MINIX_BLOCK_SIZE))
                err(MKFS_ERROR, _("%s: unable to write zone map"), device_name);
 
-       rc = write_all(DEV, inode_buffer, buffsz);
-       if (rc < 0 || buffsz != (size_t) rc)
+       if (write_all(DEV, inode_buffer, buffsz))
                err(MKFS_ERROR, _("%s: unable to write inodes"), device_name);
 }
 
 static void write_block(int blk, char * buffer) {
-       ssize_t rc;
-
        if (blk*MINIX_BLOCK_SIZE != lseek(DEV, blk*MINIX_BLOCK_SIZE, SEEK_SET))
                errx(MKFS_ERROR, _("%s: seek failed in write_block"), device_name);
 
-       rc = write_all(DEV, buffer, MINIX_BLOCK_SIZE);
-       if (rc < 0 && MINIX_BLOCK_SIZE != (size_t) rc)
+       if (write_all(DEV, buffer, MINIX_BLOCK_SIZE))
                errx(MKFS_ERROR, _("%s: write failed in write_block"), device_name);
 }