Skip to content

Commit 9f9bef9

Browse files
GustavoARSilvaSteve French
authored andcommitted
smb: smb2pdu.h: Avoid -Wflex-array-member-not-at-end warnings
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting ready to enable it globally. So, in order to avoid ending up with a flexible-array member in the middle of multiple other structs, we use the `__struct_group()` helper to separate the flexible array from the rest of the members in the flexible structure, and use the tagged `struct create_context_hdr` instead of `struct create_context`. So, with these changes, fix 51 of the following warnings[1]: fs/smb/client/../common/smb2pdu.h:1225:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] Link: https://gist.github.com/GustavoARSilva/772526a39be3dd4db39e71497f0a9893 [1] Link: KSPP#202 Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent f4e8d80 commit 9f9bef9

File tree

3 files changed

+33
-30
lines changed

3 files changed

+33
-30
lines changed

fs/smb/client/smb2pdu.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct durable_context_v2 {
145145
} __packed;
146146

147147
struct create_durable_v2 {
148-
struct create_context ccontext;
148+
struct create_context_hdr ccontext;
149149
__u8 Name[8];
150150
struct durable_context_v2 dcontext;
151151
} __packed;
@@ -167,28 +167,28 @@ struct durable_reconnect_context_v2_rsp {
167167
} __packed;
168168

169169
struct create_durable_handle_reconnect_v2 {
170-
struct create_context ccontext;
170+
struct create_context_hdr ccontext;
171171
__u8 Name[8];
172172
struct durable_reconnect_context_v2 dcontext;
173173
__u8 Pad[4];
174174
} __packed;
175175

176176
/* See MS-SMB2 2.2.13.2.5 */
177177
struct crt_twarp_ctxt {
178-
struct create_context ccontext;
178+
struct create_context_hdr ccontext;
179179
__u8 Name[8];
180180
__le64 Timestamp;
181181

182182
} __packed;
183183

184184
/* See MS-SMB2 2.2.13.2.9 */
185185
struct crt_query_id_ctxt {
186-
struct create_context ccontext;
186+
struct create_context_hdr ccontext;
187187
__u8 Name[8];
188188
} __packed;
189189

190190
struct crt_sd_ctxt {
191-
struct create_context ccontext;
191+
struct create_context_hdr ccontext;
192192
__u8 Name[8];
193193
struct smb3_sd sd;
194194
} __packed;
@@ -415,7 +415,7 @@ struct smb2_posix_info_parsed {
415415
};
416416

417417
struct smb2_create_ea_ctx {
418-
struct create_context ctx;
418+
struct create_context_hdr ctx;
419419
__u8 name[8];
420420
struct smb2_file_full_ea_info ea;
421421
} __packed;

fs/smb/common/smb2pdu.h

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,12 +1171,15 @@ struct smb2_server_client_notification {
11711171
#define SMB2_CREATE_FLAG_REPARSEPOINT 0x01
11721172

11731173
struct create_context {
1174-
__le32 Next;
1175-
__le16 NameOffset;
1176-
__le16 NameLength;
1177-
__le16 Reserved;
1178-
__le16 DataOffset;
1179-
__le32 DataLength;
1174+
/* New members must be added within the struct_group() macro below. */
1175+
__struct_group(create_context_hdr, hdr, __packed,
1176+
__le32 Next;
1177+
__le16 NameOffset;
1178+
__le16 NameLength;
1179+
__le16 Reserved;
1180+
__le16 DataOffset;
1181+
__le32 DataLength;
1182+
);
11801183
__u8 Buffer[];
11811184
} __packed;
11821185

@@ -1222,15 +1225,15 @@ struct smb2_create_rsp {
12221225
} __packed;
12231226

12241227
struct create_posix {
1225-
struct create_context ccontext;
1228+
struct create_context_hdr ccontext;
12261229
__u8 Name[16];
12271230
__le32 Mode;
12281231
__u32 Reserved;
12291232
} __packed;
12301233

12311234
/* See MS-SMB2 2.2.13.2.3 and MS-SMB2 2.2.13.2.4 */
12321235
struct create_durable {
1233-
struct create_context ccontext;
1236+
struct create_context_hdr ccontext;
12341237
__u8 Name[8];
12351238
union {
12361239
__u8 Reserved[16];
@@ -1243,14 +1246,14 @@ struct create_durable {
12431246

12441247
/* See MS-SMB2 2.2.13.2.5 */
12451248
struct create_mxac_req {
1246-
struct create_context ccontext;
1249+
struct create_context_hdr ccontext;
12471250
__u8 Name[8];
12481251
__le64 Timestamp;
12491252
} __packed;
12501253

12511254
/* See MS-SMB2 2.2.14.2.5 */
12521255
struct create_mxac_rsp {
1253-
struct create_context ccontext;
1256+
struct create_context_hdr ccontext;
12541257
__u8 Name[8];
12551258
__le32 QueryStatus;
12561259
__le32 MaximalAccess;
@@ -1286,21 +1289,21 @@ struct lease_context_v2 {
12861289
} __packed;
12871290

12881291
struct create_lease {
1289-
struct create_context ccontext;
1292+
struct create_context_hdr ccontext;
12901293
__u8 Name[8];
12911294
struct lease_context lcontext;
12921295
} __packed;
12931296

12941297
struct create_lease_v2 {
1295-
struct create_context ccontext;
1298+
struct create_context_hdr ccontext;
12961299
__u8 Name[8];
12971300
struct lease_context_v2 lcontext;
12981301
__u8 Pad[4];
12991302
} __packed;
13001303

13011304
/* See MS-SMB2 2.2.14.2.9 */
13021305
struct create_disk_id_rsp {
1303-
struct create_context ccontext;
1306+
struct create_context_hdr ccontext;
13041307
__u8 Name[8];
13051308
__le64 DiskFileId;
13061309
__le64 VolumeId;
@@ -1309,7 +1312,7 @@ struct create_disk_id_rsp {
13091312

13101313
/* See MS-SMB2 2.2.13.2.13 */
13111314
struct create_app_inst_id {
1312-
struct create_context ccontext;
1315+
struct create_context_hdr ccontext;
13131316
__u8 Name[16];
13141317
__le32 StructureSize; /* Must be 20 */
13151318
__u16 Reserved;
@@ -1318,7 +1321,7 @@ struct create_app_inst_id {
13181321

13191322
/* See MS-SMB2 2.2.13.2.15 */
13201323
struct create_app_inst_id_vers {
1321-
struct create_context ccontext;
1324+
struct create_context_hdr ccontext;
13221325
__u8 Name[16];
13231326
__le32 StructureSize; /* Must be 24 */
13241327
__u16 Reserved;

fs/smb/server/smb2pdu.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct preauth_integrity_info {
6464
#define SMB2_SESSION_TIMEOUT (10 * HZ)
6565

6666
struct create_durable_req_v2 {
67-
struct create_context ccontext;
67+
struct create_context_hdr ccontext;
6868
__u8 Name[8];
6969
__le32 Timeout;
7070
__le32 Flags;
@@ -73,7 +73,7 @@ struct create_durable_req_v2 {
7373
} __packed;
7474

7575
struct create_durable_reconn_req {
76-
struct create_context ccontext;
76+
struct create_context_hdr ccontext;
7777
__u8 Name[8];
7878
union {
7979
__u8 Reserved[16];
@@ -85,7 +85,7 @@ struct create_durable_reconn_req {
8585
} __packed;
8686

8787
struct create_durable_reconn_v2_req {
88-
struct create_context ccontext;
88+
struct create_context_hdr ccontext;
8989
__u8 Name[8];
9090
struct {
9191
__u64 PersistentFileId;
@@ -96,13 +96,13 @@ struct create_durable_reconn_v2_req {
9696
} __packed;
9797

9898
struct create_alloc_size_req {
99-
struct create_context ccontext;
99+
struct create_context_hdr ccontext;
100100
__u8 Name[8];
101101
__le64 AllocationSize;
102102
} __packed;
103103

104104
struct create_durable_rsp {
105-
struct create_context ccontext;
105+
struct create_context_hdr ccontext;
106106
__u8 Name[8];
107107
union {
108108
__u8 Reserved[8];
@@ -114,15 +114,15 @@ struct create_durable_rsp {
114114
/* Flags */
115115
#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
116116
struct create_durable_v2_rsp {
117-
struct create_context ccontext;
117+
struct create_context_hdr ccontext;
118118
__u8 Name[8];
119119
__le32 Timeout;
120120
__le32 Flags;
121121
} __packed;
122122

123123
/* equivalent of the contents of SMB3.1.1 POSIX open context response */
124124
struct create_posix_rsp {
125-
struct create_context ccontext;
125+
struct create_context_hdr ccontext;
126126
__u8 Name[16];
127127
__le32 nlink;
128128
__le32 reparse_tag;
@@ -381,13 +381,13 @@ struct smb2_ea_info {
381381
} __packed; /* level 15 Query */
382382

383383
struct create_ea_buf_req {
384-
struct create_context ccontext;
384+
struct create_context_hdr ccontext;
385385
__u8 Name[8];
386386
struct smb2_ea_info ea;
387387
} __packed;
388388

389389
struct create_sd_buf_req {
390-
struct create_context ccontext;
390+
struct create_context_hdr ccontext;
391391
__u8 Name[8];
392392
struct smb_ntsd ntsd;
393393
} __packed;

0 commit comments

Comments
 (0)