From aef4e4fe74a05f04cad084702ca0d8c910500423 Mon Sep 17 00:00:00 2001 From: valentin petrov Date: Thu, 29 Sep 2022 11:48:13 +0300 Subject: [PATCH] REVIEW: fix/suppress linter warnings (#636) --- .clang-tidy | 2 +- .github/workflows/clang-tidy.yaml | 6 +++++- src/components/cl/hier/allreduce/allreduce_split_rail.c | 6 ++++++ src/core/ucc_coll.c | 4 ++-- src/schedule/ucc_schedule.c | 6 +++--- src/utils/khash.h | 2 +- src/utils/ucc_parser.c | 2 +- 7 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index f04eb8f018..3327f70965 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -9,7 +9,7 @@ Checks: > misc-static-assert, misc-unused-parameters, readability-redundant-control-flow -WarningsAsErrors: '' +WarningsAsErrors: '*' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false FormatStyle: none diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml index 7303e967a4..cde225b4b0 100644 --- a/.github/workflows/clang-tidy.yaml +++ b/.github/workflows/clang-tidy.yaml @@ -34,7 +34,11 @@ jobs: run: | echo "Workspace: ${GITHUB_WORKSPACE}" cd ${GITHUB_WORKSPACE} - run-clang-tidy-${CLANG_VER} -p /tmp/ + run-clang-tidy-${CLANG_VER} -p /tmp/ 2>&1 | tee /tmp/clang_tidy.log + nerrors=$(grep 'error:' /tmp/clang_tidy.log | wc -l) + if [ $nerrors -ne 0 ]; then + exit 125; + fi make clean rm -rf /tmp/ucc - name: Run gtest ASAN diff --git a/src/components/cl/hier/allreduce/allreduce_split_rail.c b/src/components/cl/hier/allreduce/allreduce_split_rail.c index e45b9457f0..d45b9f8e03 100644 --- a/src/components/cl/hier/allreduce/allreduce_split_rail.c +++ b/src/components/cl/hier/allreduce/allreduce_split_rail.c @@ -127,6 +127,12 @@ static ucc_status_t ucc_cl_hier_allreduce_split_rail_frag_init( } node_size = cl_team->sbgps[UCC_HIER_SBGP_NODE].sbgp->group_size; + if (ucc_unlikely(0 == node_size)) { + /* this check is only needed to suppress clang-tidy linter which + assumes potential devision-by-zero when node_size is passed to + ucc_buffer_block_count */ + goto err_rs; + } node_rank = cl_team->sbgps[UCC_HIER_SBGP_NODE].sbgp->group_rank; total_count = coll_args->args.dst.info.count; diff --git a/src/core/ucc_coll.c b/src/core/ucc_coll.c index efaa6121c3..4f97487f56 100644 --- a/src/core/ucc_coll.c +++ b/src/core/ucc_coll.c @@ -298,8 +298,8 @@ UCC_CORE_PROFILE_FUNC(ucc_status_t, ucc_collective_post, (request), } UCC_CORE_PROFILE_FUNC(ucc_status_t, ucc_collective_init_and_post, - (coll_args, request, team), ucc_coll_args_t *coll_args, - ucc_coll_req_h *request, ucc_team_h team) + (coll_args, request, team), ucc_coll_args_t *coll_args, //NOLINT + ucc_coll_req_h *request, ucc_team_h team) //NOLINT { ucc_error("ucc_collective_init_and_post() is not implemented"); diff --git a/src/schedule/ucc_schedule.c b/src/schedule/ucc_schedule.c index 01407c5889..d9fbc3fb20 100644 --- a/src/schedule/ucc_schedule.c +++ b/src/schedule/ucc_schedule.c @@ -9,15 +9,15 @@ #include "coll_score/ucc_coll_score.h" #include "core/ucc_context.h" -static void ucc_coll_task_mpool_obj_init(ucc_mpool_t *mp, void *obj, - void *chunk) +static void ucc_coll_task_mpool_obj_init(ucc_mpool_t *mp, void *obj, //NOLINT + void *chunk) //NOLINT { ucc_coll_task_t *task = obj; ucc_coll_task_construct(task); } -static void ucc_coll_task_mpool_obj_cleanup(ucc_mpool_t *mp, void *obj) +static void ucc_coll_task_mpool_obj_cleanup(ucc_mpool_t *mp, void *obj) //NOLINT { ucc_coll_task_t *task = obj; diff --git a/src/utils/khash.h b/src/utils/khash.h index cb378966a6..8f60ed5dee 100644 --- a/src/utils/khash.h +++ b/src/utils/khash.h @@ -446,7 +446,7 @@ static kh_inline khint_t __ac_X31_hash_string(const char *s) /*! @function @abstract Const char* comparison function */ -#define kh_str_hash_equal(a, b) (strcmp(a, b) == 0) +#define kh_str_hash_equal(a, b) (strcmp(a, b) == 0) /* NOLINT */ static kh_inline khint_t __ac_Wang_hash(khint_t key) { diff --git a/src/utils/ucc_parser.c b/src/utils/ucc_parser.c index 08404c00a2..551dfba953 100644 --- a/src/utils/ucc_parser.c +++ b/src/utils/ucc_parser.c @@ -187,7 +187,7 @@ static int ucc_file_parse_handler(void *arg, const char *section, //NOLINT ucc_error("failed to dup str for kh_val"); return 0; } - kh_val(vars, iter) = dup; + kh_val(vars, iter) = dup; //NOLINT return 1; }