Throughout Cygwin, use u_intN_t or uintN_t

Don't use u_char, u_short, u_int or u_long in Cygwin, unless it refers
to the Winsock types.  Use u_intN_t in BSD-based sources, unsigned char
where strings are concerned, uintN_t otherwise.  Also:

	* net.cc: Fix comment, we're not using u_long anymore.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2016-03-24 16:39:15 +01:00
parent 6ba2b53c53
commit acc5f02ce8
16 changed files with 86 additions and 82 deletions

View File

@@ -24,9 +24,7 @@ details. */
#ifdef __x86_64__
/* 2014-04-24: Current Mingw headers define sockaddr_in6 using u_long (8 byte)
because a redefinition for LP64 systems is missing. This leads to a wrong
definition and size of sockaddr_in6 when building with winsock headers.
This definition is also required to use the right u_long type in subsequent
function calls. */
definition and size of sockaddr_in6 when building with winsock headers. */
#undef u_long
#define u_long __ms_u_long
#endif
@@ -1183,7 +1181,7 @@ cygwin_gethostbyaddr (const char *addr, int len, int type)
}
static void
memcpy4to6 (char *dst, const u_char *src)
memcpy4to6 (char *dst, const u_int8_t *src)
{
const unsigned int h[] = {0, 0, htonl (0xFFFF)};
memcpy (dst, h, 12);
@@ -1206,7 +1204,7 @@ gethostby_specials (const char *name, const int af,
}
int res;
u_char address[NS_IN6ADDRSZ];
u_int8_t address[NS_IN6ADDRSZ];
/* Test for numerical addresses */
res = cygwin_inet_pton(af, name, address);
/* Test for special domain names */
@@ -1295,7 +1293,7 @@ gethostby_helper (const char *name, const int af, const int type,
/* Get the data from the name server */
const int maxcount = 3;
int old_errno, ancount = 0, anlen = 1024, msgsize = 0;
u_char *ptr, *msg = NULL;
unsigned char *ptr, *msg = NULL;
int sz;
hostent *ret;
char *string_ptr;
@@ -1303,7 +1301,7 @@ gethostby_helper (const char *name, const int af, const int type,
while ((anlen > msgsize) && (ancount++ < maxcount))
{
msgsize = anlen;
ptr = (u_char *) realloc (msg, msgsize);
ptr = (unsigned char *) realloc (msg, msgsize);
if (ptr == NULL )
{
old_errno = errno;
@@ -1329,7 +1327,7 @@ gethostby_helper (const char *name, const int af, const int type,
set_errno (old_errno);
return NULL;
}
u_char *eomsg = msg + anlen - 1;
unsigned char *eomsg = msg + anlen - 1;
/* We scan the answer records to determine the required memory size.
They can be corrupted and we don't fully trust that the message
@@ -1349,10 +1347,11 @@ gethostby_helper (const char *name, const int af, const int type,
unsigned namelen1: 16; // expanded length (with final 0)
unsigned next_o: 16; // offset to next valid
unsigned size: 16; // data size
u_char data[]; // data
unsigned char data[]; // data
record * next () { return (record *) (((char *) this) + next_o); }
void set_next ( record * nxt) { next_o = ((char *) nxt) - ((char *) this); }
u_char * name () { return (u_char *) (((char *) this) - complen); }
unsigned char *name () { return (unsigned char *)
(((char *) this) - complen); }
};
record * anptr = NULL, * prevptr = NULL, * curptr;
@@ -2971,11 +2970,11 @@ cygwin_sendmsg (int fd, const struct msghdr *msg, int flags)
* Paul Vixie, 1996.
*/
static int
inet_pton4 (const char *src, u_char *dst)
inet_pton4 (const char *src, u_int8_t *dst)
{
static const char digits[] = "0123456789";
int saw_digit, octets, ch;
u_char tmp[INADDRSZ], *tp;
u_int8_t tmp[INADDRSZ], *tp;
saw_digit = 0;
octets = 0;
@@ -2986,7 +2985,7 @@ inet_pton4 (const char *src, u_char *dst)
if ((pch = strchr(digits, ch)) != NULL)
{
u_int ret = *tp * 10 + (pch - digits);
u_int32_t ret = *tp * 10 + (pch - digits);
if (ret > 255)
return (0);
@@ -3029,14 +3028,14 @@ inet_pton4 (const char *src, u_char *dst)
* Paul Vixie, 1996.
*/
static int
inet_pton6 (const char *src, u_char *dst)
inet_pton6 (const char *src, u_int8_t *dst)
{
static const char xdigits_l[] = "0123456789abcdef",
xdigits_u[] = "0123456789ABCDEF";
u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
u_int8_t tmp[IN6ADDRSZ], *tp, *endp, *colonp;
const char *xdigits, *curtok;
int ch, saw_xdigit;
u_int val;
u_int32_t val;
memset((tp = tmp), 0, IN6ADDRSZ);
endp = tp + IN6ADDRSZ;
@@ -3075,8 +3074,8 @@ inet_pton6 (const char *src, u_char *dst)
}
if (tp + INT16SZ > endp)
return (0);
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
*tp++ = (u_int8_t) (val >> 8) & 0xff;
*tp++ = (u_int8_t) val & 0xff;
saw_xdigit = 0;
val = 0;
continue;
@@ -3093,8 +3092,8 @@ inet_pton6 (const char *src, u_char *dst)
{
if (tp + INT16SZ > endp)
return (0);
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
*tp++ = (u_int8_t) (val >> 8) & 0xff;
*tp++ = (u_int8_t) val & 0xff;
}
if (colonp != NULL)
{
@@ -3136,9 +3135,9 @@ cygwin_inet_pton (int af, const char *src, void *dst)
switch (af)
{
case AF_INET:
return (inet_pton4(src, (u_char *) dst));
return (inet_pton4(src, (u_int8_t *) dst));
case AF_INET6:
return (inet_pton6(src, (u_char *) dst));
return (inet_pton6(src, (u_int8_t *) dst));
default:
errno = EAFNOSUPPORT;
return (-1);
@@ -3153,12 +3152,12 @@ cygwin_inet_pton (int af, const char *src, void *dst)
* `dst' (as a const)
* notes:
* (1) uses no statics
* (2) takes a u_char* not an in_addr as input
* (2) takes a u_int8_t* not an in_addr as input
* author:
* Paul Vixie, 1996.
*/
static const char *
inet_ntop4 (const u_char *src, char *dst, size_t size)
inet_ntop4 (const u_int8_t *src, char *dst, size_t size)
{
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
@@ -3180,7 +3179,7 @@ inet_ntop4 (const u_char *src, char *dst, size_t size)
* Paul Vixie, 1996.
*/
static const char *
inet_ntop6 (const u_char *src, char *dst, size_t size)
inet_ntop6 (const u_int8_t *src, char *dst, size_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
@@ -3191,7 +3190,7 @@ inet_ntop6 (const u_char *src, char *dst, size_t size)
*/
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
struct { int base, len; } best, cur;
u_int words[IN6ADDRSZ / INT16SZ];
u_int32_t words[IN6ADDRSZ / INT16SZ];
int i;
/*
@@ -3297,9 +3296,9 @@ cygwin_inet_ntop (int af, const void *src, char *dst, socklen_t size)
switch (af)
{
case AF_INET:
return (inet_ntop4((const u_char *) src, dst, size));
return (inet_ntop4((const u_int8_t *) src, dst, size));
case AF_INET6:
return (inet_ntop6((const u_char *) src, dst, size));
return (inet_ntop6((const u_int8_t *) src, dst, size));
default:
errno = EAFNOSUPPORT;
return (NULL);