diff --git a/src/context.c b/src/context.c index 8893191e..dc3b8b92 100644 --- a/src/context.c +++ b/src/context.c @@ -711,8 +711,11 @@ _getdns_upstream_shutdown(getdns_upstream *upstream) } static int -tls_is_in_transports_list(getdns_context *context) { - for (int i=0; i< context->dns_transport_count;i++) { +tls_is_in_transports_list(getdns_context *context) +{ + size_t i; + + for (i = 0; i< context->dns_transport_count;i++) { if (context->dns_transports[i] == GETDNS_TRANSPORT_TLS) return 1; } @@ -2971,7 +2974,7 @@ getdns_return_t _getdns_context_prepare_for_resolution(struct getdns_context *context, int usenamespaces) { - int i; + size_t i; getdns_return_t r; RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); diff --git a/src/context.h b/src/context.h index 46ed6c88..86bfb817 100644 --- a/src/context.h +++ b/src/context.h @@ -192,7 +192,7 @@ struct getdns_context { /* Context values */ getdns_resolution_t resolution_type; getdns_namespace_t *namespaces; - int namespace_count; + size_t namespace_count; uint64_t timeout; uint64_t idle_timeout; getdns_redirects_t follow_redirects; diff --git a/src/convert.c b/src/convert.c index 9ce2fa39..41d2b155 100644 --- a/src/convert.c +++ b/src/convert.c @@ -53,9 +53,6 @@ #include "convert.h" #include "debug.h" -/* stuff to make it compile pedantically */ -#define UNUSED_PARAM(x) ((void)(x)) - getdns_return_t getdns_convert_dns_name_to_fqdn( const getdns_bindata *dns_name_wire_fmt, char **fqdn_as_string) diff --git a/src/dict.c b/src/dict.c index e7294e62..042ec190 100644 --- a/src/dict.c +++ b/src/dict.c @@ -54,7 +54,7 @@ static char *_json_ptr_first(const struct mem_funcs *mf, - const char *jptr, char *first, size_t first_sz) + const char *jptr, char *first, ssize_t first_sz) { const char *next_ref, *k; char *j; @@ -735,14 +735,13 @@ _getdns_bindata_is_dname(getdns_bindata *bindata) /** * private function to pretty print bindata to a gldns_buffer * @param buf buffer to write to - * @param indent number of spaces to append after newline * @param bindata the bindata to print * @return on success the number of written characters * if an output error is encountered, a negative value */ static int -getdns_pp_bindata(gldns_buffer *buf, size_t indent, - getdns_bindata *bindata, int rdata_raw, int json) +getdns_pp_bindata(gldns_buffer *buf, getdns_bindata *bindata, + int rdata_raw, int json) { size_t i, p = gldns_buffer_position(buf); uint8_t *dptr; @@ -887,7 +886,7 @@ getdns_pp_list(gldns_buffer *buf, size_t indent, const getdns_list *list, GETDNS_RETURN_GOOD) return -1; if (getdns_pp_bindata( - buf, indent, bindata_item, 0, json) < 0) + buf, bindata_item, 0, json) < 0) return -1; break; @@ -1096,7 +1095,7 @@ getdns_pp_dict(gldns_buffer * buf, size_t indent, return -1; } else if (getdns_pp_bindata( - buf, indent, item->i.data.bindata, + buf, item->i.data.bindata, (strcmp(item->node.key, "rdata_raw") == 0), json) < 0) return -1; @@ -1189,7 +1188,7 @@ getdns_pretty_snprint_dict(char *str, size_t size, const getdns_dict *dict) gldns_buffer_init_frm_data(&buf, str, size); return getdns_pp_dict(&buf, 0, dict, 0) < 0 - ? -1 : gldns_buffer_position(&buf); + ? -1 : (int)gldns_buffer_position(&buf); } char * @@ -1223,7 +1222,7 @@ getdns_pretty_snprint_list(char *str, size_t size, const getdns_list *list) gldns_buffer_init_frm_data(&buf, str, size); return getdns_pp_list(&buf, 0, list, 0, 0) < 0 - ? -1 : gldns_buffer_position(&buf); + ? -1 : (int)gldns_buffer_position(&buf); } char * @@ -1258,7 +1257,7 @@ getdns_snprint_json_dict( gldns_buffer_init_frm_data(&buf, str, size); return getdns_pp_dict(&buf, 0, dict, pretty ? 1 : 2) < 0 - ? -1 : gldns_buffer_position(&buf); + ? -1 : (int)gldns_buffer_position(&buf); } char * @@ -1293,7 +1292,7 @@ getdns_snprint_json_list( gldns_buffer_init_frm_data(&buf, str, size); return getdns_pp_list(&buf, 0, list, 0, pretty ? 1 : 2) < 0 - ? -1 : gldns_buffer_position(&buf); + ? -1 : (int)gldns_buffer_position(&buf); } /* dict.c */ diff --git a/src/dnssec.c b/src/dnssec.c index f567b96b..961941a4 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -256,7 +256,7 @@ static uint8_t *_dname_label_copy(uint8_t *dst, const uint8_t *src, size_t dst_l { uint8_t *r = dst, i; - if (!src || *src + 1 > dst_len) + if (!src || (size_t)*src + 1 > dst_len) return NULL; for (i = (*dst++ = *src++); i ; i--) @@ -528,7 +528,7 @@ static chain_head *add_rrset2val_chain(struct mem_funcs *mf, chain_head *head; const uint8_t *labels[128], **last_label, **label; - size_t max_labels; /* max labels in common */ + ssize_t max_labels; /* max labels in common */ chain_head *max_head; chain_node *max_node; @@ -1871,7 +1871,7 @@ static int ds_authenticates_keys(struct mem_funcs *mf, max_supported_digest = ds->rr_i.rr_type[13]; max_supported_result = 0; - if (digest_len != ds->rr_i.nxt - ds->rr_i.rr_type-14 + if ((int)digest_len != ds->rr_i.nxt - ds->rr_i.rr_type-14 || memcmp(digest, ds->rr_i.rr_type+14, digest_len) != 0) { if (digest != digest_spc) GETDNS_FREE(*mf, digest); diff --git a/src/extension/default_eventloop.c b/src/extension/default_eventloop.c index 10efff59..671c3955 100644 --- a/src/extension/default_eventloop.c +++ b/src/extension/default_eventloop.c @@ -39,7 +39,8 @@ static uint64_t get_now_plus(uint64_t amount) } now = tv.tv_sec * 1000000 + tv.tv_usec; - return (now + amount * 1000) >= now ? now + amount * 1000 : -1; + return (now + amount * 1000) >= now + ? now + amount * 1000 : 0xFFFFFFFFFFFFFFFF; } static getdns_return_t @@ -151,6 +152,7 @@ default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event) static void default_eventloop_cleanup(getdns_eventloop *loop) { + (void)loop; } static void @@ -181,7 +183,7 @@ default_eventloop_run_once(getdns_eventloop *loop, int blocking) fd_set readfds, writefds; int fd, max_fd = -1; - uint64_t now, timeout = (uint64_t)-1; + uint64_t now, timeout = 0xFFFFFFFFFFFFFFFF; size_t i; struct timeval tv; @@ -212,7 +214,7 @@ default_eventloop_run_once(getdns_eventloop *loop, int blocking) if (default_loop->fd_timeout_times[fd] < timeout) timeout = default_loop->fd_timeout_times[fd]; } - if (max_fd == -1 && timeout == (uint64_t)-1) + if (max_fd == -1 && timeout == 0xFFFFFFFFFFFFFFFF) return; if (! blocking || now > timeout) { @@ -223,7 +225,7 @@ default_eventloop_run_once(getdns_eventloop *loop, int blocking) tv.tv_usec = (timeout - now) % 1000000; } if (select(max_fd + 1, &readfds, &writefds, NULL, - (timeout == ((uint64_t)-1) ? NULL : &tv)) < 0) { + (timeout == 0xFFFFFFFFFFFFFFFF ? NULL : &tv)) < 0) { perror("select() failed"); exit(EXIT_FAILURE); } diff --git a/src/extension/libev.c b/src/extension/libev.c index 6a8c26e9..ff36b5c2 100644 --- a/src/extension/libev.c +++ b/src/extension/libev.c @@ -97,6 +97,7 @@ static void getdns_libev_read_cb(struct ev_loop *l, struct ev_io *io, int revents) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)io->data; + (void)l; (void)revents; assert(el_ev->read_cb); el_ev->read_cb(el_ev->userarg); } @@ -105,14 +106,16 @@ static void getdns_libev_write_cb(struct ev_loop *l, struct ev_io *io, int revents) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)io->data; + (void)l; (void)revents; assert(el_ev->write_cb); el_ev->write_cb(el_ev->userarg); } static void -getdns_libev_timeout_cb(struct ev_loop *l, struct ev_timer *timer, int revent) +getdns_libev_timeout_cb(struct ev_loop *l, struct ev_timer *timer, int revents) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)timer->data; + (void)l; (void)revents; assert(el_ev->timeout_cb); el_ev->timeout_cb(el_ev->userarg); } diff --git a/src/extension/libevent.c b/src/extension/libevent.c index 800ebe8e..d096d347 100644 --- a/src/extension/libevent.c +++ b/src/extension/libevent.c @@ -95,6 +95,7 @@ static getdns_return_t getdns_libevent_clear(getdns_eventloop *loop, getdns_eventloop_event *el_ev) { struct event *my_ev = (struct event *)el_ev->ev; + (void)loop; assert(my_ev); @@ -110,6 +111,7 @@ static void getdns_libevent_callback(evutil_socket_t fd, short bits, void *arg) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)arg; + (void)fd; if (bits & EV_READ) { assert(el_ev->read_cb); diff --git a/src/extension/libuv.c b/src/extension/libuv.c index adf97835..ec9257be 100644 --- a/src/extension/libuv.c +++ b/src/extension/libuv.c @@ -104,6 +104,7 @@ getdns_libuv_clear(getdns_eventloop *loop, getdns_eventloop_event *el_ev) poll_timer *my_ev = (poll_timer *)el_ev->ev; uv_poll_t *my_poll; uv_timer_t *my_timer; + (void)loop; assert(my_ev); @@ -141,6 +142,7 @@ static void getdns_libuv_read_cb(uv_poll_t *poll, int status, int events) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)poll->data; + (void)status; (void)events; assert(el_ev->read_cb); DEBUG_UV("enter libuv_read_cb(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); @@ -153,6 +155,7 @@ static void getdns_libuv_write_cb(uv_poll_t *poll, int status, int events) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)poll->data; + (void)status; (void)events; assert(el_ev->write_cb); DEBUG_UV("enter libuv_write_cb(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); diff --git a/src/list.c b/src/list.c index eec2a1c1..4a73b63f 100644 --- a/src/list.c +++ b/src/list.c @@ -312,7 +312,7 @@ getdns_return_t _getdns_list_copy(const struct getdns_list * srclist, struct getdns_list ** dstlist) { - int i; + size_t i; getdns_return_t retval; if (!dstlist) diff --git a/src/pubkey-pinning.c b/src/pubkey-pinning.c index 7d286691..db60fbc8 100644 --- a/src/pubkey-pinning.c +++ b/src/pubkey-pinning.c @@ -97,7 +97,7 @@ getdns_dict* getdns_pubkey_pin_create_from_string( const char* str) { BIO *bio = NULL; - int i; + size_t i; uint8_t buf[SHA256_DIGEST_LENGTH]; char inbuf[B64_ENCODED_SHA256_LENGTH + 1]; getdns_bindata value = { .size = SHA256_DIGEST_LENGTH, .data = buf }; @@ -425,7 +425,7 @@ _getdns_verify_pinset_match(const sha256_pin_t *pinset, #endif /* digest the cert with sha256 */ len = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), NULL); - if (len > sizeof(raw)) { + if (len > (int)sizeof(raw)) { DEBUG_STUB("%s %-35s: Pubkey %d is larger than "PRIsz" octets\n", STUB_DEBUG_SETUP_TLS, __FUNCTION__, i, sizeof(raw)); continue; diff --git a/src/rr-dict.c b/src/rr-dict.c index 76972997..1fa30fed 100644 --- a/src/rr-dict.c +++ b/src/rr-dict.c @@ -47,6 +47,7 @@ static const uint8_t * apl_n_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { + (void)pkt; return rdf < pkt_end ? rdf + 1 : NULL; } static getdns_return_t @@ -107,6 +108,7 @@ apl_afdpart_rdf_end( const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { const uint8_t *end = rdf + (rdf[-1] & 0x7F); + (void)(pkt); return end <= pkt_end ? end : NULL; } static getdns_return_t @@ -335,6 +337,7 @@ static const uint8_t * hip_pk_algorithm_rdf_end( const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { + (void)(pkt); return rdf + 4 > pkt_end ? NULL : rdf + 4 + *rdf + gldns_read_uint16(rdf + 2) > pkt_end ? NULL : rdf + 1; @@ -397,6 +400,7 @@ static _getdns_rdf_special hip_pk_algorithm = { static const uint8_t * hip_hit_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { + (void)(pkt); return rdf + 3 > pkt_end ? NULL : rdf + 3 + rdf[-1] + gldns_read_uint16(rdf + 1) > pkt_end ? NULL : rdf + 1; @@ -467,6 +471,7 @@ static const uint8_t * hip_public_key_rdf_end( const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { + (void)(pkt); return rdf + 2 > pkt_end ? NULL : rdf + 2 + rdf[-2] + gldns_read_uint16(rdf) > pkt_end ? NULL : rdf + 2 + rdf[-2] + gldns_read_uint16(rdf); @@ -537,222 +542,222 @@ static _getdns_rdf_special hip_public_key = { static _getdns_rdata_def a_rdata[] = { - { "ipv4_address" , GETDNS_RDF_A }}; + { "ipv4_address" , GETDNS_RDF_A , NULL }}; static _getdns_rdata_def ns_rdata[] = { - { "nsdname" , GETDNS_RDF_N_C }}; + { "nsdname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def md_rdata[] = { - { "madname" , GETDNS_RDF_N_C }}; + { "madname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def cname_rdata[] = { - { "cname" , GETDNS_RDF_N_C }}; + { "cname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def soa_rdata[] = { - { "mname" , GETDNS_RDF_N_C }, - { "rname" , GETDNS_RDF_N_C }, - { "serial" , GETDNS_RDF_I4 }, - { "refresh" , GETDNS_RDF_I4 }, - { "retry" , GETDNS_RDF_I4 }, - { "expire" , GETDNS_RDF_I4 }, - { "minimum" , GETDNS_RDF_I4 }}; + { "mname" , GETDNS_RDF_N_C , NULL }, + { "rname" , GETDNS_RDF_N_C , NULL }, + { "serial" , GETDNS_RDF_I4 , NULL }, + { "refresh" , GETDNS_RDF_I4 , NULL }, + { "retry" , GETDNS_RDF_I4 , NULL }, + { "expire" , GETDNS_RDF_I4 , NULL }, + { "minimum" , GETDNS_RDF_I4 , NULL }}; static _getdns_rdata_def mg_rdata[] = { - { "mgmname" , GETDNS_RDF_N_C }}; + { "mgmname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def mr_rdata[] = { - { "newname" , GETDNS_RDF_N_C }}; + { "newname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def null_rdata[] = { - { "anything" , GETDNS_RDF_X }}; + { "anything" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def wks_rdata[] = { - { "address" , GETDNS_RDF_A }, - { "protocol" , GETDNS_RDF_I1 }, - { "bitmap" , GETDNS_RDF_X }}; + { "address" , GETDNS_RDF_A , NULL }, + { "protocol" , GETDNS_RDF_I1 , NULL }, + { "bitmap" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def ptr_rdata[] = { - { "ptrdname" , GETDNS_RDF_N_C }}; + { "ptrdname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def hinfo_rdata[] = { - { "cpu" , GETDNS_RDF_S }, - { "os" , GETDNS_RDF_S }}; + { "cpu" , GETDNS_RDF_S , NULL }, + { "os" , GETDNS_RDF_S , NULL }}; static _getdns_rdata_def minfo_rdata[] = { - { "rmailbx" , GETDNS_RDF_N_C }, - { "emailbx" , GETDNS_RDF_N_C }}; + { "rmailbx" , GETDNS_RDF_N_C , NULL }, + { "emailbx" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def mx_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "exchange" , GETDNS_RDF_N_C }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "exchange" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def txt_rdata[] = { - { "txt_strings" , GETDNS_RDF_S_M }}; + { "txt_strings" , GETDNS_RDF_S_M , NULL }}; static _getdns_rdata_def rp_rdata[] = { - { "mbox_dname" , GETDNS_RDF_N }, - { "txt_dname" , GETDNS_RDF_N }}; + { "mbox_dname" , GETDNS_RDF_N , NULL }, + { "txt_dname" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def afsdb_rdata[] = { - { "subtype" , GETDNS_RDF_I2 }, - { "hostname" , GETDNS_RDF_N }}; + { "subtype" , GETDNS_RDF_I2 , NULL }, + { "hostname" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def x25_rdata[] = { - { "psdn_address" , GETDNS_RDF_S }}; + { "psdn_address" , GETDNS_RDF_S , NULL }}; static _getdns_rdata_def isdn_rdata[] = { - { "isdn_address" , GETDNS_RDF_S }, - { "sa" , GETDNS_RDF_S }}; + { "isdn_address" , GETDNS_RDF_S , NULL }, + { "sa" , GETDNS_RDF_S , NULL }}; static _getdns_rdata_def rt_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "intermediate_host" , GETDNS_RDF_N }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "intermediate_host" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def nsap_rdata[] = { - { "nsap" , GETDNS_RDF_X }}; + { "nsap" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def sig_rdata[] = { - { "sig_obsolete" , GETDNS_RDF_X }}; + { "sig_obsolete" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def key_rdata[] = { - { "key_obsolete" , GETDNS_RDF_X }}; + { "key_obsolete" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def px_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "map822" , GETDNS_RDF_N }, - { "mapx400" , GETDNS_RDF_N }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "map822" , GETDNS_RDF_N , NULL }, + { "mapx400" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def gpos_rdata[] = { - { "longitude" , GETDNS_RDF_S }, - { "latitude" , GETDNS_RDF_S }, - { "altitude" , GETDNS_RDF_S }}; + { "longitude" , GETDNS_RDF_S , NULL }, + { "latitude" , GETDNS_RDF_S , NULL }, + { "altitude" , GETDNS_RDF_S , NULL }}; static _getdns_rdata_def aaaa_rdata[] = { - { "ipv6_address" , GETDNS_RDF_AAAA }}; + { "ipv6_address" , GETDNS_RDF_AAAA , NULL }}; static _getdns_rdata_def loc_rdata[] = { - { "loc_obsolete" , GETDNS_RDF_X }}; + { "loc_obsolete" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def nxt_rdata[] = { - { "nxt_obsolete" , GETDNS_RDF_X }}; + { "nxt_obsolete" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def srv_rdata[] = { - { "priority" , GETDNS_RDF_I2 }, - { "weight" , GETDNS_RDF_I2 }, - { "port" , GETDNS_RDF_I2 }, - { "target" , GETDNS_RDF_N }}; + { "priority" , GETDNS_RDF_I2 , NULL }, + { "weight" , GETDNS_RDF_I2 , NULL }, + { "port" , GETDNS_RDF_I2 , NULL }, + { "target" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def atma_rdata[] = { - { "format" , GETDNS_RDF_X }}; + { "format" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def naptr_rdata[] = { - { "order" , GETDNS_RDF_I2 }, - { "preference" , GETDNS_RDF_I2 }, - { "flags" , GETDNS_RDF_S }, - { "service" , GETDNS_RDF_S }, - { "regexp" , GETDNS_RDF_S }, - { "replacement" , GETDNS_RDF_N }}; + { "order" , GETDNS_RDF_I2 , NULL }, + { "preference" , GETDNS_RDF_I2 , NULL }, + { "flags" , GETDNS_RDF_S , NULL }, + { "service" , GETDNS_RDF_S , NULL }, + { "regexp" , GETDNS_RDF_S , NULL }, + { "replacement" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def kx_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "exchanger" , GETDNS_RDF_N }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "exchanger" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def cert_rdata[] = { - { "type" , GETDNS_RDF_I2 }, - { "key_tag" , GETDNS_RDF_I2 }, - { "algorithm" , GETDNS_RDF_I1 }, - { "certificate_or_crl" , GETDNS_RDF_B }}; + { "type" , GETDNS_RDF_I2 , NULL }, + { "key_tag" , GETDNS_RDF_I2 , NULL }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "certificate_or_crl" , GETDNS_RDF_B , NULL }}; static _getdns_rdata_def a6_rdata[] = { - { "a6_obsolete" , GETDNS_RDF_X }}; + { "a6_obsolete" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def dname_rdata[] = { - { "target" , GETDNS_RDF_N }}; + { "target" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def opt_rdata[] = { - { "options" , GETDNS_RDF_R }, - { "option_code" , GETDNS_RDF_I2 }, - { "option_data" , GETDNS_RDF_X_S }}; + { "options" , GETDNS_RDF_R , NULL }, + { "option_code" , GETDNS_RDF_I2 , NULL }, + { "option_data" , GETDNS_RDF_X_S , NULL }}; static _getdns_rdata_def apl_rdata[] = { - { "apitems" , GETDNS_RDF_R }, - { "address_family" , GETDNS_RDF_I2 }, - { "prefix" , GETDNS_RDF_I1 }, + { "apitems" , GETDNS_RDF_R , NULL }, + { "address_family" , GETDNS_RDF_I2 , NULL }, + { "prefix" , GETDNS_RDF_I1 , NULL }, { "n" , GETDNS_RDF_SPECIAL, &apl_n }, { "afdpart" , GETDNS_RDF_SPECIAL, &apl_afdpart }}; static _getdns_rdata_def ds_rdata[] = { - { "key_tag" , GETDNS_RDF_I2 }, - { "algorithm" , GETDNS_RDF_I1 }, - { "digest_type" , GETDNS_RDF_I1 }, - { "digest" , GETDNS_RDF_X }}; + { "key_tag" , GETDNS_RDF_I2 , NULL }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "digest_type" , GETDNS_RDF_I1 , NULL }, + { "digest" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def sshfp_rdata[] = { - { "algorithm" , GETDNS_RDF_I1 }, - { "fp_type" , GETDNS_RDF_I1 }, - { "fingerprint" , GETDNS_RDF_X }}; + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "fp_type" , GETDNS_RDF_I1 , NULL }, + { "fingerprint" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def ipseckey_rdata[] = { - { "algorithm" , GETDNS_RDF_I1 }, - { "gateway_type" , GETDNS_RDF_I1 }, - { "precedence" , GETDNS_RDF_I1 }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "gateway_type" , GETDNS_RDF_I1 , NULL }, + { "precedence" , GETDNS_RDF_I1 , NULL }, { "gateway" , GETDNS_RDF_SPECIAL, &ipseckey_gateway }, - { "public_key" , GETDNS_RDF_B }}; + { "public_key" , GETDNS_RDF_B , NULL }}; static _getdns_rdata_def rrsig_rdata[] = { - { "type_covered" , GETDNS_RDF_I2 }, - { "algorithm" , GETDNS_RDF_I1 }, - { "labels" , GETDNS_RDF_I1 }, - { "original_ttl" , GETDNS_RDF_I4 }, - { "signature_expiration" , GETDNS_RDF_T }, - { "signature_inception" , GETDNS_RDF_T }, - { "key_tag" , GETDNS_RDF_I2 }, - { "signers_name" , GETDNS_RDF_N }, - { "signature" , GETDNS_RDF_B }}; + { "type_covered" , GETDNS_RDF_I2 , NULL }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "labels" , GETDNS_RDF_I1 , NULL }, + { "original_ttl" , GETDNS_RDF_I4 , NULL }, + { "signature_expiration" , GETDNS_RDF_T , NULL }, + { "signature_inception" , GETDNS_RDF_T , NULL }, + { "key_tag" , GETDNS_RDF_I2 , NULL }, + { "signers_name" , GETDNS_RDF_N , NULL }, + { "signature" , GETDNS_RDF_B , NULL }}; static _getdns_rdata_def nsec_rdata[] = { - { "next_domain_name" , GETDNS_RDF_N }, - { "type_bit_maps" , GETDNS_RDF_X }}; + { "next_domain_name" , GETDNS_RDF_N , NULL }, + { "type_bit_maps" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def dnskey_rdata[] = { - { "flags" , GETDNS_RDF_I2 }, - { "protocol" , GETDNS_RDF_I1 }, - { "algorithm" , GETDNS_RDF_I1 }, - { "public_key" , GETDNS_RDF_B }}; + { "flags" , GETDNS_RDF_I2 , NULL }, + { "protocol" , GETDNS_RDF_I1 , NULL }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "public_key" , GETDNS_RDF_B , NULL }}; static _getdns_rdata_def dhcid_rdata[] = { - { "dhcid_opaque" , GETDNS_RDF_B }}; + { "dhcid_opaque" , GETDNS_RDF_B , NULL }}; static _getdns_rdata_def nsec3_rdata[] = { - { "hash_algorithm" , GETDNS_RDF_I1 }, - { "flags" , GETDNS_RDF_I1 }, - { "iterations" , GETDNS_RDF_I2 }, - { "salt" , GETDNS_RDF_X_C }, - { "next_hashed_owner_name" , GETDNS_RDF_B32_C}, - { "type_bit_maps" , GETDNS_RDF_X }}; + { "hash_algorithm" , GETDNS_RDF_I1 , NULL }, + { "flags" , GETDNS_RDF_I1 , NULL }, + { "iterations" , GETDNS_RDF_I2 , NULL }, + { "salt" , GETDNS_RDF_X_C , NULL }, + { "next_hashed_owner_name" , GETDNS_RDF_B32_C , NULL }, + { "type_bit_maps" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def nsec3param_rdata[] = { - { "hash_algorithm" , GETDNS_RDF_I1 }, - { "flags" , GETDNS_RDF_I1 }, - { "iterations" , GETDNS_RDF_I2 }, - { "salt" , GETDNS_RDF_X_C }}; + { "hash_algorithm" , GETDNS_RDF_I1 , NULL }, + { "flags" , GETDNS_RDF_I1 , NULL }, + { "iterations" , GETDNS_RDF_I2 , NULL }, + { "salt" , GETDNS_RDF_X_C , NULL }}; static _getdns_rdata_def tlsa_rdata[] = { - { "certificate_usage" , GETDNS_RDF_I1 }, - { "selector" , GETDNS_RDF_I1 }, - { "matching_type" , GETDNS_RDF_I1 }, - { "certificate_association_data", GETDNS_RDF_X }}; + { "certificate_usage" , GETDNS_RDF_I1 , NULL }, + { "selector" , GETDNS_RDF_I1 , NULL }, + { "matching_type" , GETDNS_RDF_I1 , NULL }, + { "certificate_association_data", GETDNS_RDF_X , NULL }}; static _getdns_rdata_def hip_rdata[] = { { "pk_algorithm" , GETDNS_RDF_SPECIAL, &hip_pk_algorithm }, { "hit" , GETDNS_RDF_SPECIAL, &hip_hit }, { "public_key" , GETDNS_RDF_SPECIAL, &hip_public_key }, - { "rendezvous_servers" , GETDNS_RDF_N_M }}; + { "rendezvous_servers" , GETDNS_RDF_N_M , NULL }}; static _getdns_rdata_def csync_rdata[] = { - { "serial" , GETDNS_RDF_I4 }, - { "flags" , GETDNS_RDF_I2 }, - { "type_bit_maps" , GETDNS_RDF_X }}; + { "serial" , GETDNS_RDF_I4 , NULL }, + { "flags" , GETDNS_RDF_I2 , NULL }, + { "type_bit_maps" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def spf_rdata[] = { - { "text" , GETDNS_RDF_S_M }}; + { "text" , GETDNS_RDF_S_M , NULL }}; static _getdns_rdata_def nid_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "node_id" , GETDNS_RDF_AA }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "node_id" , GETDNS_RDF_AA , NULL }}; static _getdns_rdata_def l32_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "locator32" , GETDNS_RDF_A }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "locator32" , GETDNS_RDF_A , NULL }}; static _getdns_rdata_def l64_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "locator64" , GETDNS_RDF_AA }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "locator64" , GETDNS_RDF_AA , NULL }}; static _getdns_rdata_def lp_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "fqdn" , GETDNS_RDF_N }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "fqdn" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def eui48_rdata[] = { - { "eui48_address" , GETDNS_RDF_X6 }}; + { "eui48_address" , GETDNS_RDF_X6 , NULL }}; static _getdns_rdata_def eui64_rdata[] = { - { "eui64_address" , GETDNS_RDF_X8 }}; + { "eui64_address" , GETDNS_RDF_X8 , NULL }}; static _getdns_rdata_def tkey_rdata[] = { - { "algorithm" , GETDNS_RDF_N }, - { "inception" , GETDNS_RDF_T }, - { "expiration" , GETDNS_RDF_T }, - { "mode" , GETDNS_RDF_I2 }, - { "error" , GETDNS_RDF_I2 }, - { "key_data" , GETDNS_RDF_X_S }, - { "other_data" , GETDNS_RDF_X_S }}; + { "algorithm" , GETDNS_RDF_N , NULL }, + { "inception" , GETDNS_RDF_T , NULL }, + { "expiration" , GETDNS_RDF_T , NULL }, + { "mode" , GETDNS_RDF_I2 , NULL }, + { "error" , GETDNS_RDF_I2 , NULL }, + { "key_data" , GETDNS_RDF_X_S , NULL }, + { "other_data" , GETDNS_RDF_X_S , NULL }}; static _getdns_rdata_def tsig_rdata[] = { - { "algorithm" , GETDNS_RDF_N }, - { "time_signed" , GETDNS_RDF_T6 }, - { "fudge" , GETDNS_RDF_I2 }, - { "mac" , GETDNS_RDF_X_S }, - { "original_id" , GETDNS_RDF_I2 }, - { "error" , GETDNS_RDF_I2 }, - { "other_data" , GETDNS_RDF_X_S }}; + { "algorithm" , GETDNS_RDF_N , NULL }, + { "time_signed" , GETDNS_RDF_T6 , NULL }, + { "fudge" , GETDNS_RDF_I2 , NULL }, + { "mac" , GETDNS_RDF_X_S , NULL }, + { "original_id" , GETDNS_RDF_I2 , NULL }, + { "error" , GETDNS_RDF_I2 , NULL }, + { "other_data" , GETDNS_RDF_X_S , NULL }}; static _getdns_rdata_def uri_rdata[] = { - { "priority" , GETDNS_RDF_I2 }, - { "weight" , GETDNS_RDF_I2 }, - { "target" , GETDNS_RDF_S_L }}; + { "priority" , GETDNS_RDF_I2 , NULL }, + { "weight" , GETDNS_RDF_I2 , NULL }, + { "target" , GETDNS_RDF_S_L , NULL }}; static _getdns_rdata_def caa_rdata[] = { - { "flags" , GETDNS_RDF_I1 }, - { "tag" , GETDNS_RDF_S }, - { "value" , GETDNS_RDF_S_L }}; + { "flags" , GETDNS_RDF_I1 , NULL }, + { "tag" , GETDNS_RDF_S , NULL }, + { "value" , GETDNS_RDF_S_L , NULL }}; static _getdns_rdata_def dlv_rdata[] = { - { "key_tag" , GETDNS_RDF_I2 }, - { "algorithm" , GETDNS_RDF_I1 }, - { "digest_type" , GETDNS_RDF_I1 }, - { "digest" , GETDNS_RDF_X }}; + { "key_tag" , GETDNS_RDF_I2 , NULL }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "digest_type" , GETDNS_RDF_I1 , NULL }, + { "digest" , GETDNS_RDF_X , NULL }}; static _getdns_rr_def _getdns_rr_defs[] = { { NULL, NULL, 0 }, diff --git a/src/rr-dict.h b/src/rr-dict.h index 6ab52b88..e19e0387 100644 --- a/src/rr-dict.h +++ b/src/rr-dict.h @@ -138,7 +138,7 @@ typedef struct _getdns_rdata_def { typedef struct _getdns_rr_def { const char *name; const _getdns_rdata_def *rdata; - int n_rdata_fields; + size_t n_rdata_fields; } _getdns_rr_def; const _getdns_rr_def *_getdns_rr_def_lookup(uint16_t rr_type); diff --git a/src/rr-iter.c b/src/rr-iter.c index 9b332603..24c71799 100644 --- a/src/rr-iter.c +++ b/src/rr-iter.c @@ -75,7 +75,7 @@ find_rrtype(_getdns_rr_iter *i) /* Past the last RR in the pkt */ if (i->pkt && - GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) + + (size_t)GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) + GLDNS_NSCOUNT(i->pkt) + GLDNS_ARCOUNT(i->pkt) <= i->n) goto done; diff --git a/src/rr-iter.h b/src/rr-iter.h index d657d484..042afb2d 100644 --- a/src/rr-iter.h +++ b/src/rr-iter.h @@ -88,13 +88,13 @@ _getdns_rr_iter_section(_getdns_rr_iter *i) { return !i->pkt ? (i->nxt - i->rr_type == 4 ? SECTION_QUESTION : SECTION_ANSWER ) - : i->n < GLDNS_QDCOUNT(i->pkt) ? SECTION_QUESTION - : i->n < GLDNS_QDCOUNT(i->pkt) + : i->n < (size_t)GLDNS_QDCOUNT(i->pkt) ? SECTION_QUESTION + : i->n < (size_t)GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) ? SECTION_ANSWER - : i->n < GLDNS_QDCOUNT(i->pkt) + : i->n < (size_t)GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) + GLDNS_NSCOUNT(i->pkt) ? SECTION_AUTHORITY - : i->n < GLDNS_QDCOUNT(i->pkt) + : i->n < (size_t)GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) + GLDNS_NSCOUNT(i->pkt) + GLDNS_ARCOUNT(i->pkt) ? SECTION_ADDITIONAL diff --git a/src/stub.c b/src/stub.c index 4aa14dae..9af045ae 100644 --- a/src/stub.c +++ b/src/stub.c @@ -663,7 +663,7 @@ stub_tcp_read(int fd, getdns_tcp_state *tcp, struct mem_funcs *mf) tcp->to_read = 2; /* Packet size */ } read = recv(fd, (void *)tcp->read_pos, tcp->to_read, 0); - if (read == -1) { + if (read < 0) { if (_getdns_EWOULDBLOCK) return STUB_TCP_WOULDBLOCK; else @@ -672,7 +672,7 @@ stub_tcp_read(int fd, getdns_tcp_state *tcp, struct mem_funcs *mf) /* Remote end closed the socket */ /* TODO: Try to reconnect */ return STUB_TCP_ERROR; - } else if (read> tcp->to_read) { + } else if ((size_t)read > tcp->to_read) { return STUB_TCP_ERROR; } tcp->to_read -= read; @@ -780,12 +780,12 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq) (struct sockaddr *)&(netreq->upstream->addr), netreq->upstream->addr_len); #endif - if ((written == -1 && (_getdns_EWOULDBLOCK || + if ((written < 0 && (_getdns_EWOULDBLOCK || /* Add the error case where the connection is in progress which is when a cookie is not available (e.g. when doing the first request to an upstream). We must let the handshake complete since non-blocking. */ _getdns_EINPROGRESS)) || - written < pkt_len + 2) { + (size_t)written < pkt_len + 2) { /* We couldn't write the whole packet. * We have to return with STUB_TCP_AGAIN. diff --git a/src/sync.c b/src/sync.c index d100afb8..bfec94c6 100644 --- a/src/sync.c +++ b/src/sync.c @@ -151,6 +151,7 @@ getdns_sync_cb(getdns_context *context, getdns_callback_type_t callback_type, getdns_dict *response, void *userarg, getdns_transaction_t transaction_id) { getdns_sync_data *data = (getdns_sync_data *)userarg; + (void)context; (void)callback_type; (void)transaction_id; assert(data); diff --git a/src/types-internal.h b/src/types-internal.h index bf7bfd7e..b321bafa 100644 --- a/src/types-internal.h +++ b/src/types-internal.h @@ -110,7 +110,7 @@ struct getdns_upstream; #define GETDNS_STR_KEY_NSCOUNT "nscount" #define GETDNS_STR_KEY_ARCOUNT "arcount" -#define TIMEOUT_FOREVER ((int64_t)-1) +#define TIMEOUT_FOREVER ((uint64_t)0xFFFFFFFFFFFFFFFF) #define ASSERT_UNREACHABLE 0 #define GETDNS_TRANSPORTS_MAX 3 diff --git a/src/ub_loop.c b/src/ub_loop.c index ddf59c68..c69d9070 100644 --- a/src/ub_loop.c +++ b/src/ub_loop.c @@ -353,6 +353,7 @@ static int my_timer_del(struct ub_event* ev) static int my_signal_add(struct ub_event* ub_ev, struct timeval* tv) { + (void)ub_ev; (void)tv; /* Only unbound daaemon workers use signals */ DEBUG_SCHED("UB_LOOP ERROR: signal_add()\n"); return -1; @@ -360,6 +361,7 @@ static int my_signal_add(struct ub_event* ub_ev, struct timeval* tv) static int my_signal_del(struct ub_event* ub_ev) { + (void)ub_ev; /* Only unbound daaemon workers use signals */ DEBUG_SCHED("UB_LOOP ERROR: signal_del()\n"); return -1; @@ -412,7 +414,7 @@ static struct ub_event* my_event_new(struct ub_event_base* base, int fd, ev->added = 0; ev->fd = fd; ev->bits = bits; - ev->timeout = (uint64_t)-1; + ev->timeout = 0xFFFFFFFFFFFFFFFF; ev->cb = cb; ev->arg = arg; #ifdef USE_WINSOCK diff --git a/src/util-internal.c b/src/util-internal.c index 6934958d..2d11dabe 100644 --- a/src/util-internal.c +++ b/src/util-internal.c @@ -890,7 +890,7 @@ static int _srv_cmp(const void *a, const void *b) static void _rfc2782_sort(_srv_rr *start, _srv_rr *end) { - int running_sum, n; + uint32_t running_sum, n; _srv_rr *i, *j, swap; /* First move all SRVs with weight 0 to the beginning of the list */ @@ -1253,6 +1253,8 @@ getdns_return_t getdns_apply_network_result(getdns_network_req* netreq, int rcode, void *pkt, int pkt_len, int sec, char* why_bogus) { + (void)why_bogus; + netreq->dnssec_status = sec == 0 ? GETDNS_DNSSEC_INSECURE : sec == 2 ? GETDNS_DNSSEC_SECURE : GETDNS_DNSSEC_BOGUS;