]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/mlx5e: Use struct assignment to initialize mlx5e_tx_wqe_info
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Tue, 8 Sep 2020 07:46:09 +0000 (10:46 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Tue, 22 Sep 2020 02:41:13 +0000 (19:41 -0700)
Struct assignment guarantees that all fields of the structure are
initialized (those that are not mentioned are zeroed). It makes code
mode robust and reduces chances for unpredictable behavior when one
forgets to reset some field and it holds an old value from previous
iterations of using the structure.

Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c

index e15aa53ff83e85e2c8b9836271df6bcf27e3132c..c064657dde131fbb29d63aec135668f2ff191e88 100644 (file)
@@ -241,10 +241,12 @@ mlx5e_txwqe_complete(struct mlx5e_txqsq *sq, struct sk_buff *skb,
        struct mlx5_wq_cyc *wq = &sq->wq;
        bool send_doorbell;
 
-       wi->num_bytes = num_bytes;
-       wi->num_dma = num_dma;
-       wi->num_wqebbs = num_wqebbs;
-       wi->skb = skb;
+       *wi = (struct mlx5e_tx_wqe_info) {
+               .skb = skb,
+               .num_bytes = num_bytes,
+               .num_dma = num_dma,
+               .num_wqebbs = num_wqebbs,
+       };
 
        cseg->opmod_idx_opcode = cpu_to_be32((sq->pc << 8) | opcode);
        cseg->qpn_ds           = cpu_to_be32((sq->sqn << 8) | ds_cnt);