tree-wide: use UINT64_MAX or friends

This commit is contained in:
Yu Watanabe
2021-03-05 07:10:13 +09:00
parent ef1e0b9a46
commit f5fbe71d95
150 changed files with 530 additions and 528 deletions
+1 -1
View File
@@ -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,
+3 -3
View File
@@ -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)
+12 -12
View File
@@ -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);
+9 -9
View File
@@ -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)
+1 -1
View File
@@ -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, \
+2 -2
View File
@@ -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),
+1 -1
View File
@@ -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));