1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-11 03:55:03 -05:00

Fix compiler warning

This commit is contained in:
Yang Tse 2009-10-09 14:06:38 +00:00
parent a5ba25a5f6
commit f1aa936d2c
2 changed files with 8 additions and 7 deletions

View File

@ -46,7 +46,7 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
while (1) while (1)
{ {
if (!fgets(*buf + offset, *bufsize - offset, fp)) if (!fgets(*buf + offset, (int)(*bufsize - offset), fp))
return (offset != 0) ? 0 : (ferror(fp)) ? ARES_EFILE : ARES_EOF; return (offset != 0) ? 0 : (ferror(fp)) ? ARES_EFILE : ARES_EOF;
len = offset + strlen(*buf + offset); len = offset + strlen(*buf + offset);
if ((*buf)[len - 1] == '\n') if ((*buf)[len - 1] == '\n')

View File

@ -81,7 +81,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
if (ch == '0' && (src[0] == 'x' || src[0] == 'X') if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
&& ISXDIGIT(src[1])) { && ISXDIGIT(src[1])) {
/* Hexadecimal: Eat nybble string. */ /* Hexadecimal: Eat nybble string. */
if (size <= 0U) if (!size)
goto emsgsize; goto emsgsize;
dirty = 0; dirty = 0;
src++; /* skip x or X. */ src++; /* skip x or X. */
@ -94,14 +94,14 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
else else
tmp = (tmp << 4) | n; tmp = (tmp << 4) | n;
if (++dirty == 2) { if (++dirty == 2) {
if (size-- <= 0U) if (!size--)
goto emsgsize; goto emsgsize;
*dst++ = (unsigned char) tmp; *dst++ = (unsigned char) tmp;
dirty = 0; dirty = 0;
} }
} }
if (dirty) { /* Odd trailing nybble? */ if (dirty) { /* Odd trailing nybble? */
if (size-- <= 0U) if (!size--)
goto emsgsize; goto emsgsize;
*dst++ = (unsigned char) (tmp << 4); *dst++ = (unsigned char) (tmp << 4);
} }
@ -117,7 +117,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
goto enoent; goto enoent;
} while ((ch = *src++) != '\0' && } while ((ch = *src++) != '\0' &&
ISDIGIT(ch)); ISDIGIT(ch));
if (size-- <= 0U) if (!size--)
goto emsgsize; goto emsgsize;
*dst++ = (unsigned char) tmp; *dst++ = (unsigned char) tmp;
if (ch == '\0' || ch == '/') if (ch == '\0' || ch == '/')
@ -179,7 +179,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
} }
/* Extend network to cover the actual mask. */ /* Extend network to cover the actual mask. */
while (bits > ((dst - odst) * 8)) { while (bits > ((dst - odst) * 8)) {
if (size-- <= 0U) if (!size--)
goto emsgsize; goto emsgsize;
*dst++ = '\0'; *dst++ = '\0';
} }
@ -426,7 +426,8 @@ ares_inet_net_pton(int af, const char *src, void *dst, size_t size)
#ifndef HAVE_INET_PTON #ifndef HAVE_INET_PTON
int ares_inet_pton(int af, const char *src, void *dst) int ares_inet_pton(int af, const char *src, void *dst)
{ {
int size, result; int result;
size_t size;
if (af == AF_INET) if (af == AF_INET)
size = sizeof(struct in_addr); size = sizeof(struct in_addr);