linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carlos Maiolino <cem@kernel.org>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH] xfs_db: fix broken logic in error path
Date: Fri, 28 Apr 2023 08:57:36 +0200	[thread overview]
Message-ID: <20230428065736.2kdhl7t6zoapedui@andromeda> (raw)
In-Reply-To: <20230427190233.GC59213@frogsfrogsfrogs>

On Thu, Apr 27, 2023 at 12:02:33PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> smatch complains proceeding into the if body if leaf is a null pointer:
> 
> check.c:3614 process_leaf_node_dir_v2_int() warn: variable dereferenced before check 'leaf' (see line 3518)
> 
> However, the logic here is misleading and broken -- what we're trying to
> do is switch between the v4 and v5 variants of the directory check.
> We're using @leaf3 being a null pointer (or not) to determine v4 vs. v5,
> so the "!" part of the comparison is correct, but the variable used
> (leaf) is not.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Looks correct.
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> ---
>  db/check.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/db/check.c b/db/check.c
> index 964756d0..fdf1f6a1 100644
> --- a/db/check.c
> +++ b/db/check.c
> @@ -3452,7 +3452,7 @@ process_leaf_node_dir_v2_int(
>  				 id->ino, dabno, stale,
>  				 be16_to_cpu(leaf3->hdr.stale));
>  		error++;
> -	} else if (!leaf && stale != be16_to_cpu(leaf->hdr.stale)) {
> +	} else if (!leaf3 && stale != be16_to_cpu(leaf->hdr.stale)) {
>  		if (!sflag || v)
>  			dbprintf(_("dir %lld block %d stale mismatch "
>  				 "%d/%d\n"),

-- 
Carlos Maiolino

      reply	other threads:[~2023-04-28  6:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <dVNtpBd6-O_AvMmCUgAc-vlNbr0x-1IgIQEPpoWYEipz8Jor5TfX6Z4vsKsLU3R38WCua0jJqVmmgSL_Rp62lA==@protonmail.internalid>
2023-04-27 19:02 ` [PATCH] xfs_db: fix broken logic in error path Darrick J. Wong
2023-04-28  6:57   ` Carlos Maiolino [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230428065736.2kdhl7t6zoapedui@andromeda \
    --to=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).