]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
NFSD: Simplify struct knfsd_fh
authorChuck Lever <chuck.lever@oracle.com>
Fri, 20 Jun 2025 12:31:55 +0000 (08:31 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 14 Jul 2025 16:46:47 +0000 (12:46 -0400)
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>
fs/nfsd/nfsfh.h

index 4569b5950b55f43e8341d051b8205a35a324f5d4..1cf9797225210c072b92236625efcfd4f5d45e93 100644 (file)
@@ -49,17 +49,14 @@ struct knfsd_fh {
                                         * Points to the current size while
                                         * building a new file handle.
                                         */
-       union {
-               char                    fh_raw[NFS4_FHSIZE];
-               struct {
-                       u8              fh_version;     /* == 1 */
-                       u8              fh_auth_type;   /* deprecated */
-                       u8              fh_fsid_type;
-                       u8              fh_fileid_type;
-               };
-       };
+       u8              fh_raw[NFS4_FHSIZE];
 };
 
+#define fh_version             fh_raw[0]
+#define fh_auth_type           fh_raw[1]
+#define fh_fsid_type           fh_raw[2]
+#define fh_fileid_type         fh_raw[3]
+
 static inline u32 *fh_fsid(const struct knfsd_fh *fh)
 {
        return (u32 *)&fh->fh_raw[4];