Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: https://github.com/KSPP/linux/issues/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>

authored by

Gustavo A. R. Silva and committed by
Herbert Xu
140e4c85 a9a72140

+11 -6
+4 -2
drivers/crypto/intel/qat/qat_common/qat_bl.c
··· 81 81 if (unlikely(!bufl)) 82 82 return -ENOMEM; 83 83 } else { 84 - bufl = &buf->sgl_src.sgl_hdr; 84 + bufl = container_of(&buf->sgl_src.sgl_hdr, 85 + struct qat_alg_buf_list, hdr); 85 86 memset(bufl, 0, sizeof(struct qat_alg_buf_list)); 86 87 buf->sgl_src_valid = true; 87 88 } ··· 140 139 if (unlikely(!buflout)) 141 140 goto err_in; 142 141 } else { 143 - buflout = &buf->sgl_dst.sgl_hdr; 142 + buflout = container_of(&buf->sgl_dst.sgl_hdr, 143 + struct qat_alg_buf_list, hdr); 144 144 memset(buflout, 0, sizeof(struct qat_alg_buf_list)); 145 145 buf->sgl_dst_valid = true; 146 146 }
+7 -4
drivers/crypto/intel/qat/qat_common/qat_bl.h
··· 15 15 } __packed; 16 16 17 17 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 + ); 21 24 struct qat_alg_buf buffers[]; 22 25 } __packed; 23 26 24 27 struct qat_alg_fixed_buf_list { 25 - struct qat_alg_buf_list sgl_hdr; 28 + struct qat_alg_buf_list_hdr sgl_hdr; 26 29 struct qat_alg_buf descriptors[QAT_MAX_BUFF_DESC]; 27 30 } __packed __aligned(64); 28 31