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

Address clang-tidy issues #163

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions switchlink/switchlink_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ switchlink_db_status_t switchlink_db_delete_lag_member(
switchlink_db_lag_member_obj_t* obj = node->data;
krnlmon_assert(obj != NULL);
node = node->next;
if ((obj->lag_member_info.ifindex == lag_member_info->ifindex)) {
if (obj->lag_member_info.ifindex == lag_member_info->ifindex) {
tommy_list_remove_existing(&switchlink_db_lag_member_obj_list,
&obj->list_node);
switchlink_free(obj);
Expand Down Expand Up @@ -1150,7 +1150,7 @@ uint32_t switchlink_db_delete_lacp_member(switchlink_handle_t lag_h) {
switchlink_db_lag_member_obj_t* obj = node->data;
krnlmon_assert(obj != NULL);
node = node->next;
if ((obj->lag_member_info.lag_h == lag_h)) {
if (obj->lag_member_info.lag_h == lag_h) {
return obj->lag_member_info.ifindex;
}
}
Expand All @@ -1176,7 +1176,7 @@ switchlink_db_status_t switchlink_db_update_lag_member_oper_state(
switchlink_db_lag_member_obj_t* obj = node->data;
krnlmon_assert(obj != NULL);
node = node->next;
if ((lag_member_info->ifindex == obj->lag_member_info.ifindex)) {
if (lag_member_info->ifindex == obj->lag_member_info.ifindex) {
obj->lag_member_info.oper_state = lag_member_info->oper_state;
return SWITCHLINK_DB_STATUS_SUCCESS;
}
Expand Down Expand Up @@ -1204,7 +1204,7 @@ switchlink_db_status_t switchlink_db_get_lag_member_info(
switchlink_db_lag_member_obj_t* obj = node->data;
krnlmon_assert(obj != NULL);
node = node->next;
if ((obj->lag_member_info.ifindex == lag_member_info->ifindex)) {
if (obj->lag_member_info.ifindex == lag_member_info->ifindex) {
memcpy(lag_member_info, &(obj->lag_member_info),
sizeof(switchlink_db_lag_member_info_t));
return SWITCHLINK_DB_STATUS_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion switchlink/switchlink_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {
int linkinfo_attr_type;

switchlink_db_interface_info_t intf_info = {0};
switchlink_db_tunnel_interface_info_t tnl_intf_info = {0};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unreferenced variable. Moved inside #ifdef block.

struct link_attrs attrs = {0};
#ifdef LAG_OPTION
bool create_lag_member = false;
Expand Down Expand Up @@ -334,6 +333,7 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {

#if !defined(OVSP4RT_SUPPORT)
case SWITCHLINK_LINK_TYPE_VXLAN: {
switchlink_db_tunnel_interface_info_t tnl_intf_info = {0};
snprintf(tnl_intf_info.ifname, sizeof(tnl_intf_info.ifname), "%s",
attrs.ifname);
tnl_intf_info.dst_ip = attrs.remote_ip_addr;
Expand Down
5 changes: 0 additions & 5 deletions switchlink/switchlink_neigh.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ void switchlink_process_neigh_msg(const struct nlmsghdr* nlmsg, int msgtype) {
} else {
intf_h = ifinfo.intf_h;
}
switchlink_handle_t bridge_h = g_default_bridge_h;
if (ifinfo.intf_type == SWITCHLINK_INTF_TYPE_L2_ACCESS) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we removing this block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

clang-tidy flagged bridge_h as an unreferenced variable. It's only used in the krnlmon_assert statement, which is disabled unless we build krnlmon in Debug mode. I didn't see this as a compelling reason to preserve what is otherwise dead code.

bridge_h = ifinfo.bridge_h;
krnlmon_assert(bridge_h != 0);
}

if (msgtype == RTM_NEWNEIGH) {
if (ipaddr_valid) {
Expand Down