]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
treewide nitpick: fix -Wshadow
authorVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 30 Nov 2018 11:15:15 +0000 (12:15 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 8 Jan 2019 12:06:32 +0000 (12:06 +0000)
None of these seemed to be errors, but it seems better to clear these.

daemon/network.c
daemon/tls.c
daemon/tls_ephemeral_credentials.c
daemon/zimport.c
lib/cache/nsec3.c
lib/cache/peek.c
lib/dnssec.c
lib/dnssec/nsec3.c
lib/zonecut.c
modules/hints/hints.c
tests/test_queue.c

index d7f5419fc8d377e7c5bbae32f944b6b63fb89630..6a148bb168bd8324be6e86301877d27b351f7be9 100644 (file)
 #if (__linux__ && SO_REUSEPORT)
   #define handle_init(type, loop, handle, family) do { \
        uv_ ## type ## _init_ex((loop), (handle), (family)); \
-       uv_os_fd_t fd = 0; \
-       if (uv_fileno((uv_handle_t *)(handle), &fd) == 0) { \
-               int on = 1; \
-               int ret = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)); \
-               if (ret) { \
-                       return ret; \
+       uv_os_fd_t hi_fd = 0; \
+       if (uv_fileno((uv_handle_t *)(handle), &hi_fd) == 0) { \
+               int hi_on = 1; \
+               int hi_ret = setsockopt(hi_fd, SOL_SOCKET, SO_REUSEPORT, &hi_on, sizeof(hi_on)); \
+               if (hi_ret) { \
+                       return hi_ret; \
                } \
        } \
   } while (0)
index 508bcf8546a4fc01ba0daa95f0824939c8ea66cf..fd7fac51a054148bd52d1b7656da7563013575d2 100644 (file)
@@ -1079,8 +1079,8 @@ static int client_verify_certificate(gnutls_session_t tls_session)
                }
 
                DEBUG_MSG("[tls_client] received pin  : %s\n", cert_pin);
-               for (size_t i = 0; i < ctx->params->pins.len; ++i) {
-                       const char *pin = ctx->params->pins.at[i];
+               for (size_t j = 0; j < ctx->params->pins.len; ++j) {
+                       const char *pin = ctx->params->pins.at[j];
                        bool match = (strcmp(cert_pin, pin) == 0);
                        DEBUG_MSG("[tls_client] configured pin: %s matches? %s\n",
                                  pin, match ? "yes" : "no");
index 7c26d24b8742a4a143344307ce4031e255bcdabf..a305eb18ef847679bfaa044c41bb807bcb5f64b1 100644 (file)
  * lock based on a filename.  At the moment it's POSIX-only, but it
  * should be abstract enough of an interface to make an implementation
  * for non-posix systems if anyone cares. */
-typedef int lock;
-static bool _lock_is_invalid(lock lock)
+typedef int lock_t;
+static bool _lock_is_invalid(lock_t lock)
 {
        return lock == -1;
 }
 /* a blocking lock on a given filename */
-static lock _lock_filename(const char *fname)
+static lock_t _lock_filename(const char *fname)
 {
-       lock lockfd = open(fname, O_RDONLY|O_CREAT, 0400);
+       lock_t lockfd = open(fname, O_RDONLY|O_CREAT, 0400);
        if (lockfd == -1)
                return lockfd;
        /* this should be a non-blocking lock */
@@ -53,7 +53,7 @@ static lock _lock_filename(const char *fname)
        }
        return lockfd; /* for cleanup later */
 }
-static void _lock_unlock(lock *lock, const char *fname)
+static void _lock_unlock(lock_t *lock, const char *fname)
 {
        if (lock && !_lock_is_invalid(*lock)) {
                flock(*lock, LOCK_UN);
@@ -68,7 +68,7 @@ static gnutls_x509_privkey_t get_ephemeral_privkey ()
        gnutls_x509_privkey_t privkey = NULL;
        int err;
        gnutls_datum_t data = { .data = NULL, .size = 0 };
-       lock lock;
+       lock_t lock;
        int datafd = -1;
 
        /* Take a lock to ensure that two daemons started concurrently
index 1eda47aa92541f8f0024652f9e21e108b5db52d8..ede0dbf7db52f13e73d09c441c9166392b757875 100644 (file)
@@ -501,14 +501,14 @@ static void zi_zone_process(uv_timer_t* handle)
                goto finish;
        }
 
-       knot_rrset_t *rr = map_get(&z_import->rrset_indexed, key);
-       if (!rr) {
+       knot_rrset_t *rr_key = map_get(&z_import->rrset_indexed, key);
+       if (!rr_key) {
                /* DNSKEY MUST be here. If not found - fail. */
                kr_log_error("[zimport] DNSKEY not found for `%s`, fail\n", zone_name_str);
                failed = 1;
                goto finish;
        }
-       z_import->key = rr;
+       z_import->key = rr_key;
 
        VERBOSE_MSG(NULL, "started: zone: '%s'\n", zone_name_str);
 
@@ -516,16 +516,16 @@ static void zi_zone_process(uv_timer_t* handle)
 
        /* Import DNSKEY at first step. If any validation problems will appear,
         * cancel import of whole zone. */
-       KR_DNAME_GET_STR(qname_str, rr->owner);
-       KR_RRTYPE_GET_STR(type_str, rr->type);
+       KR_DNAME_GET_STR(kname_str, rr_key->owner);
+       KR_RRTYPE_GET_STR(ktype_str, rr_key->type);
 
-       VERBOSE_MSG(NULL, "importing: qname: '%s' type: '%s'\n",
-                   qname_str, type_str);
+       VERBOSE_MSG(NULL, "importing: name: '%s' type: '%s'\n",
+                   kname_str, ktype_str);
 
-       int res = zi_rrset_import(z_import, rr);
+       int res = zi_rrset_import(z_import, rr_key);
        if (res != 0) {
                VERBOSE_MSG(NULL, "import failed: qname: '%s' type: '%s'\n",
-                           qname_str, type_str);
+                           kname_str, ktype_str);
                failed = 1;
                goto finish;
        }
@@ -538,16 +538,16 @@ static void zi_zone_process(uv_timer_t* handle)
                        continue;
                }
 
-               KR_DNAME_GET_STR(qname_str, rr->owner);
+               KR_DNAME_GET_STR(name_str, rr->owner);
                KR_RRTYPE_GET_STR(type_str, rr->type);
-               VERBOSE_MSG(NULL, "importing: qname: '%s' type: '%s'\n",
-                           qname_str, type_str);
-               int res = zi_rrset_import(z_import, rr);
-               if (res == 0) {
+               VERBOSE_MSG(NULL, "importing: name: '%s' type: '%s'\n",
+                           name_str, type_str);
+               int ret = zi_rrset_import(z_import, rr);
+               if (ret == 0) {
                        ++ns_imported;
                } else {
-                       VERBOSE_MSG(NULL, "import failed: qname: '%s' type: '%s'\n",
-                                   qname_str, type_str);
+                       VERBOSE_MSG(NULL, "import failed: name: '%s' type: '%s'\n",
+                                   name_str, type_str);
                        ++failed;
                }
                z_import->rrset_sorted.at[i] = NULL;
@@ -570,16 +570,16 @@ static void zi_zone_process(uv_timer_t* handle)
                        continue;
                }
 
-               KR_DNAME_GET_STR(qname_str, rr->owner);
+               KR_DNAME_GET_STR(name_str, rr->owner);
                KR_RRTYPE_GET_STR(type_str, rr->type);
-               VERBOSE_MSG(NULL, "importing: qname: '%s' type: '%s'\n",
-                           qname_str, type_str);
+               VERBOSE_MSG(NULL, "importing: name: '%s' type: '%s'\n",
+                           name_str, type_str);
                res = zi_rrset_import(z_import, rr);
                if (res == 0) {
                        ++other_imported;
                } else {
-                       VERBOSE_MSG(NULL, "import failed: qname: '%s' type: '%s'\n",
-                                   qname_str, type_str);
+                       VERBOSE_MSG(NULL, "import failed: name: '%s' type: '%s'\n",
+                                   name_str, type_str);
                        ++failed;
                }
        }
index 2139f79b24ac3de31a188e71fbef16a2ad07cec9..d2ae72a6d6570d7560a21ff5ba148266d09301cf 100644 (file)
@@ -339,8 +339,10 @@ int nsec3_encloser(struct key *k, struct answer *ans,
                /* Basic checks OK -> materialize data, cleaning any previous
                 * records on that answer index (unsuccessful attempts). */
                knot_dname_t owner[KNOT_DNAME_MAXLEN];
-               int ret = dname_wire_reconstruct(owner, k->zname, hash_low);
-               if (unlikely(ret)) continue;
+               {
+                       int ret = dname_wire_reconstruct(owner, k->zname, hash_low);
+                       if (unlikely(ret)) continue;
+               }
                const int ans_id = (exact_match && name_labels + 1 == last_nxproven_labels)
                                 ? AR_CPE : AR_NSEC;
                {
index d81ced82f163569a662cc321d78e2be0443a5fce..1af1627adce978ef60c29b8ccb86386fffa542a4 100644 (file)
@@ -133,12 +133,14 @@ int peek_nosync(kr_layer_t *ctx, knot_pkt_t *pkt)
 
        /**** 1. find the name or the closest (available) zone, not considering wildcards
         **** 1a. exact name+type match (can be negative answer in insecure zones) */
-       knot_db_val_t key = key_exact_type_maypkt(k, qry->stype);
-       knot_db_val_t val = { NULL, 0 };
-       ret = cache_op(cache, read, &key, &val, 1);
-       if (!ret) {
-               /* found an entry: test conditions, materialize into pkt, etc. */
-               ret = found_exact_hit(ctx, pkt, val, lowest_rank);
+       {
+               knot_db_val_t key = key_exact_type_maypkt(k, qry->stype);
+               knot_db_val_t val = { NULL, 0 };
+               ret = cache_op(cache, read, &key, &val, 1);
+               if (!ret) {
+                       /* found an entry: test conditions, materialize into pkt, etc. */
+                       ret = found_exact_hit(ctx, pkt, val, lowest_rank);
+               }
        }
        if (ret && ret != -abs(ENOENT)) {
                VERBOSE_MSG(qry, "=> exact hit error: %d %s\n", ret, kr_strerror(ret));
@@ -252,7 +254,7 @@ int peek_nosync(kr_layer_t *ctx, knot_pkt_t *pkt)
                /* Assuming k->buf still starts with zone's prefix,
                 * look up the SOA in cache. */
                k->buf[0] = k->zlf_len;
-               key = key_exact_type(k, KNOT_RRTYPE_SOA);
+               knot_db_val_t key = key_exact_type(k, KNOT_RRTYPE_SOA);
                knot_db_val_t val = { NULL, 0 };
                ret = cache_op(cache, read, &key, &val, 1);
                const struct entry_h *eh;
index 84cdb57c25e877a5480e4a14f7931df93ab66423..4f8ad8a260746963b3730ffc09f7d180878a88fb 100644 (file)
@@ -219,14 +219,14 @@ static int kr_rrset_validate_with_key(kr_rrset_validation_ctx_t *vctx,
                                continue;
                        }
                        vctx->rrs_counters.matching_name_type++;
-                       int ret = validate_rrsig_rr(&val_flgs, covered_labels, rdata_j,
+                       int retv = validate_rrsig_rr(&val_flgs, covered_labels, rdata_j,
                                              keys->owner, key_rdata, keytag,
                                              zone_name, timestamp, vctx);
-                       if (ret == kr_error(EAGAIN)) {
+                       if (retv == kr_error(EAGAIN)) {
                                kr_dnssec_key_free(&created_key);
-                               vctx->result = ret;
-                               return ret;
-                       } else if (ret != 0) {
+                               vctx->result = retv;
+                               return retv;
+                       } else if (retv != 0) {
                                continue;
                        }
                        if (val_flgs & FLG_WILDCARD_EXPANSION) {
index 2f61b03576efcba232860bdcf55fb2b355920905..4c2ef9597b15803206b1fe398fd88126ae94d546 100644 (file)
@@ -418,16 +418,16 @@ static int closest_encloser_proof(const knot_pkt_t *pkt,
                        next_closer = knot_wire_next_label(next_closer, NULL);
                }
                for (unsigned j = 0; j < sec->count; ++j) {
-                       const knot_rrset_t *rrset = knot_pkt_rr(sec, j);
-                       if (rrset->type != KNOT_RRTYPE_NSEC3) {
+                       const knot_rrset_t *rrset_j = knot_pkt_rr(sec, j);
+                       if (rrset_j->type != KNOT_RRTYPE_NSEC3) {
                                continue;
                        }
-                       ret = covers_name(&flags, rrset, next_closer);
+                       ret = covers_name(&flags, rrset_j, next_closer);
                        if (ret != 0) {
                                return ret;
                        }
                        if (flags & FLG_NAME_COVERED) {
-                               covering = rrset;
+                               covering = rrset_j;
                                break;
                        }
                }
index 0148ae91b25ecad1bb79d9cce77d5835da5cec51..5e54d9760073ecc4004f901651884c175ac5025e 100644 (file)
@@ -461,9 +461,9 @@ static int fetch_ns(struct kr_context *ctx, struct kr_zonecut *cut,
                            || (aqpf->AWAIT_IPV6 && aq->stype == KNOT_RRTYPE_AAAA)) {
                                if (knot_dname_in_bailiwick(ns_name,
                                                        aq->parent->zone_cut.name)) {
-                                       for (int i = 0; i < 2; ++i)
-                                               if (infos[i] == AI_UNKNOWN)
-                                                       infos[i] = AI_CYCLED;
+                                       for (int j = 0; j < 2; ++j)
+                                               if (infos[j] == AI_UNKNOWN)
+                                                       infos[j] = AI_CYCLED;
                                        break;
                                }
                        } else {
index 1edfcd71941c08a61fd69335df4809bee07a1ae2..e5d86dbaecfe258678a46a29dffbd5168c0b50a0 100644 (file)
@@ -285,29 +285,29 @@ static int del_pair(struct hints_data *data, const char *name, const char *addr)
                kr_zonecut_del(&data->reverse_hints, reverse_key, key, key_len);
                return kr_zonecut_del(&data->hints, key,
                                        kr_inaddr(&ia.ip), kr_inaddr_len(&ia.ip));
-       } else {
-               /* Find a matching name */
-               pack_t *addr_set = kr_zonecut_find(&data->hints, key);
-               if (!addr_set || addr_set->len == 0) {
-                       return kr_error(ENOENT);
-               }
+       }
+       /* We're removing everything for the name;
+        * first find the name's pack */
+       pack_t *addr_set = kr_zonecut_find(&data->hints, key);
+       if (!addr_set || addr_set->len == 0) {
+               return kr_error(ENOENT);
+       }
 
-               /* Remove address records in hints from reverse_hints. */
-               uint8_t *addr = pack_head(*addr_set);
-               while (addr != pack_tail(*addr_set)) {
-                       void *addr_val = pack_obj_val(addr);
-                       int family = pack_obj_len(addr) == kr_family_len(AF_INET)
-                                       ? AF_INET : AF_INET6;
-                       const knot_dname_t *reverse_key = raw_addr2reverse(addr_val, family);
-                       if (reverse_key != NULL) {
-                               kr_zonecut_del(&data->reverse_hints, reverse_key, key, key_len);
-                       }
-                       addr = pack_obj_next(addr);
+       /* Remove address records in hints from reverse_hints. */
+
+       for (uint8_t *a = pack_head(*addr_set); a != pack_tail(*addr_set);
+                                               a = pack_obj_next(a)) {
+               void *addr_val = pack_obj_val(a);
+               int family = pack_obj_len(a) == kr_family_len(AF_INET)
+                               ? AF_INET : AF_INET6;
+               const knot_dname_t *reverse_key = raw_addr2reverse(addr_val, family);
+               if (reverse_key != NULL) {
+                       kr_zonecut_del(&data->reverse_hints, reverse_key, key, key_len);
                }
-               
-               /* Remove the whole name. */
-               return kr_zonecut_del_all(&data->hints, key);
        }
+
+       /* Remove the whole name. */
+       return kr_zonecut_del_all(&data->hints, key);
 }
 
 static int load_file(struct kr_module *module, const char *path)
index 9ed6fc98e80e70f1ca19d1b48240d47c4f40f6b5..0b1494424e04c3ca46bd00f3e241c90165bfb0c1 100644 (file)
@@ -42,13 +42,15 @@ static void test_int(void **state_)
        assert_int_equal(queue_len(q), 3 + 99);
 
        /* Basic iterator test. */
-       int i = 0;
-       for (queue_int_it_t it = queue_it_begin(q); !queue_it_finished(it);
-            queue_it_next(it)) {
-               ++queue_it_val(it);
-               ++i;
+       {
+               int i = 0;
+               for (queue_int_it_t it = queue_it_begin(q); !queue_it_finished(it);
+                    queue_it_next(it)) {
+                       ++queue_it_val(it);
+                       ++i;
+               }
+               assert_int_equal(queue_len(q), i);
        }
-       assert_int_equal(queue_len(q), i);
 
        queue_deinit(q);
        queue_init(q);