From d8c988273edd1f98525029cf5dd410fc3b75bb7d Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Fri, 13 Aug 2021 14:37:12 +0200 Subject: [PATCH] fixstyle, now with upstream .clang-* files --- .clang-format | 28 ++++++++++++++++++++++++++++ .clang-tidy | 8 ++++++++ lcpng_if_sync.c | 28 +++++++++++++++------------- 3 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 .clang-format create mode 100644 .clang-tidy diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..b925f8c --- /dev/null +++ b/.clang-format @@ -0,0 +1,28 @@ +# Minimal clang-format version is 8 + +BasedOnStyle: GNU +UseTab: Always +SpaceAfterCStyleCast: true +SortIncludes: false +AlignConsecutiveMacros: true +BreakBeforeTernaryOperators: false +BreakBeforeBinaryOperators: None +ContinuationIndentWidth: 2 + +ForEachMacros: + - 'clib_bitmap_foreach' + - 'pool_foreach' + - 'pool_foreach_index' + - 'vec_foreach' + - 'vec_foreach_backwards' + - 'vec_foreach_index' + - 'vec_foreach_index_backwards' + - 'vlib_foreach_rx_tx' + - 'foreach_vlib_main' + +StatementMacros: + - 'CLIB_MULTIARCH_FN' + - 'VLIB_NODE_FN' + - 'VNET_DEVICE_CLASS_TX_FN' + - '__clib_section' + - '__clib_aligned' diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..f3f69d2 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,8 @@ +Checks: "-*,\ +misc-*,\ +bugprone-*,\ +-bugprone-reserved-identifier,\ +-performance-*,\ +clang-analyzer-*,\ +-clang-analyzer-valist.Uninitialized,\ +" diff --git a/lcpng_if_sync.c b/lcpng_if_sync.c index 66fc888..ff93c24 100644 --- a/lcpng_if_sync.c +++ b/lcpng_if_sync.c @@ -35,22 +35,24 @@ /* walk function to copy forward all sw interface link state flags into * their counterpart LIP link state. */ -static walk_rc_t lcp_itf_pair_walk_sync_state_cb(index_t lipi, void *ctx) { +static walk_rc_t +lcp_itf_pair_walk_sync_state_cb (index_t lipi, void *ctx) +{ lcp_itf_pair_t *lip; vnet_sw_interface_t *phy; - lip = lcp_itf_pair_get(lipi); + lip = lcp_itf_pair_get (lipi); if (!lip) return WALK_CONTINUE; phy = - vnet_get_sw_interface_or_null(vnet_get_main(), lip->lip_phy_sw_if_index); + vnet_get_sw_interface_or_null (vnet_get_main (), lip->lip_phy_sw_if_index); if (!phy) return WALK_CONTINUE; - LCP_ITF_PAIR_DBG("walk_sync_state: lip %U flags %u", format_lcp_itf_pair, lip, - phy->flags); - lcp_itf_set_link_state(lip, (phy->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)); + LCP_ITF_PAIR_DBG ("walk_sync_state: lip %U flags %u", format_lcp_itf_pair, + lip, phy->flags); + lcp_itf_set_link_state (lip, (phy->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)); return WALK_CONTINUE; } @@ -71,23 +73,23 @@ lcp_itf_admin_state_change (vnet_main_t * vnm, u32 sw_if_index, u32 flags) if (!lip) return NULL; LCP_ITF_PAIR_INFO ("admin_state_change: %U flags %u", format_lcp_itf_pair, lip, flags); - lcp_itf_set_link_state(lip, (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)); + lcp_itf_set_link_state (lip, (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)); // Sync PHY carrier changes into TAP hi = vnet_get_hw_interface_or_null (vnm, sw_if_index); si = vnet_get_sw_interface_or_null (vnm, lip->lip_host_sw_if_index); if (!si || !hi) return NULL; - LCP_ITF_PAIR_DBG("admin_state_change: hi %U si %U %u", - format_vnet_sw_if_index_name, vnm, hi->hw_if_index, - format_vnet_sw_if_index_name, vnm, si->sw_if_index, flags); - tap_set_carrier(si->hw_if_index, - (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP)); + LCP_ITF_PAIR_DBG ("admin_state_change: hi %U si %U %u", + format_vnet_sw_if_index_name, vnm, hi->hw_if_index, + format_vnet_sw_if_index_name, vnm, si->sw_if_index, flags); + tap_set_carrier (si->hw_if_index, + (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP)); // When Linux changes link on a master interface, all of its children also // change. This is not true in VPP, so we are forced to undo that change by // walking the sub-interfaces of a phy and syncing their state back into // linux. For simplicity, just walk all interfaces. - lcp_itf_pair_walk(lcp_itf_pair_walk_sync_state_cb, 0); + lcp_itf_pair_walk (lcp_itf_pair_walk_sync_state_cb, 0); return NULL; }