From: Wouter Wijngaards Date: Thu, 16 Mar 2017 15:43:25 +0000 (+0000) Subject: prettier size_t and defines. X-Git-Tag: release-1.6.2rc1~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=984c6c33bc04ce1e54651b9459c557b88f423e0d;p=thirdparty%2Funbound.git prettier size_t and defines. git-svn-id: file:///svn/unbound/trunk@4062 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/daemon/worker.c b/daemon/worker.c index f88c03263..422400de3 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -791,10 +791,10 @@ chaos_replyonestr(sldns_buffer* pkt, const char* str, struct edns_data* edns, static void chaos_trustanchor(sldns_buffer* pkt, struct edns_data* edns, struct worker* w) { - int max_txt = 16; - int max_tags = 32; - char* str_array[16]; - uint16_t tags[32]; +#define TA_RESPONSE_MAX_TXT 16 /* max number of TXT records */ +#define TA_RESPONSE_MAX_TAGS 32 /* max number of tags printed per zone */ + char* str_array[TA_RESPONSE_MAX_TXT]; + uint16_t tags[TA_RESPONSE_MAX_TAGS]; int num = 0; struct trust_anchor* ta; @@ -807,14 +807,13 @@ chaos_trustanchor(sldns_buffer* pkt, struct edns_data* edns, struct worker* w) /* fill the string with contents */ lock_basic_lock(&w->env.anchors->lock); RBTREE_FOR(ta, struct trust_anchor*, w->env.anchors->tree) { - int i, numtag; char* str; - size_t str_len = 255; - if(num == max_txt) continue; - str = (char*)regional_alloc(w->scratchpad, 255); + size_t i, numtag, str_len = 255; + if(num == TA_RESPONSE_MAX_TXT) continue; + str = (char*)regional_alloc(w->scratchpad, str_len); if(!str) continue; lock_basic_lock(&ta->lock); - numtag = anchor_list_keytags(ta, tags, max_tags); + numtag = anchor_list_keytags(ta, tags, TA_RESPONSE_MAX_TAGS); if(numtag == 0) { /* empty, insecure point */ lock_basic_unlock(&ta->lock); diff --git a/validator/val_anchor.c b/validator/val_anchor.c index 0a34fd326..6c6322447 100644 --- a/validator/val_anchor.c +++ b/validator/val_anchor.c @@ -1284,11 +1284,10 @@ keytag_compare(const void* x, const void* y) return -1; } -int -anchor_list_keytags(struct trust_anchor* ta, uint16_t* list, int num) +size_t +anchor_list_keytags(struct trust_anchor* ta, uint16_t* list, size_t num) { - size_t i; - int ret = 0; + size_t i, ret = 0; if(ta->numDS == 0 && ta->numDNSKEY == 0) return 0; /* insecure point */ if(ta->numDS != 0 && ta->ds_rrset) { @@ -1307,6 +1306,6 @@ anchor_list_keytags(struct trust_anchor* ta, uint16_t* list, int num) list[ret++] = dnskey_calc_keytag(ta->dnskey_rrset, i); } } - qsort(list, (size_t)ret, sizeof(*list), keytag_compare); + qsort(list, ret, sizeof(*list), keytag_compare); return ret; } diff --git a/validator/val_anchor.h b/validator/val_anchor.h index 76a7b5482..318a2b227 100644 --- a/validator/val_anchor.h +++ b/validator/val_anchor.h @@ -225,6 +225,6 @@ void anchors_delete_insecure(struct val_anchors* anchors, uint16_t c, * bigger than the array, it is truncated at num. On errors, less keytags * are filled in. The array is sorted. */ -int anchor_list_keytags(struct trust_anchor* ta, uint16_t* list, int num); +size_t anchor_list_keytags(struct trust_anchor* ta, uint16_t* list, size_t num); #endif /* VALIDATOR_VAL_ANCHOR_H */