[Mellanox] [platform API] Fix “local variable 'label_port' referenced 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.
This commit is contained in:
parent
ce6cc3821f
commit
5ec164b694
@ -278,6 +278,7 @@ class sfp_event:
|
|||||||
port_cnt_p = new_uint32_t_p()
|
port_cnt_p = new_uint32_t_p()
|
||||||
uint32_t_p_assign(port_cnt_p,64)
|
uint32_t_p_assign(port_cnt_p,64)
|
||||||
label_port_list = []
|
label_port_list = []
|
||||||
|
label_port = None
|
||||||
module_state = 0
|
module_state = 0
|
||||||
|
|
||||||
rc = sx_lib_host_ifc_recv(fd_p, pkt, pkt_size_p, recv_info_p)
|
rc = sx_lib_host_ifc_recv(fd_p, pkt, pkt_size_p, recv_info_p)
|
||||||
@ -309,9 +310,11 @@ class sfp_event:
|
|||||||
for i in xrange(port_cnt):
|
for i in xrange(port_cnt):
|
||||||
port_attributes = sx_port_attributes_t_arr_getitem(port_attributes_list,i)
|
port_attributes = sx_port_attributes_t_arr_getitem(port_attributes_list,i)
|
||||||
if port_attributes.log_port == logical_port:
|
if port_attributes.log_port == logical_port:
|
||||||
lable_port = port_attributes.port_mapping.module_port
|
label_port = port_attributes.port_mapping.module_port
|
||||||
break
|
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_uint32_t_p(pkt_size_p)
|
||||||
delete_uint8_t_arr(pkt)
|
delete_uint8_t_arr(pkt)
|
||||||
|
Loading…
Reference in New Issue
Block a user