From: Dave Chinner <david@fromorbit.com>
To: Carlos Maiolino <cmaiolino@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/4] Get rid of XFS_BUF_PTR() macro
Date: Wed, 7 Mar 2018 09:22:10 +1100 [thread overview]
Message-ID: <20180306222210.GL18129@dastard> (raw)
In-Reply-To: <20180306130053.13958-2-cmaiolino@redhat.com>
On Tue, Mar 06, 2018 at 02:00:50PM +0100, Carlos Maiolino wrote:
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
.....
> @@ -275,9 +275,9 @@ newfile(
> d = XFS_FSB_TO_DADDR(mp, map.br_startblock);
> bp = libxfs_trans_get_buf(logit ? tp : 0, mp->m_dev, d,
> nb << mp->m_blkbb_log, 0);
> - memmove(XFS_BUF_PTR(bp), buf, len);
> + memmove(bp->b_addr, buf, len);
> if (len < XFS_BUF_COUNT(bp))
> - memset(XFS_BUF_PTR(bp) + len, 0, XFS_BUF_COUNT(bp) - len);
> + memset(bp->b_addr + len, 0, XFS_BUF_COUNT(bp) - len);
Bug there. pointer arithmetic changed, needs (char *) cast.
> /* OK, now write the superblock... */
> buf = libxfs_getbuf(mp->m_ddev_targp, XFS_SB_DADDR, XFS_FSS_TO_BB(mp, 1));
> buf->b_ops = &xfs_sb_buf_ops;
> - memset(XFS_BUF_PTR(buf), 0, cfg->sectorsize);
> - libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
> + memset(buf->b_addr, 0, cfg->sectorsize);
> + libxfs_sb_to_disk((void *)buf->b_addr, sbp);
Kill the cast - b_addr is already a void *
> @@ -3382,8 +3382,8 @@ initialise_ag_headers(
> XFS_AG_DADDR(mp, agno, XFS_SB_DADDR),
> XFS_FSS_TO_BB(mp, 1));
> buf->b_ops = &xfs_sb_buf_ops;
> - memset(XFS_BUF_PTR(buf), 0, cfg->sectorsize);
> - libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
> + memset(buf->b_addr, 0, cfg->sectorsize);
> + libxfs_sb_to_disk((void *)buf->b_addr, sbp);
ditto.
> +++ b/repair/agheader.c
> @@ -290,8 +290,8 @@ secondary_sb_whack(
> + sizeof(sb->sb_dirblklog);
>
> /* Check the buffer we read from disk for garbage outside size */
> - for (ip = XFS_BUF_PTR(sbuf) + size;
> - ip < XFS_BUF_PTR(sbuf) + mp->m_sb.sb_sectsize;
> + for (ip = sbuf->b_addr + size;
> + ip < (char *)sbuf->b_addr + mp->m_sb.sb_sectsize;
Looks like another pointer math bug there...
> ip++) {
> if (*ip) {
> do_bzero = 1;
> @@ -314,7 +314,7 @@ secondary_sb_whack(
> memcpy(&tmpuuid, &sb->sb_meta_uuid, sizeof(uuid_t));
> memset((void *)((intptr_t)sb + size), 0,
> mp->m_sb.sb_sectsize - size);
> - memset(XFS_BUF_PTR(sbuf) + size, 0,
> + memset(sbuf->b_addr + size, 0,
And another.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2018-03-06 22:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-06 13:00 [PATCH 0/4] Remove a few macros Carlos Maiolino
2018-03-06 13:00 ` [PATCH 1/4] Get rid of XFS_BUF_PTR() macro Carlos Maiolino
2018-03-06 22:22 ` Dave Chinner [this message]
2018-03-07 6:12 ` Carlos Maiolino
2018-03-08 8:15 ` Christoph Hellwig
2018-03-06 13:00 ` [PATCH 2/4] Get rid of XFS_BUF_TARGET() macro Carlos Maiolino
2018-03-08 8:15 ` Christoph Hellwig
2018-03-06 13:00 ` [PATCH 3/4] get rid of XFS_BUF_COUNT() macro Carlos Maiolino
2018-03-08 8:15 ` Christoph Hellwig
2018-03-06 13:00 ` [PATCH 4/4] Get rid of XFS_BUF_SET_COUNT() macro Carlos Maiolino
2018-03-08 8:16 ` Christoph Hellwig
2018-03-08 13:23 ` Carlos Maiolino
2018-03-14 13:05 ` [PATCH 0/4] Remove a few macros Carlos Maiolino
-- strict thread matches above, loose matches on Subject: below --
2018-03-07 9:05 [PATCH 0/4 V2] " Carlos Maiolino
2018-03-07 9:05 ` [PATCH 1/4] Get rid of XFS_BUF_PTR() macro Carlos Maiolino
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=20180306222210.GL18129@dastard \
--to=david@fromorbit.com \
--cc=cmaiolino@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.