diff options
author | Gustavo A. R. Silva <gustavoars@kernel.org> | 2024-08-08 16:04:04 -0600 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2024-08-11 20:37:05 -0500 |
commit | 022ee3ac4807007fde323edeef738b169faf400e (patch) | |
tree | 78bdaf56cc9c79a6740ce9c25a1482e45de2f0a4 | |
parent | 9fae888050fb7da8ac1561c443accee6a5c6ef01 (diff) | |
download | linux-022ee3ac4807007fde323edeef738b169faf400e.tar.gz linux-022ee3ac4807007fde323edeef738b169faf400e.tar.bz2 linux-022ee3ac4807007fde323edeef738b169faf400e.zip |
smb: smb2pdu.h: Use static_assert() to check struct sizes
Commit 9f9bef9bc5c6 ("smb: smb2pdu.h: Avoid -Wflex-array-member-not-at-end
warnings") introduced tagged `struct create_context_hdr`. We want to
ensure that when new members need to be added to the flexible structure,
they are always included within this tagged struct.
So, we use `static_assert()` to ensure that the memory layout for
both the flexible structure and the tagged struct is the same after
any changes.
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r-- | fs/smb/common/smb2pdu.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h index c3ee42188d25..c769f9dbc0b4 100644 --- a/fs/smb/common/smb2pdu.h +++ b/fs/smb/common/smb2pdu.h @@ -1216,6 +1216,8 @@ struct create_context { ); __u8 Buffer[]; } __packed; +static_assert(offsetof(struct create_context, Buffer) == sizeof(struct create_context_hdr), + "struct member likely outside of __struct_group()"); struct smb2_create_req { struct smb2_hdr hdr; |