From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F751C4727F for ; Tue, 22 Sep 2020 02:47:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2137923A79 for ; Tue, 22 Sep 2020 02:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600742868; bh=Pxkwrzi6HAPLOvxhKx6AcXNQxunRN1ywd0gQpEnvhi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=R2Em+RlUIOtLzPre57M6zJhbkv6NPm3yeFn9YNLQfACBwVYNR2bbRrj6mW6f/Tijr iMuOF4Fe7kec++w1yosvK+SjzKWQhjo2SRAfduOAXgcwidqDPiXpp+l2oUP8fxWkUP /pqWqvMiZkHx7e8kqRdB4brCdQJLWStqoTl95LZ8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729247AbgIVCrp (ORCPT ); Mon, 21 Sep 2020 22:47:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:57984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729011AbgIVCrl (ORCPT ); Mon, 21 Sep 2020 22:47:41 -0400 Received: from sx1.mtl.com (c-24-6-56-119.hsd1.ca.comcast.net [24.6.56.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 575CD23A62; Tue, 22 Sep 2020 02:47:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600742860; bh=Pxkwrzi6HAPLOvxhKx6AcXNQxunRN1ywd0gQpEnvhi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=neDFsQ97xuJoss7A19CmGUUmtCNX0VTWFtVf7/tqedRNiZLfNzYDMcAboNGtHVnHP 1tBahOTWMCfkL1qX2KSatOMqZNYDr3ygZffRjp0p1kSTCD6QHCtpNRa79U9wVnDYnu 3fC9GUTub7lKq0Jn9qLq9yzUAuAdANCzCQIxtI2U= From: saeed@kernel.org To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Maxim Mikityanskiy , Tariq Toukan , Saeed Mahameed Subject: [net-next V3 02/12] net/mlx5e: Use struct assignment to initialize mlx5e_tx_wqe_info Date: Mon, 21 Sep 2020 19:46:54 -0700 Message-Id: <20200922024704.544482-3-saeed@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200922024704.544482-1-saeed@kernel.org> References: <20200922024704.544482-1-saeed@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Maxim Mikityanskiy 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 Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c index e15aa53ff83e..c064657dde13 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c @@ -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); -- 2.26.2