Skip to content

Commit

Permalink
libext2fs: use block_buf in ext2fs_alloc_block2() if it is provided
Browse files Browse the repository at this point in the history
If the caller supplies a buffer to ext2fs_alloc_block2(), use it
instead of calling ext2fs_zero_blocks2().

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
  • Loading branch information
tytso committed Dec 13, 2014
1 parent 0a92af2 commit bc57b12
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/ext2fs/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ errcode_t ext2fs_alloc_block2(ext2_filsys fs, blk64_t goal,
errcode_t retval;
blk64_t block;

if (block_buf)
memset(block_buf, 0, fs->blocksize);

if (fs->get_alloc_block) {
retval = (fs->get_alloc_block)(fs, goal, &block);
if (retval)
Expand All @@ -203,7 +200,11 @@ errcode_t ext2fs_alloc_block2(ext2_filsys fs, blk64_t goal,
goto fail;
}

retval = ext2fs_zero_blocks2(fs, block, 1, NULL, NULL);
if (block_buf) {
memset(block_buf, 0, fs->blocksize);
retval = io_channel_write_blk64(fs->io, block, 1, block_buf);
} else
retval = ext2fs_zero_blocks2(fs, block, 1, NULL, NULL);
if (retval)
goto fail;

Expand Down

0 comments on commit bc57b12

Please sign in to comment.