net: e1000e: fix dead code in e1000e_write_packet_to_guest
PATCH 1/1 net: e1000e: fix dead code in e1000e_write_packet_to_guest
Because is_first is declared inside a loop, it is always true. The store is dead, and so is the "else" branch of "if (is_first)". is_last is okay though.
Reported by Coverity.
--- hw/net/e1000e_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/e1000e_core.c +1 -1
@@ -1507,6 +1507,7 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,const E1000E_RingInfo *rxi;size_t ps_hdr_len =0 ;bool do_ps =e1000e_do_ps (core, pkt, &ps_hdr_len); +bool is_first = true; rxi = rxr->i;
@@ -1514,7 +1515,6 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,hwaddr ba[MAX_PS_BUFFERS ];e1000e_ba_state bastate = { {0 } };bool is_last = false; -bool is_first = true; desc_size = total_size - desc_offset;
Signature · 1 line
2.9.3
Good catch!
Quoted 36 lines · Paolo Bonzini
Because
is_firstis declared inside a loop, it is always true. The store is dead, and so is the "else" branch of "if (is_first)".is_lastis okay though.Reported by Coverity.
Signed-off-by Paolo Bonzini <[email protected]>---
hw/net/e1000e_core.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)hw/net/e1000e_core.c +1
-1@@ -1507,6 +1507,7 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,const E1000E_RingInfo *rxi;size_t ps_hdr_len =0 ;bool do_ps =e1000e_do_ps (core, pkt, &ps_hdr_len); +bool is_first = true; rxi = rxr->i;@@ -1514,7 +1515,6 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,hwaddr ba[MAX_PS_BUFFERS ];e1000e_ba_state bastate = { {0 } };bool is_last = false; -bool is_first = true; desc_size = total_size - desc_offset;Signature · 1 line
2.9.3
Jason Wang
AppliedQuoted 24 lines · Paolo Bonzini
Because
is_firstis declared inside a loop, it is always true. The store is dead, and so is the "else" branch of "if (is_first)".is_lastis okay though.Reported by Coverity.
Signed-off-by Paolo Bonzini <[email protected]>--- hw/net/e1000e_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/net/e1000e_core.c +1
-0@@ -1507,6 +1507,7 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,const E1000E_RingInfo *rxi;size_t ps_hdr_len =0 ;bool do_ps =e1000e_do_ps (core, pkt, &ps_hdr_len); +bool is_first = true; rxi = rxr->i;
hw/net/e1000e_core.c e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt, · line 1520
Quoted 7 lines
hw/net/e1000e_core.c +0
-1@@ -1514,7 +1515,6 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,hwaddr ba[MAX_PS_BUFFERS ];e1000e_ba_state bastate = { {0 } };bool is_last = false; -bool is_first = true; desc_size = total_size - desc_offset;
Applied, thanks.