Message ID | 89743aba-ca7f-340c-c813-b8d73cb25cd7@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | xfs: don't take addresses of packed structures | expand |
On Wed, Jan 29, 2020 at 11:45:05AM -0600, Eric Sandeen wrote: > gcc now warns about taking an address of a packed structure member. > > This happens here because of how be32_add_cpu() works; just open-code > the modification using a temporary variable instead. > > Signed-off-by: Eric Sandeen <sandeen@redhat.com> > --- > > diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c > index fc78efa52c94..ad5ead62c992 100644 > --- a/fs/xfs/libxfs/xfs_rmap_btree.c > +++ b/fs/xfs/libxfs/xfs_rmap_btree.c > @@ -182,12 +182,14 @@ xfs_rmapbt_init_high_key_from_rec( > union xfs_btree_rec *rec) > { > uint64_t off; > + xfs_agblock_t start; > int adj; > > adj = be32_to_cpu(rec->rmap.rm_blockcount) - 1; > > key->rmap.rm_startblock = rec->rmap.rm_startblock; I was gonna say to kill this statement since you set it again two lines later, but then spotted a bug two lines down... > - be32_add_cpu(&key->rmap.rm_startblock, adj); > + start = be32_to_cpu(rec->rmap.rm_startblock) - adj; > + rec->rmap.rm_startblock = cpu_to_be32(start); ...this should be setting key->rmap.rm_startblock. --D > key->rmap.rm_owner = rec->rmap.rm_owner; > key->rmap.rm_offset = rec->rmap.rm_offset; > if (XFS_RMAP_NON_INODE_OWNER(be64_to_cpu(rec->rmap.rm_owner)) || > >
On 1/29/20 11:56 AM, Darrick J. Wong wrote: > On Wed, Jan 29, 2020 at 11:45:05AM -0600, Eric Sandeen wrote: >> gcc now warns about taking an address of a packed structure member. >> >> This happens here because of how be32_add_cpu() works; just open-code >> the modification using a temporary variable instead. >> >> Signed-off-by: Eric Sandeen <sandeen@redhat.com> >> --- >> >> diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c >> index fc78efa52c94..ad5ead62c992 100644 >> --- a/fs/xfs/libxfs/xfs_rmap_btree.c >> +++ b/fs/xfs/libxfs/xfs_rmap_btree.c >> @@ -182,12 +182,14 @@ xfs_rmapbt_init_high_key_from_rec( >> union xfs_btree_rec *rec) >> { >> uint64_t off; >> + xfs_agblock_t start; >> int adj; >> >> adj = be32_to_cpu(rec->rmap.rm_blockcount) - 1; >> >> key->rmap.rm_startblock = rec->rmap.rm_startblock; > > I was gonna say to kill this statement since you set it again two lines > later, but then spotted a bug two lines down... > >> - be32_add_cpu(&key->rmap.rm_startblock, adj); >> + start = be32_to_cpu(rec->rmap.rm_startblock) - adj; >> + rec->rmap.rm_startblock = cpu_to_be32(start); /searches for that brown paper bag thanks -Eric
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c index fc78efa52c94..ad5ead62c992 100644 --- a/fs/xfs/libxfs/xfs_rmap_btree.c +++ b/fs/xfs/libxfs/xfs_rmap_btree.c @@ -182,12 +182,14 @@ xfs_rmapbt_init_high_key_from_rec( union xfs_btree_rec *rec) { uint64_t off; + xfs_agblock_t start; int adj; adj = be32_to_cpu(rec->rmap.rm_blockcount) - 1; key->rmap.rm_startblock = rec->rmap.rm_startblock; - be32_add_cpu(&key->rmap.rm_startblock, adj); + start = be32_to_cpu(rec->rmap.rm_startblock) - adj; + rec->rmap.rm_startblock = cpu_to_be32(start); key->rmap.rm_owner = rec->rmap.rm_owner; key->rmap.rm_offset = rec->rmap.rm_offset; if (XFS_RMAP_NON_INODE_OWNER(be64_to_cpu(rec->rmap.rm_owner)) ||
gcc now warns about taking an address of a packed structure member. This happens here because of how be32_add_cpu() works; just open-code the modification using a temporary variable instead. Signed-off-by: Eric Sandeen <sandeen@redhat.com> ---