Fix issue: should always check return value of a function if the function may return None#350
Conversation
|
|
|
/easycla |
2 similar comments
|
/easycla |
|
/easycla |
|
/easycla |
1 similar comment
|
/easycla |
| 'low warn': laser_temp_low_warn} | ||
| return laser_temp_dict | ||
|
|
||
| def _get_laser_temp_threshold(self, field): |
There was a problem hiding this comment.
what about other fields which can result in read failure
There was a problem hiding this comment.
I have added a UT case to randomly return None for EEPROM read. For now, I fixed all issues found by the UT case. For other field which I did not touch, I assume the return value is properly checked/handled (not 100% sure).
0dad404 to
b6897d7
Compare
…tion may return None Fix unit test failure
b6897d7 to
9a60097
Compare
|
Hi @prgeor , the easycla checker has passed, could you please help review ? |
|
@Junchao-Mellanox is it needed on other branches? if so, to which? |
| for lane in range(1, self.NUM_CHANNELS+1): | ||
| trans_status['txbiashighalarm_flag%d' % lane] = tx_bias_flag_dict['tx_bias_high_alarm']['TxBiasHighAlarmFlag%d' % lane] | ||
| trans_status['txbiaslowalarm_flag%d' % lane] = tx_bias_flag_dict['tx_bias_low_alarm']['TxBiasLowAlarmFlag%d' % lane] | ||
| trans_status['txbiashighwarning_flag%d' % lane] = tx_bias_flag_dict['tx_bias_high_warn']['TxBiasHighWarnFlag%d' % lane] | ||
| trans_status['txbiaslowwarning_flag%d' % lane] = tx_bias_flag_dict['tx_bias_low_warn']['TxBiasLowWarnFlag%d' % lane] |
There was a problem hiding this comment.
@Junchao-Mellanox if tx_bias_flag_dict{} is None how should the caller handle?
There was a problem hiding this comment.
We checked
if tx_bias_flag_dict:|
@mihirpat1 can you review |
|
Hi @prgeor , could you please help review and sign-off? |
…tion may return None (sonic-net#350) Fix unit test failure Conflicts: tests/sonic_xcvr/test_sff8436.py tests/sonic_xcvr/test_sff8472.py tests/sonic_xcvr/test_sff8636.py
…tion may return None (sonic-net#350) Fix unit test failure Conflicts: tests/sonic_xcvr/test_sff8436.py tests/sonic_xcvr/test_sff8636.py
…tion may return None (#350) (#355) Backport #355 to 202211 Description When a function may return None, caller should always check the return value before using it. This PR is to fix such issues in sonic-xcvr. Motivation and Context When a function may return None, caller should always check the return value before using it. This PR is to fix such issues in sonic-xcvr. How Has This Been Tested? Created unit test cases to avoid such thing happening
Description
When a function may return None, caller should always check the return value before using it. This PR is to fix such issues in sonic-xcvr.
Motivation and Context
When a function may return None, caller should always check the return value before using it. This PR is to fix such issues in sonic-xcvr.
How Has This Been Tested?
Created unit test cases to avoid such thing happening
Additional Information (Optional)