Skip to content

Commit

Permalink
[Mellanox] [platform API] Fix “local variable 'label_port' referenced…
Browse files Browse the repository at this point in the history
… before assignment” error (#6419)

In rare case can see that xcvrd failed due to "UnboundLocalError: local variable 'label_port' referenced before assignment"

Init "label_port" as None at the beginning of the function, to avoid the case that "label_port" not assigned.
  • Loading branch information
keboliu authored Jan 12, 2021
1 parent bbd6967 commit 015b421
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def on_pmpe(self, fd_p):
port_cnt_p = new_uint32_t_p()
uint32_t_p_assign(port_cnt_p,64)
label_port_list = []
label_port = None
module_state = 0

rc = sx_lib_host_ifc_recv(fd_p, pkt, pkt_size_p, recv_info_p)
Expand Down Expand Up @@ -309,9 +310,11 @@ def on_pmpe(self, fd_p):
for i in range(port_cnt):
port_attributes = sx_port_attributes_t_arr_getitem(port_attributes_list,i)
if port_attributes.log_port == logical_port:
lable_port = port_attributes.port_mapping.module_port
label_port = port_attributes.port_mapping.module_port
break
label_port_list.append(lable_port)

if label_port is not None:
label_port_list.append(label_port)

delete_uint32_t_p(pkt_size_p)
delete_uint8_t_arr(pkt)
Expand Down

0 comments on commit 015b421

Please sign in to comment.