From 3f9536c5cc9ed6659ad2514859bd1716cbf7b26b Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 12 Jan 2017 15:35:29 +0000 Subject: Types fix, first pass. Some places marked XXX for the skalibs API change. --- src/libs6dns/s6dns-message-internal.h | 5 ++-- src/libs6dns/s6dns_analyze_packet.c | 3 ++- src/libs6dns/s6dns_analyze_qtype_parse.c | 7 +++--- src/libs6dns/s6dns_analyze_record.c | 3 ++- src/libs6dns/s6dns_analyze_record_domain.c | 5 ++-- src/libs6dns/s6dns_analyze_record_hinfo.c | 5 ++-- src/libs6dns/s6dns_analyze_record_mx.c | 5 ++-- src/libs6dns/s6dns_analyze_record_soa.c | 5 ++-- src/libs6dns/s6dns_analyze_record_srv.c | 5 ++-- src/libs6dns/s6dns_analyze_record_unknown.c | 3 ++- src/libs6dns/s6dns_debug_dumpdt_post_send.c | 10 +++++--- src/libs6dns/s6dns_debug_dumpdt_pre_send.c | 6 +++-- src/libs6dns/s6dns_domain_fromstring.c | 9 ++++--- .../s6dns_domain_fromstring_noqualify_encode.c | 3 ++- .../s6dns_domain_fromstring_qualify_encode.c | 2 +- src/libs6dns/s6dns_domain_qualify.c | 3 ++- src/libs6dns/s6dns_domain_tostring.c | 3 ++- src/libs6dns/s6dns_engine.c | 13 +++++----- src/libs6dns/s6dns_fmt_domainlist.c | 5 ++-- src/libs6dns/s6dns_fmt_hinfo.c | 5 ++-- src/libs6dns/s6dns_fmt_mx.c | 5 ++-- src/libs6dns/s6dns_fmt_soa.c | 7 +++--- src/libs6dns/s6dns_fmt_srv.c | 7 +++--- src/libs6dns/s6dns_message_get_domain_internal.c | 5 ++-- src/libs6dns/s6dns_message_get_string_internal.c | 3 ++- src/libs6dns/s6dns_message_parse_answer_strings.c | 13 +++++----- src/libs6dns/s6dns_rci_init.c | 29 +++++++++++----------- src/libs6dns/s6dns_resolve_core.c | 4 +-- src/libs6dns/s6dns_resolve_dpag.c | 4 +-- src/libs6dns/s6dns_resolve_mpag.c | 4 +-- src/libs6dns/s6dns_resolve_parse.c | 4 +-- src/libs6dns/s6dns_resolvenoq.c | 4 +-- src/libs6dns/s6dns_resolvenoq_aaaaa.c | 5 ++-- src/libs6dns/s6dns_resolveq.c | 4 +-- src/libs6dns/s6dns_resolveq_aaaaa.c | 8 +++--- 35 files changed, 119 insertions(+), 92 deletions(-) (limited to 'src/libs6dns') diff --git a/src/libs6dns/s6dns-message-internal.h b/src/libs6dns/s6dns-message-internal.h index e0d10d6..9b63bcf 100644 --- a/src/libs6dns/s6dns-message-internal.h +++ b/src/libs6dns/s6dns-message-internal.h @@ -3,10 +3,11 @@ #ifndef S6DNS_MESSAGE_INTERNAL_H #define S6DNS_MESSAGE_INTERNAL_H +#include /* Low-level packet parsing */ -extern int s6dns_message_get_string_internal (char *, unsigned int, char const *, unsigned int, unsigned int *) ; -extern unsigned int s6dns_message_get_domain_internal (char *, unsigned int, char const *, unsigned int, unsigned int *) ; +extern int s6dns_message_get_string_internal (char *, size_t, char const *, unsigned int, unsigned int *) ; +extern size_t s6dns_message_get_domain_internal (char *, size_t, char const *, unsigned int, unsigned int *) ; #endif diff --git a/src/libs6dns/s6dns_analyze_packet.c b/src/libs6dns/s6dns_analyze_packet.c index 8932ab3..11c14e6 100644 --- a/src/libs6dns/s6dns_analyze_packet.c +++ b/src/libs6dns/s6dns_analyze_packet.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -84,7 +85,7 @@ int s6dns_analyze_packet (genwrite_t *gp, char const *packet, unsigned int packe s6dns_domain_t d ; char buf[257] ; unsigned int len ; - uint16 qtype ; + uint16_t qtype ; uint16 qclass ; section = s6dns_message_counts_next(&counts) ; if (section != 1) break ; diff --git a/src/libs6dns/s6dns_analyze_qtype_parse.c b/src/libs6dns/s6dns_analyze_qtype_parse.c index 8c04137..383dcde 100644 --- a/src/libs6dns/s6dns_analyze_qtype_parse.c +++ b/src/libs6dns/s6dns_analyze_qtype_parse.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -9,7 +10,7 @@ typedef struct lookuptable_s lookuptable_t, *lookuptable_t_ref ; struct lookuptable_s { char const *text ; - uint16 qtype ; + uint16_t qtype ; } ; static lookuptable_t const table[] = @@ -32,10 +33,10 @@ static lookuptable_t const table[] = { 0, 0 } } ; -uint16 s6dns_analyze_qtype_parse (char const *s) +uint16_t s6dns_analyze_qtype_parse (char const *s) { { - uint16 u ; + uint16_t u ; if (uint160_scan(s, &u)) return u ; } { diff --git a/src/libs6dns/s6dns_analyze_record.c b/src/libs6dns/s6dns_analyze_record.c index dd2e7d2..ecc5c26 100644 --- a/src/libs6dns/s6dns_analyze_record.c +++ b/src/libs6dns/s6dns_analyze_record.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -8,7 +9,7 @@ #include #include -static s6dns_analyze_rtypetable_t const *rtypelookup (uint16 rtype) +static s6dns_analyze_rtypetable_t const *rtypelookup (uint16_t rtype) { register s6dns_analyze_rtypetable_t const *wut = s6dns_analyze_rtypetable ; while (wut->rtype && wut->rtype != rtype) wut++ ; diff --git a/src/libs6dns/s6dns_analyze_record_domain.c b/src/libs6dns/s6dns_analyze_record_domain.c index f645dca..9a4b209 100644 --- a/src/libs6dns/s6dns_analyze_record_domain.c +++ b/src/libs6dns/s6dns_analyze_record_domain.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -11,9 +12,9 @@ int s6dns_analyze_record_domain (genwrite_t *gp, s6dns_message_rr_t const *rr, char const *packet, unsigned int packetlen, unsigned int start) { s6dns_domain_t d ; - char buf[S6DNS_FMT_DOMAIN] ; + size_t len ; unsigned int pos = start ; - register unsigned int len ; + char buf[S6DNS_FMT_DOMAIN] ; if (!s6dns_message_get_domain(&d, packet, packetlen, &pos)) return 0 ; if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ; len = s6dns_fmt_domain(buf, 256, &d) ; diff --git a/src/libs6dns/s6dns_analyze_record_hinfo.c b/src/libs6dns/s6dns_analyze_record_hinfo.c index 38d13d9..b294a06 100644 --- a/src/libs6dns/s6dns_analyze_record_hinfo.c +++ b/src/libs6dns/s6dns_analyze_record_hinfo.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -10,9 +11,9 @@ int s6dns_analyze_record_hinfo (genwrite_t *gp, s6dns_message_rr_t const *rr, char const *packet, unsigned int packetlen, unsigned int start) { s6dns_message_rr_hinfo_t hinfo ; - char buf[S6DNS_FMT_HINFO] ; + size_t len ; unsigned int pos = start ; - unsigned int len ; + char buf[S6DNS_FMT_HINFO] ; if (!s6dns_message_get_hinfo(&hinfo, packet, packetlen, &pos)) return 0 ; if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ; len = s6dns_fmt_hinfo(buf, S6DNS_FMT_HINFO, &hinfo) ; diff --git a/src/libs6dns/s6dns_analyze_record_mx.c b/src/libs6dns/s6dns_analyze_record_mx.c index adf9995..442ef2d 100644 --- a/src/libs6dns/s6dns_analyze_record_mx.c +++ b/src/libs6dns/s6dns_analyze_record_mx.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -10,9 +11,9 @@ int s6dns_analyze_record_mx (genwrite_t *gp, s6dns_message_rr_t const *rr, char const *packet, unsigned int packetlen, unsigned int start) { s6dns_message_rr_mx_t mx ; - char buf[S6DNS_FMT_MX] ; + size_t len ; unsigned int pos = start ; - unsigned int len ; + char buf[S6DNS_FMT_MX] ; if (!s6dns_message_get_mx(&mx, packet, packetlen, &pos)) return 0 ; if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ; len = s6dns_fmt_mx(buf, S6DNS_FMT_MX, &mx) ; diff --git a/src/libs6dns/s6dns_analyze_record_soa.c b/src/libs6dns/s6dns_analyze_record_soa.c index 68fc55f..fa4dc3a 100644 --- a/src/libs6dns/s6dns_analyze_record_soa.c +++ b/src/libs6dns/s6dns_analyze_record_soa.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -10,9 +11,9 @@ int s6dns_analyze_record_soa (genwrite_t *gp, s6dns_message_rr_t const *rr, char const *packet, unsigned int packetlen, unsigned int start) { s6dns_message_rr_soa_t soa ; - char buf[S6DNS_FMT_SOA] ; + size_t len ; unsigned int pos = start ; - unsigned int len ; + char buf[S6DNS_FMT_SOA] ; if (!s6dns_message_get_soa(&soa, packet, packetlen, &pos)) return 0 ; if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ; len = s6dns_fmt_soa(buf, S6DNS_FMT_SOA, &soa) ; diff --git a/src/libs6dns/s6dns_analyze_record_srv.c b/src/libs6dns/s6dns_analyze_record_srv.c index 9ce5b6e..a0f8c6a 100644 --- a/src/libs6dns/s6dns_analyze_record_srv.c +++ b/src/libs6dns/s6dns_analyze_record_srv.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -10,9 +11,9 @@ int s6dns_analyze_record_srv (genwrite_t *gp, s6dns_message_rr_t const *rr, char const *packet, unsigned int packetlen, unsigned int start) { s6dns_message_rr_srv_t srv ; - char buf[S6DNS_FMT_SRV] ; + size_t len ; unsigned int pos = start ; - unsigned int len ; + char buf[S6DNS_FMT_SRV] ; if (!s6dns_message_get_srv(&srv, packet, packetlen, &pos)) return 0 ; if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ; len = s6dns_fmt_srv(buf, S6DNS_FMT_SRV, &srv) ; diff --git a/src/libs6dns/s6dns_analyze_record_unknown.c b/src/libs6dns/s6dns_analyze_record_unknown.c index b5e458e..07b2941 100644 --- a/src/libs6dns/s6dns_analyze_record_unknown.c +++ b/src/libs6dns/s6dns_analyze_record_unknown.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -15,7 +16,7 @@ int s6dns_analyze_record_unknown (genwrite_t *gp, s6dns_message_rr_t const *rr, if ((*gp->put)(gp->target, fmt, uint16_fmt(fmt, rr->rdlength)) < 0) return 0 ; if ((*gp->put)(gp->target, ": ", 2) < 0) return 0 ; { - register uint16 i = 0 ; + register uint16_t i = 0 ; for (; i < rr->rdlength ; i++) if ((*gp->put)(gp->target, fmt, ucharn_fmt(fmt, packet + pos + i, 1)) < 0) return 0 ; diff --git a/src/libs6dns/s6dns_debug_dumpdt_post_send.c b/src/libs6dns/s6dns_debug_dumpdt_post_send.c index e41d595..5e7b60c 100644 --- a/src/libs6dns/s6dns_debug_dumpdt_post_send.c +++ b/src/libs6dns/s6dns_debug_dumpdt_post_send.c @@ -1,5 +1,7 @@ /* ISC license */ +#include +#include #include #include #include @@ -9,22 +11,22 @@ int s6dns_debug_dumpdt_post_send (s6dns_engine_t const *dt, void *data) { genwrite_t *gp = data ; + size_t len ; char buf[LOCALTMN_FMT] ; - unsigned int len ; if ((*gp->put)(gp->target, "Sent query ", 11) < 11) return 0 ; { - uint16 id ; + uint16_t id ; uint16_unpack_big(dt->sa.s + 2, &id) ; len = uint16_fmt(buf, id) ; } - if ((*gp->put)(gp->target, buf, len) < (int)len) return 0 ; + if ((*gp->put)(gp->target, buf, len) < (ssize_t)len) return 0 ; if ((*gp->put)(gp->target, " - next recv deadline is ", 25) < 25) return 0 ; { localtmn_t l ; if (!localtmn_from_tain(&l, &dt->localdeadline, 0)) return 0 ; len = localtmn_fmt(buf, &l) ; } - if ((*gp->put)(gp->target, buf, len) < (int)len) return 0 ; + if ((*gp->put)(gp->target, buf, len) < (ssize_t)len) return 0 ; if ((*gp->put)(gp->target, "\n\n", 2) < 2) return 0 ; return (*gp->flush)(gp->target) ; } diff --git a/src/libs6dns/s6dns_debug_dumpdt_pre_send.c b/src/libs6dns/s6dns_debug_dumpdt_pre_send.c index 998eff8..1cd6e6e 100644 --- a/src/libs6dns/s6dns_debug_dumpdt_pre_send.c +++ b/src/libs6dns/s6dns_debug_dumpdt_pre_send.c @@ -5,6 +5,8 @@ #define _BSD_SOURCE #endif +#include +#include #include #include #include @@ -27,8 +29,8 @@ int s6dns_debug_dumpdt_pre_send (s6dns_engine_t const *dt, void *data) { genwrite_t *gp = data ; + size_t len ; char buf[LOCALTMN_FMT] ; - unsigned int len ; if ((*gp->put)(gp->target, "Preparing to send via ", 22) < 22) return 0 ; if ((*gp->put)(gp->target, dt->flagtcp ? "TCP" : "UDP", 3) < 3) return 0 ; if ((*gp->put)(gp->target, " to ", 4) < 4) return 0 ; @@ -52,7 +54,7 @@ int s6dns_debug_dumpdt_pre_send (s6dns_engine_t const *dt, void *data) if (dt->flagstrict && (*gp->put)(gp->target, "strict, ", 8) < 8) return 0 ; if ((*gp->put)(gp->target, "query id ", 9) < 9) return 0 ; { - uint16 id ; + uint16_t id ; uint16_unpack_big(dt->sa.s + 2, &id) ; len = uint16_fmt(buf, id) ; } diff --git a/src/libs6dns/s6dns_domain_fromstring.c b/src/libs6dns/s6dns_domain_fromstring.c index 9346e24..92f3117 100644 --- a/src/libs6dns/s6dns_domain_fromstring.c +++ b/src/libs6dns/s6dns_domain_fromstring.c @@ -1,14 +1,15 @@ /* ISC license. */ +#include #include #include #include -int s6dns_domain_fromstring (s6dns_domain_t *d, char const *s, unsigned int len) +int s6dns_domain_fromstring (s6dns_domain_t *d, char const *s, size_t len) { - register unsigned int j = 1 ; - register unsigned int i = 0 ; - register unsigned int lastdot = 0 ; + register size_t j = 1 ; + register size_t i = 0 ; + unsigned int lastdot = 0 ; d->s[0] = '.' ; for (; i < len ; i++) { diff --git a/src/libs6dns/s6dns_domain_fromstring_noqualify_encode.c b/src/libs6dns/s6dns_domain_fromstring_noqualify_encode.c index a12f979..eb5b55a 100644 --- a/src/libs6dns/s6dns_domain_fromstring_noqualify_encode.c +++ b/src/libs6dns/s6dns_domain_fromstring_noqualify_encode.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include #include -int s6dns_domain_fromstring_noqualify_encode (s6dns_domain_t *d, char const *name, unsigned int len) +int s6dns_domain_fromstring_noqualify_encode (s6dns_domain_t *d, char const *name, size_t len) { return s6dns_domain_fromstring(d, name, len) && s6dns_domain_noqualify(d) diff --git a/src/libs6dns/s6dns_domain_fromstring_qualify_encode.c b/src/libs6dns/s6dns_domain_fromstring_qualify_encode.c index dbdea02..d57a521 100644 --- a/src/libs6dns/s6dns_domain_fromstring_qualify_encode.c +++ b/src/libs6dns/s6dns_domain_fromstring_qualify_encode.c @@ -2,7 +2,7 @@ #include -unsigned int s6dns_domain_fromstring_qualify_encode (s6dns_domain_t *list, char const *name, unsigned int len, char const *rules, unsigned int rulesnum) +unsigned int s6dns_domain_fromstring_qualify_encode (s6dns_domain_t *list, char const *name, size_t len, char const *rules, unsigned int rulesnum) { s6dns_domain_t d ; if (!s6dns_domain_fromstring(&d, name, len)) return 0 ; diff --git a/src/libs6dns/s6dns_domain_qualify.c b/src/libs6dns/s6dns_domain_qualify.c index 6194ab5..8f036be 100644 --- a/src/libs6dns/s6dns_domain_qualify.c +++ b/src/libs6dns/s6dns_domain_qualify.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -17,7 +18,7 @@ unsigned int s6dns_domain_qualify (s6dns_domain_t *list, s6dns_domain_t const *d register unsigned int i = 0 ; for (; i < rulesnum ; i++) { - unsigned int n = str_len(rules) ; + size_t n = str_len(rules) ; if (d->len + n >= 254) return (errno = ENAMETOOLONG, 0) ; list[i] = *d ; list[i].s[d->len] = '.' ; diff --git a/src/libs6dns/s6dns_domain_tostring.c b/src/libs6dns/s6dns_domain_tostring.c index ff72893..d5de7ae 100644 --- a/src/libs6dns/s6dns_domain_tostring.c +++ b/src/libs6dns/s6dns_domain_tostring.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include #include #include #include -unsigned int s6dns_domain_tostring (char *s, unsigned int max, s6dns_domain_t const *d) +unsigned int s6dns_domain_tostring (char *s, size_t max, s6dns_domain_t const *d) { if ((unsigned int)d->len + 1 > max) return (errno = ENAMETOOLONG, 0) ; if (!d->len || (d->s[0] != '.')) return (errno = EINVAL, 0) ; diff --git a/src/libs6dns/s6dns_engine.c b/src/libs6dns/s6dns_engine.c index f903ea9..c991c16 100644 --- a/src/libs6dns/s6dns_engine.c +++ b/src/libs6dns/s6dns_engine.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include +#include #include #include -#include #include #include #include @@ -21,7 +22,7 @@ /* Utility functions */ -static inline int qdomain_diff (char const *s1, unsigned int n1, char const *s2, unsigned int n2) +static inline int qdomain_diff (char const *s1, size_t n1, char const *s2, size_t n2) { return (n1 < n2) ? -1 : (n1 > n2) ? 1 : case_diffb(s1, n1, s2) ; } @@ -30,7 +31,7 @@ static int relevant (char const *q, unsigned int qlen, char const *ans, unsigned { { s6dns_message_header_t h ; - uint16 id ; + uint16_t id ; s6dns_message_header_unpack(ans, &h) ; if (!h.qr || h.opcode || h.z || (h.counts.qd != 1)) return 0 ; if (h.rd != (q[2] & 1)) return 0 ; @@ -208,7 +209,7 @@ static int s6dns_engine_read_udp (s6dns_engine_t *dt, tain_t const *stamp) { s6dns_message_header_t h ; char buf[513] ; - register int r = fd_recv(dt->fd, buf, 513, 0) ; + register ssize_t r = fd_recv(dt->fd, buf, 513, 0) ; if (r < 0) return (prepare_next(dt, stamp, 0), 0) ; if ((r > 512) || (r < 12)) return (errno = EAGAIN, 0) ; switch (relevant(dt->sa.s + 2, dt->querylen - 2, buf, r, dt->flagstrict)) @@ -255,7 +256,7 @@ static int s6dns_engine_read_udp (s6dns_engine_t *dt, tain_t const *stamp) static int s6dns_engine_read_tcp (s6dns_engine_t *dt, tain_t const *stamp) { - register int r = sanitize_read(mininetstring_read(dt->fd, &dt->sa, &dt->protostate)) ; + register ssize_t r = sanitize_read(mininetstring_read(dt->fd, &dt->sa, &dt->protostate)) ; if (r < 0) return (prepare_next(dt, stamp, 1), 0) ; else if (!r) return (errno = EAGAIN, 0) ; else if ((dt->sa.len - dt->querylen) < 12) @@ -351,7 +352,7 @@ int s6dns_engine_event (s6dns_engine_t *dt, tain_t const *stamp) return -1 ; } -int s6dns_engine_init_r (s6dns_engine_t *dt, s6dns_ip46list_t const *servers, uint32 options, char const *q, unsigned int qlen, uint16 qtype, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t const *stamp) +int s6dns_engine_init_r (s6dns_engine_t *dt, s6dns_ip46list_t const *servers, uint32_t options, char const *q, unsigned int qlen, uint16_t qtype, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t const *stamp) { s6dns_message_header_t h = S6DNS_MESSAGE_HEADER_ZERO ; if (!stralloc_ready(&dt->sa, qlen + 18)) return 0 ; diff --git a/src/libs6dns/s6dns_fmt_domainlist.c b/src/libs6dns/s6dns_fmt_domainlist.c index d53050a..625e149 100644 --- a/src/libs6dns/s6dns_fmt_domainlist.c +++ b/src/libs6dns/s6dns_fmt_domainlist.c @@ -1,13 +1,14 @@ /* ISC license. */ +#include #include #include #include #include -unsigned int s6dns_fmt_domainlist (char *s, unsigned int max, s6dns_domain_t const *list, unsigned int n, char const *delim, unsigned int delimlen) +size_t s6dns_fmt_domainlist (char *s, size_t max, s6dns_domain_t const *list, unsigned int n, char const *delim, size_t delimlen) { - unsigned int len = 0 ; + size_t len = 0 ; register unsigned int i = 0 ; for (; i < n ; i++) { diff --git a/src/libs6dns/s6dns_fmt_hinfo.c b/src/libs6dns/s6dns_fmt_hinfo.c index 8c1d7c4..2389926 100644 --- a/src/libs6dns/s6dns_fmt_hinfo.c +++ b/src/libs6dns/s6dns_fmt_hinfo.c @@ -1,13 +1,14 @@ /* ISC license. */ +#include #include #include #include #include -unsigned int s6dns_fmt_hinfo (char *s, unsigned int max, s6dns_message_rr_hinfo_t const *hinfo) +size_t s6dns_fmt_hinfo (char *s, size_t max, s6dns_message_rr_hinfo_t const *hinfo) { - if ((unsigned int)hinfo->cpu.len + 1 + (unsigned int)hinfo->os.len > max) return (errno = ENAMETOOLONG, 0) ; + if (hinfo->cpu.len + 1 + hinfo->os.len > max) return (errno = ENAMETOOLONG, 0) ; byte_copy(s, hinfo->cpu.len, hinfo->cpu.s) ; s[hinfo->cpu.len] = ' ' ; byte_copy(s + hinfo->cpu.len + 1, hinfo->os.len, hinfo->os.s) ; diff --git a/src/libs6dns/s6dns_fmt_mx.c b/src/libs6dns/s6dns_fmt_mx.c index aba538b..303c545 100644 --- a/src/libs6dns/s6dns_fmt_mx.c +++ b/src/libs6dns/s6dns_fmt_mx.c @@ -1,14 +1,15 @@ /* ISC license. */ +#include #include #include #include #include -unsigned int s6dns_fmt_mx (char *s, unsigned int max, s6dns_message_rr_mx_t const *mx) +size_t s6dns_fmt_mx (char *s, size_t max, s6dns_message_rr_mx_t const *mx) { char fmt[UINT16_FMT] ; - unsigned int len = uint16_fmt(fmt, mx->preference) ; + size_t len = uint16_fmt(fmt, mx->preference) ; unsigned int r ; if (len >= max) return 0 ; fmt[len++] = ' ' ; diff --git a/src/libs6dns/s6dns_fmt_soa.c b/src/libs6dns/s6dns_fmt_soa.c index e066c6a..b07ae14 100644 --- a/src/libs6dns/s6dns_fmt_soa.c +++ b/src/libs6dns/s6dns_fmt_soa.c @@ -1,16 +1,17 @@ /* ISC license. */ +#include #include #include #include #include #include -unsigned int s6dns_fmt_soa (char *s, unsigned int max, s6dns_message_rr_soa_t const *soa) +size_t s6dns_fmt_soa (char *s, size_t max, s6dns_message_rr_soa_t const *soa) { + size_t len = 0 ; char fmt[UINT32_FMT] ; - unsigned int len = 0 ; - register unsigned int r = s6dns_domain_tostring(s + len, max - len, &soa->mname) ; + register size_t r = s6dns_domain_tostring(s + len, max - len, &soa->mname) ; if (!r) return 0 ; len += r ; if (len >= max) return (errno = ENAMETOOLONG, 0) ; diff --git a/src/libs6dns/s6dns_fmt_srv.c b/src/libs6dns/s6dns_fmt_srv.c index ad0944b..33bfd49 100644 --- a/src/libs6dns/s6dns_fmt_srv.c +++ b/src/libs6dns/s6dns_fmt_srv.c @@ -1,16 +1,17 @@ /* ISC license. */ +#include #include #include #include #include #include -unsigned int s6dns_fmt_srv (char *s, unsigned int max, s6dns_message_rr_srv_t const *srv) +size_t s6dns_fmt_srv (char *s, size_t max, s6dns_message_rr_srv_t const *srv) { + size_t len = 0 ; char fmt[UINT16_FMT] ; - unsigned int len = 0 ; - register unsigned int r = uint16_fmt(fmt, srv->priority) ; + register size_t r = uint16_fmt(fmt, srv->priority) ; if (len + r >= max) return (errno = ENAMETOOLONG, 0) ; byte_copy(s + len, r, fmt) ; len += r ; s[len++] = ' ' ; diff --git a/src/libs6dns/s6dns_message_get_domain_internal.c b/src/libs6dns/s6dns_message_get_domain_internal.c index 357797d..64e71dc 100644 --- a/src/libs6dns/s6dns_message_get_domain_internal.c +++ b/src/libs6dns/s6dns_message_get_domain_internal.c @@ -1,13 +1,14 @@ /* ISC license. */ +#include #include #include #include #include "s6dns-message-internal.h" -unsigned int s6dns_message_get_domain_internal (char *out, unsigned int outmax, char const *s, unsigned int len, unsigned int *pos) +size_t s6dns_message_get_domain_internal (char *out, size_t outmax, char const *s, unsigned int len, unsigned int *pos) { - unsigned int w = 0 ; /* writing head */ + size_t w = 0 ; /* writing head */ unsigned int r = *pos ; /* reading head */ unsigned int jumps = 0 ; register int hasjumped = 0 ; diff --git a/src/libs6dns/s6dns_message_get_string_internal.c b/src/libs6dns/s6dns_message_get_string_internal.c index 4f6eb0c..7e4105b 100644 --- a/src/libs6dns/s6dns_message_get_string_internal.c +++ b/src/libs6dns/s6dns_message_get_string_internal.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include #include #include #include #include "s6dns-message-internal.h" -int s6dns_message_get_string_internal (char *s, unsigned int max, char const *packet, unsigned int packetlen, unsigned int *pos) +int s6dns_message_get_string_internal (char *s, size_t max, char const *packet, unsigned int packetlen, unsigned int *pos) { register unsigned char len = ((unsigned char const *)packet)[*pos] ; if (*pos + len + 1 > packetlen) return (errno = EPROTO, -1) ; diff --git a/src/libs6dns/s6dns_message_parse_answer_strings.c b/src/libs6dns/s6dns_message_parse_answer_strings.c index 09470c7..f5ac783 100644 --- a/src/libs6dns/s6dns_message_parse_answer_strings.c +++ b/src/libs6dns/s6dns_message_parse_answer_strings.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -8,27 +9,25 @@ int s6dns_message_parse_answer_strings (s6dns_message_rr_t const *rr, char const *packet, unsigned int packetlen, unsigned int pos, unsigned int section, void *stuff) { - s6dns_mpag_t_ref data = stuff ; + s6dns_mpag_t *data = stuff ; if ((section == 2) && (rr->rtype == data->rtype)) { - unsigned int base = data->sa.len ; + size_t base = data->sa.len ; int wasnull = !data->sa.s ; unsigned int start = pos ; register int r ; if (!stralloc_readyplus(&data->sa, rr->rdlength + 1)) return -1 ; - errno = EPROTO ; r = s6dns_message_get_strings(data->sa.s + data->sa.len, rr->rdlength, packet, packetlen, &pos) ; if ((r < 0) || (rr->rdlength != pos - start)) { if (wasnull) stralloc_free(&data->sa) ; else data->sa.len = base ; - return 0 ; + return (errno = EPROTO, 0) ; } - if (!genalloc_append(unsigned int, &data->offsets, &data->sa.len)) + if (!genalloc_append(size_t, &data->offsets, &data->sa.len)) { if (wasnull) stralloc_free(&data->sa) ; else data->sa.len = base ; - return -1 ; + return (errno = EPROTO, -1) ; } - errno = 0 ; data->sa.len += r ; stralloc_0(&data->sa) ; } diff --git a/src/libs6dns/s6dns_rci_init.c b/src/libs6dns/s6dns_rci_init.c index a4f3fcf..e7d3676 100644 --- a/src/libs6dns/s6dns_rci_init.c +++ b/src/libs6dns/s6dns_rci_init.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -12,19 +13,19 @@ #include #include -static unsigned int readit (char const *file, char *buf, unsigned int max) +static size_t readit (char const *file, char *buf, size_t max) { - register int r = openreadnclose(file, buf, max - 1) ; + register ssize_t r = openreadnclose(file, buf, max - 1) ; if (r < 0) { if (errno != ENOENT) return 0 ; else r = 0 ; } buf[r++] = '\n' ; - return (unsigned int)r ; + return r ; } -static inline int s6dns_rci_init_servers (s6dns_rci_t *rci, char const *file, char *tmp, unsigned int max, unsigned int *size) +static inline int s6dns_rci_init_servers (s6dns_rci_t *rci, char const *file, char *tmp, size_t max, size_t *size) { ip46_t tmplist[S6DNS_MAX_SERVERS] ; unsigned int num = 0 ; @@ -32,15 +33,15 @@ static inline int s6dns_rci_init_servers (s6dns_rci_t *rci, char const *file, ch if (x) ip46_scanlist(tmplist, S6DNS_MAX_SERVERS, x, &num) ; if (!num) { - unsigned int i = 0 ; + size_t i = 0 ; *size = readit(file, tmp, max) ; if (!*size) return 0 ; while ((i < *size) && (num < S6DNS_MAX_SERVERS)) { - register unsigned int j = byte_chr(tmp + i, *size - i, '\n') ; + register size_t j = byte_chr(tmp + i, *size - i, '\n') ; if ((i + j < *size) && (j > 13U) && !byte_diff("nameserver", 10, tmp + i)) { - register unsigned int k = 0 ; + register size_t k = 0 ; while ((tmp[i+10+k] == ' ') || (tmp[i+10+k] == '\t')) k++ ; if (k && ip46_scan(tmp+i+10+k, tmplist + num)) num++ ; } @@ -72,10 +73,10 @@ static inline int s6dns_rci_init_servers (s6dns_rci_t *rci, char const *file, ch static inline int stringrules (stralloc *rules, char const *s, unsigned int *num) { + size_t base = rules->len ; + int wasnull = !rules->s ; unsigned int n = 0 ; int crunching = 1 ; - int wasnull = !rules->s ; - unsigned int base = rules->len ; char c = ' ' ; while (c) { @@ -105,7 +106,7 @@ static inline int stringrules (stralloc *rules, char const *s, unsigned int *num return 0 ; } -static inline int s6dns_rci_init_rules (s6dns_rci_t_ref rci, char const *file, char *tmp, unsigned int max, unsigned int *size) +static inline int s6dns_rci_init_rules (s6dns_rci_t_ref rci, char const *file, char *tmp, size_t max, size_t *size) { unsigned int num = 0 ; char const *x = env_get("DNSQUALIFY") ; @@ -115,7 +116,7 @@ static inline int s6dns_rci_init_rules (s6dns_rci_t_ref rci, char const *file, c } else { - unsigned int i = 0 ; + size_t i = 0 ; if (!*size) { *size = readit(file, tmp, max) ; @@ -123,12 +124,12 @@ static inline int s6dns_rci_init_rules (s6dns_rci_t_ref rci, char const *file, c } while (i < *size) { - register unsigned int j = byte_chr(tmp + i, *size - i, '\n') ; + size_t j = byte_chr(tmp + i, *size - i, '\n') ; if ((i + j < *size) && (j > 8U) && (!byte_diff("domain", 6, tmp + i) || !byte_diff("search", 6, tmp + i)) && ((tmp[i+6] == ' ') || (tmp[i+6] == '\t') || (tmp[i+6] == '\r'))) { - unsigned int k = 0 ; + size_t k = 0 ; int copying = 0 ; register int notsearching = (tmp[i] != 's') ; if (!stralloc_readyplus(&rci->rules, j)) return 0 ; @@ -166,7 +167,7 @@ static inline int s6dns_rci_init_rules (s6dns_rci_t_ref rci, char const *file, c int s6dns_rci_init (s6dns_rci_t *rci, char const *file) { char tmp[4096] ; - unsigned int size = 0 ; + size_t size = 0 ; if (!s6dns_rci_init_servers(rci, file, tmp, 4096, &size)) return 0 ; if (!s6dns_rci_init_rules(rci, file, tmp, 4096, &size)) return 0 ; return 1 ; diff --git a/src/libs6dns/s6dns_resolve_core.c b/src/libs6dns/s6dns_resolve_core.c index a3c51c1..c321869 100644 --- a/src/libs6dns/s6dns_resolve_core.c +++ b/src/libs6dns/s6dns_resolve_core.c @@ -1,7 +1,7 @@ /* ISC license. */ +#include #include -#include #include #include #include @@ -9,7 +9,7 @@ #include #include -int s6dns_resolve_core_r (s6dns_domain_t const *d, uint16 qtype, s6dns_engine_t *dt, s6dns_ip46list_t const *servers, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) +int s6dns_resolve_core_r (s6dns_domain_t const *d, uint16_t qtype, s6dns_engine_t *dt, s6dns_ip46list_t const *servers, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) { if (!s6dns_engine_init_r(dt, servers, S6DNS_O_RECURSIVE, d->s, d->len, qtype, dbh, deadline, stamp)) return 0 ; if (!s6dns_resolve_loop_r(dt, deadline, stamp)) diff --git a/src/libs6dns/s6dns_resolve_dpag.c b/src/libs6dns/s6dns_resolve_dpag.c index 7c735b8..0bc5a42 100644 --- a/src/libs6dns/s6dns_resolve_dpag.c +++ b/src/libs6dns/s6dns_resolve_dpag.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include #include @@ -8,7 +8,7 @@ #include #include -int s6dns_resolve_dpag_r (genalloc *ds, char const *name, unsigned int len, uint16 qtype, int qualif, s6dns_engine_t *dt, s6dns_rci_t const *rci, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) +int s6dns_resolve_dpag_r (genalloc *ds, char const *name, unsigned int len, uint16_t qtype, int qualif, s6dns_engine_t *dt, s6dns_rci_t const *rci, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) { s6dns_dpag_t data ; register int r ; diff --git a/src/libs6dns/s6dns_resolve_mpag.c b/src/libs6dns/s6dns_resolve_mpag.c index a6e04cb..ca0ab1a 100644 --- a/src/libs6dns/s6dns_resolve_mpag.c +++ b/src/libs6dns/s6dns_resolve_mpag.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include #include @@ -9,7 +9,7 @@ #include #include -int s6dns_resolve_mpag_r (stralloc *sa, genalloc *offsets, char const *name, unsigned int len, uint16 qtype, s6dns_message_rr_func_t_ref parsefunc, int qualif, s6dns_engine_t *dt, s6dns_rci_t const *rci, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) +int s6dns_resolve_mpag_r (stralloc *sa, genalloc *offsets, char const *name, unsigned int len, uint16_t qtype, s6dns_message_rr_func_t_ref parsefunc, int qualif, s6dns_engine_t *dt, s6dns_rci_t const *rci, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) { s6dns_mpag_t data ; register int r ; diff --git a/src/libs6dns/s6dns_resolve_parse.c b/src/libs6dns/s6dns_resolve_parse.c index b00804f..b2e4974 100644 --- a/src/libs6dns/s6dns_resolve_parse.c +++ b/src/libs6dns/s6dns_resolve_parse.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include #include @@ -8,7 +8,7 @@ #include #include -int s6dns_resolve_parse_r (s6dns_domain_t const *d, uint16 qtype, s6dns_message_rr_func_t_ref parsefunc, void *data, s6dns_engine_t *dt, s6dns_ip46list_t const *servers, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) +int s6dns_resolve_parse_r (s6dns_domain_t const *d, uint16_t qtype, s6dns_message_rr_func_t_ref parsefunc, void *data, s6dns_engine_t *dt, s6dns_ip46list_t const *servers, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) { register int r ; if (!s6dns_resolve_core_r(d, qtype, dt, servers, dbh, deadline, stamp)) return -1 ; diff --git a/src/libs6dns/s6dns_resolvenoq.c b/src/libs6dns/s6dns_resolvenoq.c index 3462076..5269655 100644 --- a/src/libs6dns/s6dns_resolvenoq.c +++ b/src/libs6dns/s6dns_resolvenoq.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include #include @@ -8,7 +8,7 @@ #include #include -int s6dns_resolvenoq_r (char const *name, unsigned int len, uint16 qtype, s6dns_message_rr_func_t_ref parsefunc, void *data, s6dns_engine_t *dt, s6dns_ip46list_t const *servers, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) +int s6dns_resolvenoq_r (char const *name, unsigned int len, uint16_t qtype, s6dns_message_rr_func_t_ref parsefunc, void *data, s6dns_engine_t *dt, s6dns_ip46list_t const *servers, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) { s6dns_domain_t d ; if (!s6dns_domain_fromstring_noqualify_encode(&d, name, len)) return -1 ; diff --git a/src/libs6dns/s6dns_resolvenoq_aaaaa.c b/src/libs6dns/s6dns_resolvenoq_aaaaa.c index b280fe0..d10b20b 100644 --- a/src/libs6dns/s6dns_resolvenoq_aaaaa.c +++ b/src/libs6dns/s6dns_resolvenoq_aaaaa.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -35,9 +36,9 @@ int s6dns_resolvenoq_aaaaa_r (genalloc *ips, char const *name, unsigned int len, return -1 ; } { - unsigned int n = genalloc_len(ip46_t, ips) ; int e = (!!sa[0].len << 1) | !!sa[1].len ; - register unsigned int i = 0 ; + size_t n = genalloc_len(ip46_t, ips) ; + register size_t i = 0 ; for (; i < (sa[0].len >> 4) ; i++) ip46_from_ip6(genalloc_s(ip46_t, ips) + n++, sa[0].s + (i << 4)) ; for (i = 0 ; i < (sa[1].len >> 2) ; i++) diff --git a/src/libs6dns/s6dns_resolveq.c b/src/libs6dns/s6dns_resolveq.c index c43db1f..7fad70f 100644 --- a/src/libs6dns/s6dns_resolveq.c +++ b/src/libs6dns/s6dns_resolveq.c @@ -1,7 +1,7 @@ /* ISC license. */ +#include #include -#include #include #include #include @@ -10,7 +10,7 @@ #include #include -int s6dns_resolveq_r (char const *name, unsigned int len, uint16 qtype, s6dns_message_rr_func_t_ref parsefunc, void *data, s6dns_rci_t const *rci, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) +int s6dns_resolveq_r (char const *name, unsigned int len, uint16_t qtype, s6dns_message_rr_func_t_ref parsefunc, void *data, s6dns_rci_t const *rci, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) { s6dns_engine_t dtl[rci->rulesnum] ; unsigned int best = 0 ; diff --git a/src/libs6dns/s6dns_resolveq_aaaaa.c b/src/libs6dns/s6dns_resolveq_aaaaa.c index 825e68e..cbc853f 100644 --- a/src/libs6dns/s6dns_resolveq_aaaaa.c +++ b/src/libs6dns/s6dns_resolveq_aaaaa.c @@ -1,7 +1,7 @@ /* ISC license. */ +#include #include -#include #include #include #include @@ -75,9 +75,9 @@ int s6dns_resolveq_aaaaa_r (genalloc *ips, char const *name, unsigned int len, s found: s6dns_engine_freen(dtl, n<<1) ; { - register unsigned int len = data.len >> ((best & 1) ? 2 : 4) ; - register unsigned int i = 0 ; - register unsigned int base = genalloc_len(ip46_t, ips) ; + register size_t len = data.len >> ((best & 1) ? 2 : 4) ; + register size_t i = 0 ; + register size_t base = genalloc_len(ip46_t, ips) ; if (!genalloc_readyplus(ip46_t, ips, len)) return -1 ; for (; i < len ; i++) ip46_from_ip(genalloc_s(ip46_t, ips) + base + i, data.s + (i << ((best & 1) ? 2 : 4)), !(best & 1)) ; -- cgit v1.2.3