Skip to content

Commit 140e4c8

Browse files
GustavoARSilvaherbertx
authored andcommitted
crypto: qat - 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. Use the `__struct_group()` helper to separate the flexible array from the rest of the members in flexible `struct qat_alg_buf_list`, through tagged `struct qat_alg_buf_list_hdr`, and avoid embedding the flexible-array member in the middle of `struct qat_alg_fixed_buf_list`. Also, use `container_of()` whenever we need to retrieve a pointer to the flexible structure. So, with these changes, fix the following warnings: drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] Link: KSPP/linux#202 Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent a9a7214 commit 140e4c8

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

drivers/crypto/intel/qat/qat_common/qat_bl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ static int __qat_bl_sgl_to_bufl(struct adf_accel_dev *accel_dev,
8181
if (unlikely(!bufl))
8282
return -ENOMEM;
8383
} else {
84-
bufl = &buf->sgl_src.sgl_hdr;
84+
bufl = container_of(&buf->sgl_src.sgl_hdr,
85+
struct qat_alg_buf_list, hdr);
8586
memset(bufl, 0, sizeof(struct qat_alg_buf_list));
8687
buf->sgl_src_valid = true;
8788
}
@@ -139,7 +140,8 @@ static int __qat_bl_sgl_to_bufl(struct adf_accel_dev *accel_dev,
139140
if (unlikely(!buflout))
140141
goto err_in;
141142
} else {
142-
buflout = &buf->sgl_dst.sgl_hdr;
143+
buflout = container_of(&buf->sgl_dst.sgl_hdr,
144+
struct qat_alg_buf_list, hdr);
143145
memset(buflout, 0, sizeof(struct qat_alg_buf_list));
144146
buf->sgl_dst_valid = true;
145147
}

drivers/crypto/intel/qat/qat_common/qat_bl.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ struct qat_alg_buf {
1515
} __packed;
1616

1717
struct qat_alg_buf_list {
18-
u64 resrvd;
19-
u32 num_bufs;
20-
u32 num_mapped_bufs;
18+
/* New members must be added within the __struct_group() macro below. */
19+
__struct_group(qat_alg_buf_list_hdr, hdr, __packed,
20+
u64 resrvd;
21+
u32 num_bufs;
22+
u32 num_mapped_bufs;
23+
);
2124
struct qat_alg_buf buffers[];
2225
} __packed;
2326

2427
struct qat_alg_fixed_buf_list {
25-
struct qat_alg_buf_list sgl_hdr;
28+
struct qat_alg_buf_list_hdr sgl_hdr;
2629
struct qat_alg_buf descriptors[QAT_MAX_BUFF_DESC];
2730
} __packed __aligned(64);
2831

0 commit comments

Comments
 (0)