Skip to content

Commit 0396379

Browse files
committed
NFSD: Simplify struct knfsd_fh
Compilers are allowed to insert padding and reorder the fields in a struct, so using a union of an array and a struct in struct knfsd_fh is not reliable. The position of elements in an array is more reliable. Suggested-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent edf7b90 commit 0396379

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

fs/nfsd/nfsfh.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,14 @@ struct knfsd_fh {
4949
* Points to the current size while
5050
* building a new file handle.
5151
*/
52-
union {
53-
char fh_raw[NFS4_FHSIZE];
54-
struct {
55-
u8 fh_version; /* == 1 */
56-
u8 fh_auth_type; /* deprecated */
57-
u8 fh_fsid_type;
58-
u8 fh_fileid_type;
59-
};
60-
};
52+
u8 fh_raw[NFS4_FHSIZE];
6153
};
6254

55+
#define fh_version fh_raw[0]
56+
#define fh_auth_type fh_raw[1]
57+
#define fh_fsid_type fh_raw[2]
58+
#define fh_fileid_type fh_raw[3]
59+
6360
static inline u32 *fh_fsid(const struct knfsd_fh *fh)
6461
{
6562
return (u32 *)&fh->fh_raw[4];

0 commit comments

Comments
 (0)