[dpdk-dev] e1000/base: fix the wrong assignment to msgbuf[0]

Message ID 1487063647-16263-1-git-send-email-wang.yong19@zte.com.cn (mailing list archive)
State Rejected, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Yong Wang Feb. 14, 2017, 9:14 a.m. UTC
  In function e1000_update_mc_addr_list_vf(), "msgbuf[0]" is used prior
to initialization at "msgbuf[0] |= E1000_VF_SET_MULTICAST_OVERFLOW".
And "msgbuf[0]" is overwritten at "msgbuf[0] = E1000_VF_SET_MULTICAST".
Fix it by moving the second line prior to the first one that mentioned
above.

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
 drivers/net/e1000/base/e1000_vf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Wenzhuo Lu Feb. 14, 2017, 8:24 a.m. UTC | #1
Hi Yong,

> -----Original Message-----
> From: Yong Wang [mailto:wang.yong19@zte.com.cn]
> Sent: Tuesday, February 14, 2017 5:14 PM
> To: Lu, Wenzhuo
> Cc: dev@dpdk.org; Yong Wang
> Subject: [PATCH] e1000/base: fix the wrong assignment to msgbuf[0]
> 
> In function e1000_update_mc_addr_list_vf(), "msgbuf[0]" is used prior to
> initialization at "msgbuf[0] |= E1000_VF_SET_MULTICAST_OVERFLOW".
> And "msgbuf[0]" is overwritten at "msgbuf[0] = E1000_VF_SET_MULTICAST".
> Fix it by moving the second line prior to the first one that mentioned above.
> 
> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
> ---
>  drivers/net/e1000/base/e1000_vf.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/e1000/base/e1000_vf.c
> b/drivers/net/e1000/base/e1000_vf.c
> index 7845b48..44ab018 100644
> --- a/drivers/net/e1000/base/e1000_vf.c
> +++ b/drivers/net/e1000/base/e1000_vf.c
> @@ -421,12 +421,13 @@ void e1000_update_mc_addr_list_vf(struct
> e1000_hw *hw,
> 
>  	DEBUGOUT1("MC Addr Count = %d\n", mc_addr_count);
> 
> +	msgbuf[0] = E1000_VF_SET_MULTICAST;
> +
>  	if (mc_addr_count > 30) {
>  		msgbuf[0] |= E1000_VF_SET_MULTICAST_OVERFLOW;
>  		mc_addr_count = 30;
>  	}
> 
> -	msgbuf[0] = E1000_VF_SET_MULTICAST;
>  	msgbuf[0] |= mc_addr_count << E1000_VT_MSGINFO_SHIFT;
> 
>  	for (i = 0; i < mc_addr_count; i++) {
> --
> 1.8.3.1
Thanks for the patch. I believe it's a good fix.
As normally we don't change the base code. I'll double confirm it with my colleague.
  
Thomas Monjalon Feb. 14, 2017, 8:50 a.m. UTC | #2
2017-02-14 04:14, Yong Wang:
> In function e1000_update_mc_addr_list_vf(), "msgbuf[0]" is used prior
> to initialization at "msgbuf[0] |= E1000_VF_SET_MULTICAST_OVERFLOW".
> And "msgbuf[0]" is overwritten at "msgbuf[0] = E1000_VF_SET_MULTICAST".
> Fix it by moving the second line prior to the first one that mentioned
> above.
> 
> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>

Note about the title: msgbuf[0] does not explain anything in the title
because we have no context when browsing the titles.
It could be "e1000/base: fix multicast setting in VF".
  

Patch

diff --git a/drivers/net/e1000/base/e1000_vf.c b/drivers/net/e1000/base/e1000_vf.c
index 7845b48..44ab018 100644
--- a/drivers/net/e1000/base/e1000_vf.c
+++ b/drivers/net/e1000/base/e1000_vf.c
@@ -421,12 +421,13 @@  void e1000_update_mc_addr_list_vf(struct e1000_hw *hw,
 
 	DEBUGOUT1("MC Addr Count = %d\n", mc_addr_count);
 
+	msgbuf[0] = E1000_VF_SET_MULTICAST;
+
 	if (mc_addr_count > 30) {
 		msgbuf[0] |= E1000_VF_SET_MULTICAST_OVERFLOW;
 		mc_addr_count = 30;
 	}
 
-	msgbuf[0] = E1000_VF_SET_MULTICAST;
 	msgbuf[0] |= mc_addr_count << E1000_VT_MSGINFO_SHIFT;
 
 	for (i = 0; i < mc_addr_count; i++) {