Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handling in es2k/switch_pd_fdb.c #161

Merged
merged 3 commits into from
Oct 4, 2024
Merged

Conversation

ffoulkes
Copy link
Contributor

@ffoulkes ffoulkes commented Oct 2, 2024

In switch_pd_l2_rx_forward_table_entry():

  • Renamed 'status' variable to 'tdi_status', to make it clear whether we are handling a tdi or a switch status code.

  • Defined a distinct 'cleanup_status' variable to hold the status of the call to tdi_switch_pd_deallocate_resources().

  • Added arbitration logic to select the status code to return to the caller.

In switch_pd_l2_rx_forward_table_entry():

- Renamed 'status' variable to 'tdi_status', to make it clear
  whether we are handling a tdi or a switch status code.

- Defined a distinct 'dealloc_status' variable to hold the
  status of the call to tdi_switch_pd_deallocate_resources().

- Added arbitration logic to select the status code to be
  returned to the caller.

Signed-off-by: Derek Foster <[email protected]>
@@ -475,22 +476,23 @@ switch_status_t switch_pd_l2_rx_forward_table_entry(
goto dealloc_resources;
}

status = switch_pd_get_bridge_id(device, (uint8_t)api_l2_rx_info->port_id,
(uint8_t*)&api_l2_rx_info->bridge_id);
switch_status =
Copy link
Contributor Author

@ffoulkes ffoulkes Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original logic assigned the return code from switch_pd_get_bridge_id() (type switch_status_t) to the variable status (type tdi_status_t) and then checked the variable switch_status to see if there was an error.

I renamed status to tdi_status because the former is ambiguous in a function that handles both tdi and switch status codes, and this is a bad thing (as evidenced by the fact that the original coder confused the two).

switchapi/es2k/switch_pd_fdb.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@5abeel 5abeel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

switchapi/es2k/switch_pd_fdb.c Outdated Show resolved Hide resolved
@ffoulkes ffoulkes merged commit 529a5df into main Oct 4, 2024
4 checks passed
@ffoulkes ffoulkes deleted the switch_pd_fdb branch October 4, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants