On Tue, Sep 03, 2019 at 05:00:35PM +0200, Johannes Thumshirn wrote:
> The callers of csum_tree_block_size() blindly assume we're only having
> crc32c as a possible checksum and thus pass in
> btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32] for the size argument of
> csum_tree_block_size().
> 
> Signed-off-by: Johannes Thumshirn <jthumsh...@suse.de>
> Reviewed-by: Nikolay Borisov <nbori...@suse.com>
> ---
>  mkfs/common.c | 14 +++++++-------
>  mkfs/common.h |  2 ++
>  2 files changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/mkfs/common.c b/mkfs/common.c
> index caca5e707233..b6e549b19272 100644
> --- a/mkfs/common.c
> +++ b/mkfs/common.c
> @@ -101,7 +101,7 @@ static int btrfs_create_tree_root(int fd, struct 
> btrfs_mkfs_config *cfg,
>       }
>  
>       /* generate checksum */
> -     csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0);
> +     csum_tree_block_size(buf, btrfs_csum_sizes[cfg->csum_type], 0);

I don't see where cfg->csum_type is initialized. The tests pass so
there's probably some implicit initialization to 0 that makes it work.

Reply via email to