Per discussion in https://github.com/gentoo/gentoo/pull/36138#discussion_r1594836910 transformed u_intX_t to uintX_t, changed relevant includes and trimmed really redundant checks, includes, undefines https://bugs.gentoo.org/880341 --- a/acconfig.h +++ b/acconfig.h @@ -1,18 +1,6 @@ /* Define if kqueue works correctly with pipes */ #undef HAVE_WORKING_KQUEUE -/* Define to `unsigned long long' if doesn't define. */ -#undef u_int64_t - -/* Define to `unsigned int' if doesn't define. */ -#undef u_int32_t - -/* Define to `unsigned short' if doesn't define. */ -#undef u_int16_t - -/* Define to `unsigned char' if doesn't define. */ -#undef u_int8_t - /* Define if timeradd is defined in */ #undef HAVE_TIMERADD #ifndef HAVE_TIMERADD --- a/arc4random.c +++ b/arc4random.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -10,8 +10,8 @@ * application anyway. Screw you, hippy! */ -u_int32_t arc4random(void); -u_int32_t arc4random(void) +uint32_t arc4random(void); +uint32_t arc4random(void) { static int init; --- a/base64.c +++ b/base64.c @@ -42,7 +42,6 @@ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. */ -#include #include #include #include @@ -52,6 +51,7 @@ #include #include +#include #include #include --- a/config.h.in +++ b/config.h.in @@ -2,18 +2,6 @@ /* Define if kqueue works correctly with pipes */ #undef HAVE_WORKING_KQUEUE -/* Define to `unsigned long long' if doesn't define. */ -#undef u_int64_t - -/* Define to `unsigned int' if doesn't define. */ -#undef u_int32_t - -/* Define to `unsigned short' if doesn't define. */ -#undef u_int16_t - -/* Define to `unsigned char' if doesn't define. */ -#undef u_int8_t - /* Define if timeradd is defined in */ #undef HAVE_TIMERADD #ifndef HAVE_TIMERADD @@ -250,14 +238,3 @@ /* Define to unsigned int if you dont have it */ #undef socklen_t -/* Define to `unsigned short' if does not define. */ -#undef u_int16_t - -/* Define to `unsigned int' if does not define. */ -#undef u_int32_t - -/* Define to `unsigned long long' if does not define. */ -#undef u_int64_t - -/* Define to `unsigned char' if does not define. */ -#undef u_int8_t --- a/configure.in +++ b/configure.in @@ -167,10 +167,6 @@ AC_TYPE_PID_T AC_TYPE_SIZE_T -AC_CHECK_TYPE(u_int64_t, unsigned long long) -AC_CHECK_TYPE(u_int32_t, unsigned int) -AC_CHECK_TYPE(u_int16_t, unsigned short) -AC_CHECK_TYPE(u_int8_t, unsigned char) AC_MSG_CHECKING([for sin_len]) AC_TRY_COMPILE([ --- a/dnsres-internal.h +++ b/dnsres-internal.h @@ -101,6 +101,9 @@ * --Copyright-- */ + +#include + #ifndef _DNSRES_INTERNAL_H_ #define _DNSRES_INTERNAL_H_ @@ -305,24 +308,24 @@ */ #define DNSRES_GETSHORT(s, cp) { \ unsigned char *t_cp = (unsigned char *)(cp); \ - (s) = ((u_int16_t)t_cp[0] << 8) \ - | ((u_int16_t)t_cp[1]) \ + (s) = ((uint16_t)t_cp[0] << 8) \ + | ((uint16_t)t_cp[1]) \ ; \ (cp) += INT16SZ; \ } #define DNSRES_GETLONG(l, cp) { \ unsigned char *t_cp = (unsigned char *)(cp); \ - (l) = ((u_int32_t)t_cp[0] << 24) \ - | ((u_int32_t)t_cp[1] << 16) \ - | ((u_int32_t)t_cp[2] << 8) \ - | ((u_int32_t)t_cp[3]) \ + (l) = ((uint32_t)t_cp[0] << 24) \ + | ((uint32_t)t_cp[1] << 16) \ + | ((uint32_t)t_cp[2] << 8) \ + | ((uint32_t)t_cp[3]) \ ; \ (cp) += INT32SZ; \ } #define DNSRES_PUTSHORT(s, cp) { \ - u_int16_t t_s = (u_int16_t)(s); \ + uint16_t t_s = (uint16_t)(s); \ unsigned char *t_cp = (unsigned char *)(cp); \ *t_cp++ = t_s >> 8; \ *t_cp = t_s; \ @@ -330,7 +333,7 @@ } #define DNSRES_PUTLONG(l, cp) { \ - u_int32_t t_l = (u_int32_t)(l); \ + uint32_t t_l = (uint32_t)(l); \ unsigned char *t_cp = (unsigned char *)(cp); \ *t_cp++ = t_l >> 24; \ *t_cp++ = t_l >> 16; \ --- a/dnsres.h +++ b/dnsres.h @@ -118,7 +118,7 @@ #define _DNSRES_H_ #include -#include +#include /* * Type values for resources and queries @@ -482,7 +482,7 @@ char unused[3]; struct { struct in_addr addr; - u_int32_t mask; + uint32_t mask; } sort_list[MAXRESOLVSORT]; char lookups[MAXDNSLUS]; --- a/getaddrinfo.c +++ b/getaddrinfo.c @@ -110,7 +110,7 @@ #include "config.h" #endif -#include +#include #include #include #include @@ -221,7 +221,7 @@ static int get_port(struct dnsres_servent_state *, struct addrinfo *, const char *, int); static const struct afd *find_afd(int); -static int ip6_str2scopeid(char *, struct sockaddr_in6 *, u_int32_t *); +static int ip6_str2scopeid(char *, struct sockaddr_in6 *, uint32_t *); static void _sethtent(struct dnsres_hostent_state *); static void _endhtent(struct dnsres_hostent_state *); @@ -969,7 +969,7 @@ error = explore_numeric(state, pai, addr, servname, res, hostname); if (error == 0) { - u_int32_t scopeid; + uint32_t scopeid; for (cur = *res; cur; cur = cur->ai_next) { if (cur->ai_family != AF_INET6) @@ -1148,10 +1148,7 @@ /* convert a string to a scope identifier. XXX: IPv6 specific */ static int -ip6_str2scopeid(scope, sin6, scopeid) - char *scope; - struct sockaddr_in6 *sin6; - u_int32_t *scopeid; +ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6, uint32_t *scopeid) { u_long lscopeid; struct in6_addr *a6 = &sin6->sin6_addr; @@ -1185,7 +1182,7 @@ trynumeric: errno = 0; lscopeid = strtoul(scope, &ep, 10); - *scopeid = (u_int32_t)(lscopeid & 0xffffffffUL); + *scopeid = (uint32_t)(lscopeid & 0xffffffffUL); if (errno == 0 && ep && *ep == '\0' && *scopeid == lscopeid) return 0; else --- a/res_comp.c +++ b/res_comp.c @@ -64,6 +64,7 @@ #include #include +#include #include #include #include @@ -81,10 +82,7 @@ * Return size of compressed name or -1 if there was an error. */ int -dn_expand(msg, eomorig, comp_dn, exp_dn, length) - const u_char *msg, *eomorig, *comp_dn; - char *exp_dn; - int length; +dn_expand(const u_char *msg, const u_char *eomorig, const u_char *comp_dn, char *exp_dn, int length) { const u_char *cp; char *dn; @@ -165,10 +163,7 @@ * is NULL, we don't update the list. */ int -dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr) - const char *exp_dn; - u_char *comp_dn, **dnptrs, **lastdnptr; - int length; +dn_comp(const char *exp_dn, u_char *comp_dn, int length, u_char **dnptrs, u_char **lastdnptr) { register u_char *cp, *dn; register int c, l; @@ -245,8 +240,7 @@ * Skip over a compressed domain name. Return the size or -1. */ int -__dnsres_dn_skipname(comp_dn, eom) - const u_char *comp_dn, *eom; +__dnsres_dn_skipname(const u_char *comp_dn, const u_char *eom) { register const u_char *cp; register int n; @@ -289,9 +283,7 @@ * not the pointer to the start of the message. */ static int -dn_find(exp_dn, msg, dnptrs, lastdnptr) - u_char *exp_dn, *msg; - u_char **dnptrs, **lastdnptr; +dn_find(u_char *exp_dn, u_char *msg, u_char **dnptrs, u_char **lastdnptr) { register u_char *dn, *cp, **cpp; register int n; @@ -389,8 +381,7 @@ * but must otherwise be as a host name. */ int -res_ownok(dn) - const char *dn; +res_ownok(const char *dn) { if (asterchar(dn[0])) { if (periodchar(dn[1])) @@ -406,8 +397,7 @@ * label, but the rest of the name has to look like a host name. */ int -res_mailok(dn) - const char *dn; +res_mailok(const char *dn) { int ch, escaped = 0; @@ -436,8 +426,7 @@ * recommendations. */ int -res_dnok(dn) - const char *dn; +res_dnok(const char *dn) { int ch; @@ -451,36 +440,32 @@ * Routines to insert/extract short/long's. */ -u_int16_t -__dnsres_getshort(msgp) - register const u_char *msgp; +uint16_t +__dnsres_getshort(register const u_char *msgp) { - register u_int16_t u; + register uint16_t u; DNSRES_GETSHORT(u, msgp); return (u); } -u_int32_t -__dnsres_getlong(msgp) - register const u_char *msgp; +uint32_t +__dnsres_getlong(register const u_char *msgp) { - register u_int32_t u; + register uint32_t u; DNSRES_GETLONG(u, msgp); return (u); } void -__dnsres_putshort(register u_int16_t s, register u_char *msgp) +__dnsres_putshort(register uint16_t s, register u_char *msgp) { DNSRES_PUTSHORT(s, msgp); } void -__dnsres_putlong(l, msgp) - register u_int32_t l; - register u_char *msgp; +__dnsres_putlong(register uint32_t l, register u_char *msgp) { DNSRES_PUTLONG(l, msgp); } --- a/res_debug.c +++ b/res_debug.c @@ -73,8 +73,9 @@ * --Copyright-- */ +#include #include -#include +#include #include #include #include @@ -457,9 +458,9 @@ int type, class, dlen, n, c; struct in_addr inaddr; const u_char *cp1, *cp2; - u_int32_t tmpttl, t; + uint32_t tmpttl, t; int lcnt; - u_int16_t keyflags; + uint16_t keyflags; char rrname[DNSRES_MAXDNAME]; /* The fqdn of this RR */ char base64_key[MAX_KEY_BASE64]; @@ -1010,7 +1011,7 @@ * Return a mnemonic for a time to live */ const char * -p_time(u_int32_t value) +p_time(uint32_t value) { static char nbuf[40]; char *ebuf; @@ -1091,7 +1092,7 @@ /* takes an XeY precision/size value, returns a string representation. */ static const char * -precsize_ntoa(u_int8_t prec) +precsize_ntoa(uint8_t prec) { static char retbuf[sizeof "90000000.00"]; unsigned long val; @@ -1107,11 +1108,11 @@ } /* converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer. */ -static u_int8_t +static uint8_t precsize_aton(unsigned char **strptr) { unsigned int mval = 0, cmval = 0; - u_int8_t retval = 0; + uint8_t retval = 0; unsigned char *cp; int exponent; int mantissa; @@ -1148,11 +1149,11 @@ } /* converts ascii lat/lon to unsigned encoded 32-bit number. moves pointer. */ -static u_int32_t +static uint32_t latlon2ul(unsigned char **latlonstrptr, int *which) { unsigned char *cp; - u_int32_t retval; + uint32_t retval; int deg = 0, min = 0, secs = 0, secsfrac = 0; cp = *latlonstrptr; @@ -1252,12 +1253,12 @@ u_char *bcp; unsigned char *cp; - u_int32_t latit = 0, longit = 0, alt = 0; - u_int32_t lltemp1 = 0, lltemp2 = 0; + uint32_t latit = 0, longit = 0, alt = 0; + uint32_t lltemp1 = 0, lltemp2 = 0; int altmeters = 0, altfrac = 0, altsign = 1; - u_int8_t hp = 0x16; /* default = 1e6 cm = 10000.00m = 10km */ - u_int8_t vp = 0x13; /* default = 1e3 cm = 10.00m */ - u_int8_t siz = 0x12; /* default = 1e2 cm = 1.00m */ + uint8_t hp = 0x16; /* default = 1e6 cm = 10000.00m = 10km */ + uint8_t vp = 0x13; /* default = 1e3 cm = 10.00m */ + uint8_t siz = 0x12; /* default = 1e2 cm = 1.00m */ int which1 = 0, which2 = 0; cp = (unsigned char *)ascii; @@ -1343,7 +1344,7 @@ defaults: bcp = binary; - *bcp++ = (u_int8_t) 0; /* version byte */ + *bcp++ = (uint8_t) 0; /* version byte */ *bcp++ = siz; *bcp++ = hp; *bcp++ = vp; @@ -1375,8 +1376,8 @@ const int referencealt = 100000 * 100; int32_t latval, longval, altval; - u_int32_t templ; - u_int8_t sizeval, hpval, vpval, versionval; + uint32_t templ; + uint8_t sizeval, hpval, vpval, versionval; char *sizestr, *hpstr, *vpstr; --- a/res_init.c +++ b/res_init.c @@ -85,7 +85,7 @@ #include "config.h" #endif -#include +#include #include #include #include @@ -137,7 +137,7 @@ #ifdef RESOLVSORT static const char sort_mask[] = "/&"; #define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL) -static u_int32_t net_mask(struct in_addr); +static uint32_t net_mask(struct in_addr); #endif /* @@ -603,11 +603,10 @@ #ifdef RESOLVSORT /* XXX - should really support CIDR which means explicit masks always. */ -static u_int32_t -net_mask(in) /* XXX - should really use system's version of this */ - struct in_addr in; +static uint32_t +net_mask(struct in_addr in) /* XXX - should really use system's version of this */ { - register u_int32_t i = ntohl(in.s_addr); + register uint32_t i = ntohl(in.s_addr); if (IN_CLASSA(i)) return (htonl(IN_CLASSA_NET)); --- a/res_random.c +++ b/res_random.c @@ -54,7 +54,7 @@ * so that an attacker will not get sequential ids. */ -#include +#include #include #include @@ -72,23 +72,23 @@ #define RU_M 31104 /* RU_M = 2^7*3^5 - don't change */ #define PFAC_N 3 -const static u_int16_t pfacts[PFAC_N] = { +const static uint16_t pfacts[PFAC_N] = { 2, 3, 2729 }; -static u_int16_t ru_x; -static u_int16_t ru_seed, ru_seed2; -static u_int16_t ru_a, ru_b; -static u_int16_t ru_g; -static u_int16_t ru_counter = 0; -static u_int16_t ru_msb = 0; +static uint16_t ru_x; +static uint16_t ru_seed, ru_seed2; +static uint16_t ru_a, ru_b; +static uint16_t ru_g; +static uint16_t ru_counter = 0; +static uint16_t ru_msb = 0; static long ru_reseed; -static u_int32_t tmp; /* Storage for unused random */ +static uint32_t tmp; /* Storage for unused random */ static struct timeval tv; -static u_int16_t pmod(u_int16_t, u_int16_t, u_int16_t); +static uint16_t pmod(uint16_t, uint16_t, uint16_t); static void res_initid(void); /* @@ -96,10 +96,10 @@ * of 0 - (mod-1) */ -static u_int16_t -pmod(u_int16_t gen, u_int16_t exp, u_int16_t mod) +static uint16_t +pmod(uint16_t gen, uint16_t exp, uint16_t mod) { - u_int16_t s, t, u; + uint16_t s, t, u; s = 1; t = gen; @@ -125,7 +125,7 @@ static void res_initid() { - u_int16_t j, i; + uint16_t j, i; int noprime = 1; tmp = arc4random(); @@ -208,7 +208,7 @@ main(int argc, char **argv) { int i, n; - u_int16_t wert; + uint16_t wert; res_initid(); --- a/resolv.h +++ b/resolv.h @@ -119,7 +119,8 @@ #define _RESOLV_H_ #include -# include +#include +#include #include #include @@ -293,10 +294,10 @@ void fp_nquery(struct dnsres *, const unsigned char *msg, int len, FILE *file); const char * hostalias(struct dnsres *, const char *); -void putlong(u_int32_t, unsigned char *); -void putshort(u_int16_t, unsigned char *); +void putlong(uint32_t, unsigned char *); +void putshort(uint16_t, unsigned char *); const char * p_class(int); -const char * p_time(u_int32_t); +const char * p_time(uint32_t); const char * p_type(int); void p_query(struct dnsres *, const unsigned char *); @@ -365,7 +366,7 @@ #endif #ifndef ARC4RANDOM -u_int32_t arc4random(void); +uint32_t arc4random(void); #endif #endif /* !_RESOLV_H_ */