crypto: qat - Avoid -Wflex-array-member-not-at-end warnings
Subsystems (2)
PATCH 1/1 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]
--- drivers/crypto/intel/qat/qat_common/qat_bl.c | 6 ++++-- drivers/crypto/intel/qat/qat_common/qat_bl.h | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-)
drivers/crypto/intel/qat/qat_common/qat_bl.c +4 -2
@@ -81,7 +81,8 @@ static int __qat_bl_sgl_to_bufl(struct adf_accel_dev *accel_dev,if (unlikely (!bufl))return -ENOMEM ; }else { - bufl = &buf->sgl_src.sgl_hdr; + bufl =container_of (&buf->sgl_src.sgl_hdr, + struct qat_alg_buf_list, hdr);memset (bufl,0 ,sizeof (struct qat_alg_buf_list )); buf->sgl_src_valid = true; }
@@ -139,7 +140,8 @@ static int __qat_bl_sgl_to_bufl(struct adf_accel_dev *accel_dev,if (unlikely (!buflout)) goto err_in; }else { - buflout = &buf->sgl_dst.sgl_hdr; + buflout =container_of (&buf->sgl_dst.sgl_hdr, + struct qat_alg_buf_list, hdr);memset (buflout,0 ,sizeof (struct qat_alg_buf_list )); buf->sgl_dst_valid = true; }
drivers/crypto/intel/qat/qat_common/qat_bl.h +7 -4
@@ -15,14 +15,17 @@ struct qat_alg_buf { } __packed;struct qat_alg_buf_list { -u64 resrvd; -u32 num_bufs; -u32 num_mapped_bufs; +/* New members must be added within the __struct_group() macro below. */ + __struct_group(qat_alg_buf_list_hdr, hdr, __packed, + u64 resrvd; +u32 num_bufs; +u32 num_mapped_bufs; + );struct qat_alg_buf buffers[]; } __packed;struct qat_alg_fixed_buf_list { -struct qat_alg_buf_list sgl_hdr; +struct qat_alg_buf_list_hdr sgl_hdr;struct qat_alg_buf descriptors[QAT_MAX_BUFF_DESC ]; } __packed__aligned(64) ;
Signature · 1 line
2.34.1
Quoted 21 lines · Gustavo A. R. Silva
-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 flexiblestruct qat_alg_buf_list, through taggedstruct qat_alg_buf_list_hdr, and avoid embedding the flexible-array member in the middle ofstruct 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]
Quoted 2 lines
Regards,
Signature · 1 line
Giovanni
Herbert Xu
maintainerQuoted 21 lines · Gustavo A. R. Silva
-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 flexiblestruct qat_alg_buf_list, through taggedstruct qat_alg_buf_list_hdr, and avoid embedding the flexible-array member in the middle ofstruct 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]
Quoted 6 lines
---
drivers/crypto/intel/qat/qat_common/qat_bl.c| 6 ++++--drivers/crypto/intel/qat/qat_common/qat_bl.h| 11 +++++++----2 files changed, 11 insertions(+), 6 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt