I think this is ok; another "should never happen" scenario,
so the ASSERT seems fine.
Reviewed-by: Eric Sandeen <sandeen@xxxxxxxxxx>
On 12/2/15 5:19 AM, Vivek Trivedi wrote:
> add assert if block_to_bt returns NULL to avoid null pointer
> dereference and get backtrace.
> Reported by coverity.
>
> Signed-off-by: Vivek Trivedi <t.vivek@xxxxxxxxxxx>
> ---
> db/btblock.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/db/btblock.c b/db/btblock.c
> index 46140fc..91593f8 100644
> --- a/db/btblock.c
> +++ b/db/btblock.c
> @@ -180,6 +180,7 @@ btblock_key_offset(
> struct xfs_db_btree *bt = block_to_bt(block);
> int offset;
>
> + ASSERT(bt != NULL);
> ASSERT(startoff == 0);
> ASSERT(block->bb_level != 0);
>
> @@ -201,6 +202,7 @@ btblock_ptr_offset(
> int offset;
> int maxrecs;
>
> + ASSERT(bt != NULL);
> ASSERT(startoff == 0);
> ASSERT(block->bb_level != 0);
>
> @@ -225,6 +227,7 @@ btblock_rec_offset(
> struct xfs_db_btree *bt = block_to_bt(block);
> int offset;
>
> + ASSERT(bt != NULL);
> ASSERT(startoff == 0);
> ASSERT(block->bb_level == 0);
>
>
|