Skip to content

Commit

Permalink
[clang-tidy] move config to .clang-tidy file (#9308)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhui committed Jul 24, 2023
1 parent 34906f4 commit 1f1c155
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 49 deletions.
22 changes: 22 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
Checks: >
-*,
bugprone-argument-comment,
google-explicit-constructor,
google-readability-casting,
misc-unused-using-decls,
modernize-loop-convert,
modernize-use-bool-literals,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-nullptr,
readability-avoid-const-params-in-decls,
readability-else-after-return,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-redundant-control-flow,
readability-redundant-member-init,
readability-simplify-boolean-expr,
readability-static-accessed-through-instance
WarningsAsErrors: '*'
HeaderFilterRegex: '(examples|include|src).*(?<!third_party.*repo)'
40 changes: 5 additions & 35 deletions script/make-pretty
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,6 @@ OT_CLANG_TIDY_BUILD_OPTS=(
)
readonly OT_CLANG_TIDY_BUILD_OPTS

OT_CLANG_TIDY_CHECKS="\
-*,\
google-explicit-constructor,\
google-readability-casting,\
misc-unused-using-decls,\
modernize-loop-convert,\
modernize-use-bool-literals,\
modernize-use-equals-default,\
modernize-use-equals-delete,\
modernize-use-nullptr,\
readability-avoid-const-params-in-decls,\
readability-else-after-return,\
readability-inconsistent-declaration-parameter-name,\
readability-make-member-function-const,\
readability-redundant-control-flow,\
readability-redundant-member-init,\
readability-simplify-boolean-expr,\
readability-static-accessed-through-instance,\
"
readonly OT_CLANG_TIDY_CHECKS

do_clang_format()
{
echo -e '========================================'
Expand Down Expand Up @@ -192,7 +171,7 @@ do_clang_tidy_fix()
(mkdir -p ./build/cmake-tidy \
&& cd ./build/cmake-tidy \
&& THREAD_VERSION=1.3 cmake "${OT_CLANG_TIDY_BUILD_OPTS[@]}" ../.. \
&& ../../script/clang-tidy -header-filter='.*' -checks="${OT_CLANG_TIDY_CHECKS}" -j"$OT_BUILD_JOBS" "${OT_CLANG_TIDY_FIX_DIRS[@]}" -fix)
&& ../../script/clang-tidy -j"$OT_BUILD_JOBS" "${OT_CLANG_TIDY_FIX_DIRS[@]}" -fix)
}

do_clang_tidy_check()
Expand All @@ -201,19 +180,10 @@ do_clang_tidy_check()
echo -e ' check c/c++ (clang-tidy)'
echo -e '========================================'

(
mkdir -p ./build/cmake-tidy \
&& cd ./build/cmake-tidy \
&& THREAD_VERSION=1.3 cmake "${OT_CLANG_TIDY_BUILD_OPTS[@]}" ../.. \
&& ../../script/clang-tidy -header-filter='.*' -checks="${OT_CLANG_TIDY_CHECKS}" -j"$OT_BUILD_JOBS" "${OT_CLANG_TIDY_FIX_DIRS[@]}" \
| grep -v -E "third_party" >output.txt
if grep -q "warning: \|error: " output.txt; then
echo "You must pass the clang tidy checks before submitting a pull request"
echo ""
grep --color -E 'warning: |error: ' -A 5 output.txt
exit 1
fi
)
(mkdir -p ./build/cmake-tidy \
&& cd ./build/cmake-tidy \
&& THREAD_VERSION=1.3 cmake "${OT_CLANG_TIDY_BUILD_OPTS[@]}" ../.. \
&& ../../script/clang-tidy -j"$OT_BUILD_JOBS" "${OT_CLANG_TIDY_FIX_DIRS[@]}")
}

do_markdown_format()
Expand Down
28 changes: 14 additions & 14 deletions third_party/tcplp/tcplp.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ struct tcplp_signals
* Functions that the TCP protocol logic can call to interact with the rest of
* the system.
*/
otMessage * tcplp_sys_new_message(otInstance *instance);
void tcplp_sys_free_message(otInstance *instance, otMessage *pkt);
void tcplp_sys_send_message(otInstance *instance, otMessage *pkt, otMessageInfo *info);
otMessage * tcplp_sys_new_message(otInstance *aInstance);
void tcplp_sys_free_message(otInstance *aInstance, otMessage *aMessage);
void tcplp_sys_send_message(otInstance *aInstance, otMessage *aMessage, otMessageInfo *aMessageInfo);
uint32_t tcplp_sys_get_ticks();
uint32_t tcplp_sys_get_millis();
void tcplp_sys_set_timer(struct tcpcb *tcb, uint8_t timer_flag, uint32_t delay);
void tcplp_sys_stop_timer(struct tcpcb *tcb, uint8_t timer_flag);
struct tcpcb *tcplp_sys_accept_ready(struct tcpcb_listen *tpl, struct in6_addr *addr, uint16_t port);
bool tcplp_sys_accepted_connection(struct tcpcb_listen *tpl,
struct tcpcb * accepted,
struct in6_addr * addr,
uint16_t port);
void tcplp_sys_connection_lost(struct tcpcb *tcb, uint8_t errnum);
void tcplp_sys_on_state_change(struct tcpcb *tcb, int newstate);
void tcplp_sys_log(const char *format, ...);
void tcplp_sys_panic(const char *format, ...);
void tcplp_sys_set_timer(struct tcpcb *aTcb, uint8_t aTimerFlag, uint32_t aDelay);
void tcplp_sys_stop_timer(struct tcpcb *aTcb, uint8_t aTimerFlag);
struct tcpcb *tcplp_sys_accept_ready(struct tcpcb_listen *aTcbListen, struct in6_addr *aAddr, uint16_t aPort);
bool tcplp_sys_accepted_connection(struct tcpcb_listen *aTcbListen,
struct tcpcb * aAccepted,
struct in6_addr * aAddr,
uint16_t aPort);
void tcplp_sys_connection_lost(struct tcpcb *aTcb, uint8_t aErrNum);
void tcplp_sys_on_state_change(struct tcpcb *aTcb, int aNewState);
void tcplp_sys_log(const char *aFormat, ...);
void tcplp_sys_panic(const char *aFormat, ...);
bool tcplp_sys_autobind(otInstance * aInstance,
const otSockAddr *aPeer,
otSockAddr * aToBind,
Expand Down

0 comments on commit 1f1c155

Please sign in to comment.