public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Allison Henderson <allison.henderson@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/2] xfs: fix backwards endian conversion in scrub
Date: Mon, 25 Feb 2019 10:15:25 -0800	[thread overview]
Message-ID: <20190225181525.GF21626@magnolia> (raw)
In-Reply-To: <94dc02ba-ba62-012c-40b6-afb5d1bb201d@oracle.com>

On Mon, Feb 25, 2019 at 11:09:14AM -0700, Allison Henderson wrote:
> On 2/25/19 10:41 AM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Fix a backwards endian conversion of a constant.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >   fs/xfs/scrub/agheader.c |    2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > 
> > diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c
> > index 9d4e8293d37e..ddf06bfaa29d 100644
> > --- a/fs/xfs/scrub/agheader.c
> > +++ b/fs/xfs/scrub/agheader.c
> > @@ -399,7 +399,7 @@ xchk_agf_xref_cntbt(
> >   	if (!xchk_should_check_xref(sc, &error, &sc->sa.cnt_cur))
> >   		return;
> >   	if (!have) {
> > -		if (agf->agf_freeblks != be32_to_cpu(0))
> > +		if (agf->agf_freeblks != cpu_to_be32(0))
> >   			xchk_block_xref_set_corrupt(sc, sc->sa.agf_bp);
> >   		return;
> >   	}
> > 
> 
> Good catch.  I suppose there's not as much need to do the conversion if the
> value is 0?

Yep.  Fortunately, there's enough macro soup in cpu_to_be* (and all the
other endian conversion functions) to detect that the argument is a
constant value and transform it at compile time to avoid runtime
overhead.

> But I think the call helps to make clear that the value is supposed to
> be in big endian.

It's more or less to satisfy static checkers. :)

> Reviewed-by: Allison Henderson <allison.henderson@oracle.com>



--D

  reply	other threads:[~2019-02-25 18:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-25 17:41 [PATCH 1/2] xfs: fix uninitialized error variables Darrick J. Wong
2019-02-25 17:41 ` [PATCH 2/2] xfs: fix backwards endian conversion in scrub Darrick J. Wong
2019-02-25 18:09   ` Allison Henderson
2019-02-25 18:15     ` Darrick J. Wong [this message]
2019-02-25 17:53 ` [PATCH 1/2] xfs: fix uninitialized error variables Allison Henderson

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=20190225181525.GF21626@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=allison.henderson@oracle.com \
    --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