]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
gitlabci: fix lint:tidy
authorTomas Krizek <tomas.krizek@nic.cz>
Thu, 21 Feb 2019 13:11:33 +0000 (14:11 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 12 Mar 2019 09:43:35 +0000 (10:43 +0100)
18 files changed:
.clang-tidy
.gitlab-ci.yml
bench/meson.build
client/meson.build
contrib/meson.build
daemon/meson.build
lib/dnssec/signature.c
lib/meson.build
meson.build
modules/bogus_log/meson.build
modules/dnstap/meson.build
modules/edns_keepalive/meson.build
modules/hints/meson.build
modules/nsid/meson.build
modules/policy/meson.build
modules/stats/meson.build
tests/pytests/meson.build
tests/unit/meson.build

index fa191ddfd030c9e7b88f928cb4160fd84e96a2ec..b496044c4f8e94b04f029e7ff4a93e0d6cbf8fdf 100644 (file)
@@ -1,5 +1,5 @@
 ---
-Checks: 'bugprone-*,cert-*,-clang-analyzer-unix.Malloc,-clang-analyzer-deadcode.DeadStores,-clang-analyzer-valist.Uninitialized,readability-*,-readability-braces-*,-readability-else-after-return,-readability-redundant-declaration,-readability-non-const-parameter,google-readability-casting,misc-*,-misc-macro-parentheses,-misc-unused-parameters'
+Checks: 'bugprone-*,cert-*,-cert-dcl03-c,-clang-analyzer-unix.Malloc,-clang-analyzer-deadcode.DeadStores,-clang-analyzer-valist.Uninitialized,readability-*,-readability-braces-*,-readability-else-after-return,-readability-redundant-declaration,-readability-non-const-parameter,google-readability-casting,misc-*,-misc-static-assert,-misc-macro-parentheses,-misc-unused-parameters'
 WarningsAsErrors: 'cert-*,misc-*,readability-*,clang-analyzer-*,-readability-non-const-parameter'
 HeaderFilterRegex: 'contrib/ucw/*.h'
 CheckOptions:
@@ -8,4 +8,4 @@ CheckOptions:
   - key:             readability-function-size.StatementThreshold
     value:           '400'
   - key:             readability-function-size.LineThreshold
-    value:           '500'
\ No newline at end of file
+    value:           '500'
index e69bc359211bccd309c1ecce663d4e254e8fdc8f..6f6b1627bc611e496985fd455238e7cfdce95d9b 100644 (file)
@@ -131,6 +131,14 @@ kres-gen:
   tags:
     - docker
 
+lint:tidy:
+  <<: *test
+  before_script: []
+  tags:
+    - docker
+  script:
+    - ninja -C build_ci* tidy
+
 lint:pedantic:
   <<: *test_nodep
   tags:
@@ -155,16 +163,6 @@ lint:lua:
   tags:
     - docker
 
-lint:c:
-  stage: test
-  except:
-    - master
-  dependencies: []  # do not download build artifacts
-  script:
-    - make lint-c CLANG_TIDY="clang-tidy -quiet"
-  tags:
-    - docker
-
 lint:clang-scan-build:
   stage: test
   except:
index 2d466ab01b41341fb047ae263a365c489b64825a..b542d2196290a802094165e565d14840877e8463 100644 (file)
@@ -1,8 +1,8 @@
 # bench
 
-bench_lru_src = [
+bench_lru_src = files([
   'bench_lru.c',
-]
+])
 
 cc = meson.get_compiler('c')
 m_dep = cc.find_library('m', required : false)
index cbbabf677b7c30d04e04841cefccd3a34c402bda..9d39a9505148f63a95dfa830e57b98d94a77cd55 100644 (file)
@@ -1,8 +1,9 @@
 # client
 
-kresc_src = [
+kresc_src = files([
   'kresc.c',
-]
+])
+c_src_lint += kresc_src
 
 build_client = false
 if not get_option('client').disabled()
index 0c7aeb1cafbf4ceab57731934f197bab75ff9614..4c420e07da4a01f84fcdf48d73a0e583de0a6cc7 100644 (file)
@@ -1,6 +1,6 @@
 # contrib
 
-contrib_src = [
+contrib_src = files([
   'ccan/asprintf/asprintf.c',
   'ccan/ilog/ilog.c',
   'ccan/json/json.c',
@@ -9,7 +9,7 @@ contrib_src = [
   'murmurhash3/murmurhash3.c',
   'base32hex.c',
   'base64.c'
-]
+])
 
 contrib_inc = include_directories('.')
 
index 902f11494c7b13afef1fe882d646c959d7e7406f..4b9805275e2878c1849eb63b547829cddac7e71a 100644 (file)
@@ -1,6 +1,6 @@
 # daemon
 
-kresd_src = [
+kresd_src = files([
   'bindings/cache.c',
   'bindings/event.c',
   'bindings/impl.c',
@@ -18,7 +18,8 @@ kresd_src = [
   'tls_session_ticket-srv.c',
   'worker.c',
   'zimport.c',
-]
+])
+c_src_lint += kresd_src
 
 config_tests += [
   ['cache.clear', files('cache.test/clear.test.lua')],
index 356bf1400850f9c38025a5b5d595419cb8f1404a..f5d7182ab8e6ac883c96ad1ad894b2fd5d7542f2 100644 (file)
@@ -90,8 +90,8 @@ int kr_authenticate_referral(const knot_rrset_t *ref, const dnssec_key_t *key)
 static int adjust_wire_ttl(uint8_t *wire, size_t wire_size, uint32_t new_ttl)
 {
        assert(wire);
-       assert(sizeof(uint16_t) == 2);
-       assert(sizeof(uint32_t) == 4);
+       static_assert(sizeof(uint16_t) == 2, "uint16_t must be exactly 2 bytes");
+       static_assert(sizeof(uint32_t) == 4, "uint32_t) must be exactly 4 bytes");
        uint16_t rdlen;
 
        int ret;
index 20d97bed5cb00122e2815be87c9c6ed3afeda045..0101fb3ac2838ae83b4c692cecbe3815f6f43f5b 100644 (file)
@@ -1,6 +1,6 @@
 # libkres
 
-libkres_src = [
+libkres_src = files([
   'cache/api.c',
   'cache/cdb_lmdb.c',
   'cache/entry_list.c',
@@ -28,9 +28,10 @@ libkres_src = [
   'rplan.c',
   'utils.c',
   'zonecut.c',
-]
+])
+c_src_lint += libkres_src
 
-libkres_headers = [
+libkres_headers = files([
   'cache/api.h',
   'cache/cdb_api.h',
   'cache/cdb_lmdb.h',
@@ -55,7 +56,7 @@ libkres_headers = [
   'rplan.h',
   'utils.h',
   'zonecut.h',
-]
+])
 
 unit_tests += [
   ['array', files('generic/test_array.c')],
index a7bfec9174a405ac3340bb036d58c4200813998e..114c66250839a8ff054951aef8205fe80eed95c8 100644 (file)
@@ -96,6 +96,9 @@ add_project_arguments(
   language: 'c',
 )
 
+# Files for clang-tidy lint
+c_src_lint = files()
+
 # Lists of tests
 # These lists are added to from subdir() and finally used in tests/*
 
@@ -151,6 +154,21 @@ if get_option('bench').enabled()
 endif
 
 
+# Lint
+message('--- lint dependencies ---')
+clangtidy = find_program('clang-tidy', required: false)
+message('-------------------------')
+if clangtidy.found()
+  run_target(
+    'tidy',
+    command: [
+      clangtidy,
+      '-quiet',
+      '-p', meson.build_root(),
+    ] + c_src_lint
+  )
+endif
+
 # Tests
 subdir('tests')
 
index 08419b1e350a4fe1b7810801770e497df5504033..8fc93f3659d1cf95a63388cccdb798c2fe62704e 100644 (file)
@@ -1,8 +1,9 @@
 # C module: bogus_log
 
-bogus_log_src = [
+bogus_log_src = files([
   'bogus_log.c',
-]
+])
+c_src_lint += bogus_log_src
 
 bogus_log_mod = shared_module(
   'bogus_log',
index 2db216c355993bd4bddf8ae6a392c9f008978c4f..ce1fd85a4a8c7338fce11896dd5fc18d8acf187f 100644 (file)
@@ -1,8 +1,8 @@
 # C module: dnstap
 
-dnstap_src = [
+dnstap_src = files([
   'dnstap.c',
-]
+])
 
 ## dnstap dependencies
 message('--- dnstap module dependencies ---')
@@ -14,6 +14,8 @@ message('----------------------------------')
 
 # build dnstap if deps are found
 if libprotobuf_c.found() and libfstrm.found() and protoc_c.found()
+  c_src_lint += dnstap_src
+
   # generate protobuf-c sources using protoc-c
   dnstap_pb = custom_target(
     'dnstap_pb',
index f94c0cc599e9fa96bb2d4481d65ed57c7498d71f..94ce98ba8f162319bd72a3da33c6a061a430965a 100644 (file)
@@ -1,8 +1,9 @@
 # C module: edns_keepalive
 
-edns_keepalive_src = [
+edns_keepalive_src = files([
   'edns_keepalive.c',
-]
+])
+c_src_lint += edns_keepalive_src
 
 edns_keepalive_mod = shared_module(
   'edns_keepalive',
index 41fa0c3d7dc2a238e13641ec1e3ee9ee09ff7d71..d87587a996b6f0825d5a938ac96c193be00b6fed 100644 (file)
@@ -1,8 +1,9 @@
 # C module: hints
 
-hints_src = [
+hints_src = files([
   'hints.c',
-]
+])
+c_src_lint += hints_src
 
 hints_mod = shared_module(
   'hints',
index 1b796bb03ccc4625e9440c0b9ca56b52ef3dd0b6..114a8b37f948f8da0f64d1be7dfbdaaac3b34407 100644 (file)
@@ -1,8 +1,9 @@
 # C module: nsid
 
-nsid_src = [
+nsid_src = files([
   'nsid.c',
-]
+])
+c_src_lint += nsid_src
 
 nsid_mod = shared_module(
   'nsid',
index cea0f20a46fe47ea740f590331730d68255651ee..4f324e04e3dbbb031339eed597b27b07bc874bae 100644 (file)
@@ -22,11 +22,11 @@ if lua_ac_submodule.returncode() != 0
 endif
 
 # compile bundled lua-aho-corasick lib
-lua_ac_src = [
+lua_ac_src = files([
   'lua-aho-corasick/ac_fast.cxx',
   'lua-aho-corasick/ac_lua.cxx',
   'lua-aho-corasick/ac_slow.cxx',
-]
+])
 
 lua_ac_lib = shared_module(
   'ahocorasick',
index 4cea87219ee2fed3fa6446644efd21171627d675..908638ead39ecbe3d35947e54cc23ed458dbe1e2 100644 (file)
@@ -1,8 +1,9 @@
 # C module: stats
 
-stats_src = [
+stats_src = files([
   'stats.c',
-]
+])
+c_src_lint += stats_src
 
 integr_tests += [
   ['stats', join_paths(meson.current_source_dir(), 'test.integr')],
index 96ccb22ea436d422014b2d4ae16d498a43e86eae..faef8f5e9fd52c4288fd94097d4974d979710199 100644 (file)
@@ -10,10 +10,10 @@ py3_deps += [
 ]
 
 # compile tlsproxy
-tlsproxy_src = [
+tlsproxy_src = files([
   'proxy/tlsproxy.c',
   'proxy/tls-proxy.c',
-]
+])
 tlsproxy = executable(
   'tlsproxy',
   tlsproxy_src,
index 43ca767508d927147d5e75de786e7598d77d2020..a78f3f7bc7fec2ff92d0452ec7bc98de50f11296 100644 (file)
@@ -1,9 +1,9 @@
 # tests: unit
 
 # mock module for test_module
-mock_cmodule_src = [
+mock_cmodule_src = files([
   'mock_cmodule.c',
-]
+])
 
 mock_cmodule_lib = shared_library(
   'mock_cmodule',