linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: linux-xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH 1/2] xfs: don't take addresses of packed xfs_agfl_t member
Date: Wed, 29 Jan 2020 11:43:13 -0600	[thread overview]
Message-ID: <09382ee9-8539-2f1d-bd4d-7256daf38a40@redhat.com> (raw)
In-Reply-To: <65e48930-96ae-7307-ba65-6b7528bb2fb5@redhat.com>

gcc now warns about taking an address of a packed structure member.

Work around this by using offsetof() instead.

Thanks to bfoster for the suggestion and djwong for reiterating it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index 1b7dcbae051c..7bfc8e2437e9 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -787,7 +787,8 @@ typedef struct xfs_agi {
 
 #define XFS_BUF_TO_AGFL_BNO(mp, bp) \
 	(xfs_sb_version_hascrc(&((mp)->m_sb)) ? \
-		&(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \
+		(__be32 *)((char *)(bp)->b_addr + \
+			offsetof(struct xfs_agfl, agfl_bno)) : \
 		(__be32 *)(bp)->b_addr)
 
 typedef struct xfs_agfl {


  reply	other threads:[~2020-01-29 17:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-29 17:41 [PATCH 0/2] xfs: don't take addresses of packed structures Eric Sandeen
2020-01-29 17:43 ` Eric Sandeen [this message]
2020-01-29 18:09   ` [PATCH 1/2] xfs: don't take addresses of packed xfs_agfl_t member Christoph Hellwig
2020-01-29 18:18     ` Eric Sandeen
2020-01-29 18:28       ` Christoph Hellwig
2020-01-29 18:46         ` Eric Sandeen
2020-01-29 17:45 ` [PATCH 2/2] xfs: don't take addresses of packed xfs_rmap_key Eric Sandeen
2020-01-29 17:56   ` Darrick J. Wong
2020-01-29 18:01     ` Eric Sandeen
2020-01-29 18:15   ` [PATCH 2/2 V2] xfs: don't take addresses of packed xfs_rmap_key member Eric Sandeen
2020-01-29 18:29     ` Christoph Hellwig
2020-01-29 18:31       ` Eric Sandeen
2020-01-29 18:35     ` [PATCH 2/2 V3] " Eric Sandeen
2020-01-29 18:36       ` Christoph Hellwig
2020-02-26 18:06       ` Darrick J. Wong
2020-02-26 18:21         ` Eric Sandeen
2020-02-26 18:45           ` Eric Sandeen

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=09382ee9-8539-2f1d-bd4d-7256daf38a40@redhat.com \
    --to=sandeen@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 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).