diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-03-03 13:07:10 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-03-05 07:10:13 +0900 |
commit | f5fbe71d956957ca7ceb6777aed05a416fc83a43 (patch) | |
tree | 67358d417604030867a979f216bbb79939a37844 /src/resolve | |
parent | ef1e0b9a461c4baa12bdda47579c2c017209c3be (diff) | |
download | systemd-f5fbe71d956957ca7ceb6777aed05a416fc83a43.tar.gz |
tree-wide: use UINT64_MAX or friends
Diffstat (limited to 'src/resolve')
-rw-r--r-- | src/resolve/resolved-dns-cache.c | 2 | ||||
-rw-r--r-- | src/resolve/resolved-dns-dnssec.c | 6 | ||||
-rw-r--r-- | src/resolve/resolved-dns-packet.c | 24 | ||||
-rw-r--r-- | src/resolve/resolved-dns-rr.c | 18 | ||||
-rw-r--r-- | src/resolve/resolved-dns-rr.h | 2 | ||||
-rw-r--r-- | src/resolve/resolved-dns-transaction.c | 4 | ||||
-rw-r--r-- | src/resolve/resolved-mdns.c | 2 |
7 files changed, 29 insertions, 29 deletions
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c index 395f983deb..0bf320df88 100644 --- a/src/resolve/resolved-dns-cache.c +++ b/src/resolve/resolved-dns-cache.c @@ -476,7 +476,7 @@ static int dns_cache_put_positive( .rr = dns_resource_record_ref(rr), .answer = dns_answer_ref(answer), .full_packet = dns_packet_ref(full_packet), - .until = calculate_until(rr, (uint32_t) -1, timestamp, false), + .until = calculate_until(rr, UINT32_MAX, timestamp, false), .query_flags = query_flags & CACHEABLE_QUERY_FLAGS, .shared_owner = shared_owner, .dnssec_result = dnssec_result, diff --git a/src/resolve/resolved-dns-dnssec.c b/src/resolve/resolved-dns-dnssec.c index 2f5776b5ed..4b12e48352 100644 --- a/src/resolve/resolved-dns-dnssec.c +++ b/src/resolve/resolved-dns-dnssec.c @@ -490,7 +490,7 @@ static int dnssec_rrsig_prepare(DnsResourceRecord *rrsig) { assert(rrsig->key->type == DNS_TYPE_RRSIG); /* Check if this RRSIG RR is already prepared */ - if (rrsig->n_skip_labels_source != (unsigned) -1) + if (rrsig->n_skip_labels_source != UINT_MAX) return 0; if (rrsig->rrsig.inception > rrsig->rrsig.expiration) @@ -1297,10 +1297,10 @@ static int nsec3_is_good(DnsResourceRecord *rr, DnsResourceRecord *nsec3) { /* Ignore NSEC3 RRs generated from wildcards. If these NSEC3 RRs weren't correctly signed we can't make this * check (since rr->n_skip_labels_source is -1), but that's OK, as we won't trust them anyway in that case. */ - if (!IN_SET(rr->n_skip_labels_source, 0, (unsigned) -1)) + if (!IN_SET(rr->n_skip_labels_source, 0, UINT_MAX)) return 0; /* Ignore NSEC3 RRs that are located anywhere else than one label below the zone */ - if (!IN_SET(rr->n_skip_labels_signer, 1, (unsigned) -1)) + if (!IN_SET(rr->n_skip_labels_signer, 1, UINT_MAX)) return 0; if (!nsec3) diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c index 9778f5ee6b..abc978ab83 100644 --- a/src/resolve/resolved-dns-packet.c +++ b/src/resolve/resolved-dns-packet.c @@ -82,8 +82,8 @@ int dns_packet_new( .rindex = DNS_PACKET_HEADER_SIZE, .allocated = a, .max_size = max_size, - .opt_start = (size_t) -1, - .opt_size = (size_t) -1, + .opt_start = SIZE_MAX, + .opt_size = SIZE_MAX, }; *ret = p; @@ -182,8 +182,8 @@ int dns_packet_dup(DnsPacket **ret, DnsPacket *p) { .rindex = DNS_PACKET_HEADER_SIZE, .allocated = p->size, .max_size = p->max_size, - .opt_start = (size_t) -1, - .opt_size = (size_t) -1, + .opt_start = SIZE_MAX, + .opt_size = SIZE_MAX, }; memcpy(DNS_PACKET_DATA(c), DNS_PACKET_DATA(p), p->size); @@ -736,10 +736,10 @@ int dns_packet_append_opt( assert(rcode >= 0); assert(rcode <= _DNS_RCODE_MAX); - if (p->opt_start != (size_t) -1) + if (p->opt_start != SIZE_MAX) return -EBUSY; - assert(p->opt_size == (size_t) -1); + assert(p->opt_size == SIZE_MAX); saved_size = p->size; @@ -851,12 +851,12 @@ fail: int dns_packet_truncate_opt(DnsPacket *p) { assert(p); - if (p->opt_start == (size_t) -1) { - assert(p->opt_size == (size_t) -1); + if (p->opt_start == SIZE_MAX) { + assert(p->opt_size == SIZE_MAX); return 0; } - assert(p->opt_size != (size_t) -1); + assert(p->opt_size != SIZE_MAX); assert(DNS_PACKET_ARCOUNT(p) > 0); if (p->opt_start + p->opt_size != p->size) @@ -864,7 +864,7 @@ int dns_packet_truncate_opt(DnsPacket *p) { dns_packet_truncate(p, p->opt_start); DNS_PACKET_HEADER(p)->arcount = htobe16(DNS_PACKET_ARCOUNT(p) - 1); - p->opt_start = p->opt_size = (size_t) -1; + p->opt_start = p->opt_size = SIZE_MAX; return 1; } @@ -2458,10 +2458,10 @@ int dns_packet_patch_max_udp_size(DnsPacket *p, uint16_t max_udp_size) { assert(p); assert(max_udp_size >= DNS_PACKET_UNICAST_SIZE_MAX); - if (p->opt_start == (size_t) -1) /* No OPT section, nothing to patch */ + if (p->opt_start == SIZE_MAX) /* No OPT section, nothing to patch */ return 0; - assert(p->opt_size != (size_t) -1); + assert(p->opt_size != SIZE_MAX); assert(p->opt_size >= 5); unaligned_write_be16(DNS_PACKET_DATA(p) + p->opt_start + 3, max_udp_size); diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index 9b94ab59ea..823117e5c9 100644 --- a/src/resolve/resolved-dns-rr.c +++ b/src/resolve/resolved-dns-rr.c @@ -118,7 +118,7 @@ DnsResourceKey* dns_resource_key_ref(DnsResourceKey *k) { /* Static/const keys created with DNS_RESOURCE_KEY_CONST will * set this to -1, they should not be reffed/unreffed */ - assert(k->n_ref != (unsigned) -1); + assert(k->n_ref != UINT_MAX); assert(k->n_ref > 0); k->n_ref++; @@ -130,7 +130,7 @@ DnsResourceKey* dns_resource_key_unref(DnsResourceKey *k) { if (!k) return NULL; - assert(k->n_ref != (unsigned) -1); + assert(k->n_ref != UINT_MAX); assert(k->n_ref > 0); if (k->n_ref == 1) { @@ -342,9 +342,9 @@ bool dns_resource_key_reduce(DnsResourceKey **a, DnsResourceKey **b) { return false; /* We refuse merging const keys */ - if ((*a)->n_ref == (unsigned) -1) + if ((*a)->n_ref == UINT_MAX) return false; - if ((*b)->n_ref == (unsigned) -1) + if ((*b)->n_ref == UINT_MAX) return false; /* Already the same? */ @@ -378,8 +378,8 @@ DnsResourceRecord* dns_resource_record_new(DnsResourceKey *key) { .n_ref = 1, .key = dns_resource_key_ref(key), .expiry = USEC_INFINITY, - .n_skip_labels_signer = (unsigned) -1, - .n_skip_labels_source = (unsigned) -1, + .n_skip_labels_signer = UINT_MAX, + .n_skip_labels_source = UINT_MAX, }; return rr; @@ -1265,7 +1265,7 @@ int dns_resource_record_signer(DnsResourceRecord *rr, const char **ret) { /* Returns the RRset's signer, if it is known. */ - if (rr->n_skip_labels_signer == (unsigned) -1) + if (rr->n_skip_labels_signer == UINT_MAX) return -ENODATA; n = dns_resource_key_name(rr->key); @@ -1288,7 +1288,7 @@ int dns_resource_record_source(DnsResourceRecord *rr, const char **ret) { /* Returns the RRset's synthesizing source, if it is known. */ - if (rr->n_skip_labels_source == (unsigned) -1) + if (rr->n_skip_labels_source == UINT_MAX) return -ENODATA; n = dns_resource_key_name(rr->key); @@ -1322,7 +1322,7 @@ int dns_resource_record_is_synthetic(DnsResourceRecord *rr) { /* Returns > 0 if the RR is generated from a wildcard, and is not the asterisk name itself */ - if (rr->n_skip_labels_source == (unsigned) -1) + if (rr->n_skip_labels_source == UINT_MAX) return -ENODATA; if (rr->n_skip_labels_source == 0) diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h index d3edcadf67..ab48ea5f2a 100644 --- a/src/resolve/resolved-dns-rr.h +++ b/src/resolve/resolved-dns-rr.h @@ -76,7 +76,7 @@ struct DnsResourceKey { * resource key object. */ #define DNS_RESOURCE_KEY_CONST(c, t, n) \ ((DnsResourceKey) { \ - .n_ref = (unsigned) -1, \ + .n_ref = UINT_MAX, \ .class = c, \ .type = t, \ ._name = (char*) n, \ diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c index 07c6eca3ba..6eac7e9c57 100644 --- a/src/resolve/resolved-dns-transaction.c +++ b/src/resolve/resolved-dns-transaction.c @@ -30,7 +30,7 @@ static void dns_transaction_reset_answer(DnsTransaction *t) { t->answer_dnssec_result = _DNSSEC_RESULT_INVALID; t->answer_source = _DNS_TRANSACTION_SOURCE_INVALID; t->answer_query_flags = 0; - t->answer_nsec_ttl = (uint32_t) -1; + t->answer_nsec_ttl = UINT32_MAX; t->answer_errno = 0; } @@ -275,7 +275,7 @@ int dns_transaction_new( .dns_udp_fd = -1, .answer_source = _DNS_TRANSACTION_SOURCE_INVALID, .answer_dnssec_result = _DNSSEC_RESULT_INVALID, - .answer_nsec_ttl = (uint32_t) -1, + .answer_nsec_ttl = UINT32_MAX, .key = dns_resource_key_ref(key), .query_flags = query_flags, .bypass = dns_packet_ref(bypass), diff --git a/src/resolve/resolved-mdns.c b/src/resolve/resolved-mdns.c index e3a46f4ca1..bfd71575d6 100644 --- a/src/resolve/resolved-mdns.c +++ b/src/resolve/resolved-mdns.c @@ -321,7 +321,7 @@ static int on_mdns_packet(sd_event_source *s, int fd, uint32_t revents, void *us dns_transaction_process_reply(t, p, false); } - dns_cache_put(&scope->cache, scope->manager->enable_cache, NULL, DNS_PACKET_RCODE(p), p->answer, NULL, false, _DNSSEC_RESULT_INVALID, (uint32_t) -1, p->family, &p->sender); + dns_cache_put(&scope->cache, scope->manager->enable_cache, NULL, DNS_PACKET_RCODE(p), p->answer, NULL, false, _DNSSEC_RESULT_INVALID, UINT32_MAX, p->family, &p->sender); } else if (dns_packet_validate_query(p) > 0) { log_debug("Got mDNS query packet for id %u", DNS_PACKET_ID(p)); |