]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
Some more Clang-Tidy silencing
authorOto Šťáva <oto.stava@nic.cz>
Wed, 29 May 2024 14:04:45 +0000 (16:04 +0200)
committerOto Šťáva <oto.stava@nic.cz>
Tue, 4 Jun 2024 11:05:00 +0000 (13:05 +0200)
.clang-tidy
daemon/session2.h
daemon/tls.c
lib/rules/api.c
lib/rules/local-addr.c
lib/rules/zonefile.c

index ecc9a62144cfedb7c833e1e9fe3dd20f63f9c80b..bc1d69c3e981c2f5f18531bea6fcf885c89fa54b 100644 (file)
@@ -1,43 +1,51 @@
 ---
-Checks:
-  - bugprone-*
-  - cert-*
-  - google-readability-casting
-  - misc-*
-  - readability-*
+Checks: |-
+  bugprone-*,
+  cert-*,
+  google-readability-casting,
+  misc-*,
+  readability-*,
 
-  - -bugprone-assignment-in-if-condition  # we explicitly put assignments into parentheses so they are very visible
-  - -bugprone-branch-clone
-  - -bugprone-easily-swappable-parameters
-  - -bugprone-inc-dec-in-conditions
-  - -bugprone-multi-level-implicit-pointer-conversion
-  - -bugprone-narrowing-conversions
-  - -bugprone-sizeof-expression  # may be useful, but it's utterly broken
-  - -bugprone-suspicious-string-compare
-  - -cert-dcl03-c
-  - -clang-analyzer-deadcode.DeadStores
-  - -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling
-  - -clang-analyzer-unix.Malloc
-  - -clang-analyzer-valist.Uninitialized
-  - -clang-analyzer-optin.core.EnumCastOutOfRange  # libknot uses enums as flags
-  - -misc-include-cleaner
-  - -misc-macro-parentheses
-  - -misc-no-recursion
-  - -misc-static-assert
-  - -misc-unused-parameters
-  - -readability-avoid-nested-conditional-operator
-  - -readability-avoid-unconditional-preprocessor-if
-  - -readability-braces-*
-  - -readability-cognitive-complexity
-  - -readability-else-after-return
-  - -readability-function-cognitive-complexity
-  - -readability-identifier-length
-  - -readability-isolate-declaration
-  - -readability-magic-numbers
-  - -readability-non-const-parameter
-  - -readability-redundant-declaration
-WarningsAsErrors: 'cert-*,clang-analyzer-*,misc-*,readability-*,-readability-non-const-parameter'
-HeaderFilterRegex: 'contrib/ucw/*.h'
+  -bugprone-assignment-in-if-condition,
+  -bugprone-branch-clone,
+  -bugprone-easily-swappable-parameters,
+  -bugprone-inc-dec-in-conditions,
+  -bugprone-multi-level-implicit-pointer-conversion,
+  -bugprone-narrowing-conversions,
+  -bugprone-not-null-terminated-result,
+  -bugprone-sizeof-expression,
+  -bugprone-suspicious-string-compare,
+  -cert-dcl03-c,
+  -clang-analyzer-deadcode.DeadStores,
+  -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
+  -clang-analyzer-unix.Malloc,
+  -clang-analyzer-valist.Uninitialized,
+  -clang-analyzer-optin.core.EnumCastOutOfRange,
+  -misc-include-cleaner,
+  -misc-macro-parentheses,
+  -misc-no-recursion,
+  -misc-static-assert,
+  -misc-unused-parameters,
+  -readability-avoid-nested-conditional-operator,
+  -readability-avoid-unconditional-preprocessor-if,
+  -readability-braces-*,
+  -readability-cognitive-complexity,
+  -readability-else-after-return,
+  -readability-function-cognitive-complexity,
+  -readability-identifier-length,
+  -readability-isolate-declaration,
+  -readability-magic-numbers,
+  -readability-non-const-parameter,
+  -readability-redundant-declaration,
+
+WarningsAsErrors: |-
+  cert-*,
+  clang-analyzer-*,
+  misc-*,
+  readability-*,
+  -readability-non-const-parameter,
+
+HeaderFilterRegex: '(contrib/ucw/*.h|/usr/*.h)'
 CheckOptions:
   - key:             readability-identifier-naming
     value:           'lower_case'
index ada57af25cbbd882bca92768107866dd0362cf71..b43d8fc13a999782c09c268c326d4fb9bfbe7304 100644 (file)
@@ -854,7 +854,7 @@ struct session2 {
  * individual layer implementations to determine the lifetime of the data
  * pointed to by the parameters. */
 struct session2 *session2_new(enum session2_transport_type transport_type,
-                              enum kr_proto layer_grp,
+                              enum kr_proto proto,
                               struct protolayer_data_param *layer_param,
                               size_t layer_param_count,
                               bool outgoing);
index 90271bc8e29d5f05070a7e97b02e8025d97108f5..a5169ae36c1179e2ee683a03fc133273dc26c0c5 100644 (file)
@@ -218,6 +218,11 @@ static ssize_t kres_gnutls_vec_push(gnutls_transport_ptr_t h, const giovec_t * i
                return 0;
        }
 
+       if (kr_fails_assert(iovcnt > 0)) {
+               errno = EINVAL;
+               return -1;
+       }
+
        size_t total_len = 0;
        for (int i = 0; i < iovcnt; i++)
                total_len += iov[i].iov_len;
index c10cbb0b116f16e51e2175efc4922cae9509ad31..8e908a7afda19fcb84d52db11ac134fdfaf2ab8c 100644 (file)
@@ -158,7 +158,7 @@ int kr_rules_init(const char *path, size_t maxsize)
                // Later we might improve it to auto-resize in case of running out of space.
                // Caveat: mdb_env_set_mapsize() can only be called without transactions open.
                .maxsize = maxsize ? maxsize :
-                       (sizeof(size_t) > 4 ? 2048 : 500) * 1024*(size_t)1024,
+                       (size_t)(sizeof(size_t) > 4 ? 2048 : 500) * 1024*1024,
        };
        int ret = the_rules->api->open(&the_rules->db, &the_rules->stats, &opts, NULL);
        /* No persistence - we always refill from config for now.
@@ -848,8 +848,8 @@ static int subnet_encode(const struct sockaddr *addr, int sub_len, uint8_t buf[3
                uint16_t x = a[i] * 85; // interleave by zero bits
                uint8_t sub_mask = 255 >> (8 - MIN(sub_len, 8));
                uint16_t r = x | (sub_mask * 85 * 2);
-               buf[2*i] = r / 256;
-               buf[2*i + 1] = r % 256;
+               buf[(ssize_t)2*i] = r / 256;
+               buf[(ssize_t)2*i + 1] = r % 256;
        }
        return i * 2;
 }
@@ -870,9 +870,9 @@ bool subnet_is_prefix(uint8_t a, uint8_t b)
 }
 
 #define KEY_PREPEND(key, arr) do { \
-               key.data -= sizeof(arr); \
-               key.len  += sizeof(arr); \
-               memcpy(key.data, arr, sizeof(arr)); \
+               (key).data -= sizeof(arr); \
+               (key).len  += sizeof(arr); \
+               memcpy((key).data, arr, sizeof(arr)); \
        } while (false)
 
 int kr_view_insert_action(const char *subnet, const char *dst_subnet,
index 787639df177a6ea68890c5e5bfca3075b1b21f1d..cd5d456b4da7e07973d84cfae2d8e5dc46bad3d5 100644 (file)
@@ -67,7 +67,7 @@ static const knot_dname_t * raw_addr2reverse(const uint8_t *raw_addr, int family
        #undef REV_MAXLEN
 
        if (family == AF_INET) {
-               snprintf(reverse_addr, sizeof(reverse_addr),
+               (void)snprintf(reverse_addr, sizeof(reverse_addr),
                         "%d.%d.%d.%d.in-addr.arpa.",
                         raw_addr[3], raw_addr[2], raw_addr[1], raw_addr[0]);
        } else if (family == AF_INET6) {
index 74a7317defa9e7e7b43586e702294a0f122fc170..d308f3755490b1e93af4cbdbf31e5b5bfe3655ab 100644 (file)
@@ -203,6 +203,7 @@ static void process_record(zs_scanner_t *s)
                KR_RRTYPE_GET_STR(type_str, s->r_type);
                kr_log_warning(RULES, "skipping unsupported RR type %s\n", type_str);
                return;
+       default:; // Continue below
        }
        if (knot_rrtype_is_metatype(s->r_type))
                goto unsupported_type;
@@ -245,7 +246,7 @@ int kr_rule_zonefile(const struct kr_rule_zonefile_config *c)
 
        s_data_t s_data = { 0 };
        s_data.c = c;
-       s_data.pool = mm_ctx_mempool2(64 * 1024);
+       s_data.pool = mm_ctx_mempool2((size_t)64 * 1024);
        s_data.rrs = trie_create(s_data.pool);
        ret = zs_set_processing(s, process_record, NULL, &s_data);
        if (kr_fails_assert(ret == 0))