RDMA/irdma: Replace one-element array with flexible-array member
authorGustavo A. R. Silva <gustavoars@kernel.org>
Wed, 2 Aug 2023 14:46:26 +0000 (08:46 -0600)
committerLeon Romanovsky <leon@kernel.org>
Thu, 3 Aug 2023 18:11:18 +0000 (21:11 +0300)
commit38313c6d2a02c28162e06753b01bd885caf9386d
treed9d883e0ed9cb7a4f3d8a72e0da1c0a544ad89d4
parent2897f1925be9a3fad3972660ca4bb0909cd64f35
RDMA/irdma: Replace one-element array with flexible-array member

One-element and zero-length arrays are deprecated. So, replace
one-element array in struct irdma_qvlist_info with flexible-array
member.

A patch for this was sent a while ago[1]. However, it seems that, at
the time, the changes were partially folded[2][3], and the actual
flexible-array transformation was omitted. This patch fixes that.

The only binary difference seen before/after changes is shown below:

|  drivers/infiniband/hw/irdma/hw.o
| @@ -868,7 +868,7 @@
| drivers/infiniband/hw/irdma/hw.c:484 (discriminator 2)
| size += struct_size(iw_qvlist, qv_info, rf->msix_count);
|      55b:      imul   $0x45c,%rdi,%rdi
|-     562:      add    $0x10,%rdi
|+     562:      add    $0x4,%rdi

which is, of course, expected as it reflects the mistake made
while folding the patch I've mentioned above.

Worth mentioning is the fact that with this change we save 12 bytes
of memory, as can be inferred from the diff snapshot above. Notice
that:

$ pahole -C rdma_qv_info idrivers/infiniband/hw/irdma/hw.o
struct irdma_qv_info {
u32                        v_idx;                /*     0     4 */
u16                        ceq_idx;              /*     4     2 */
u16                        aeq_idx;              /*     6     2 */
u8                         itr_idx;              /*     8     1 */

/* size: 12, cachelines: 1, members: 4 */
/* padding: 3 */
/* last cacheline: 12 bytes */
};

Link: https://lore.kernel.org/linux-hardening/20210525230038.GA175516@embeddedor/
Link: https://lore.kernel.org/linux-hardening/bf46b428deef4e9e89b0ea1704b1f0e5@intel.com/
Link: https://lore.kernel.org/linux-rdma/20210520143809.819-1-shiraz.saleem@intel.com/T/#u
Fixes: 44d9e52977a1 ("RDMA/irdma: Implement device initialization definitions")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ZMpsQrZadBaJGkt4@work
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/irdma/main.h