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

fix compiler warning: dereferencing type-punned pointer will break strict-aliasing rules

This commit is contained in:
Yang Tse 2008-09-30 17:04:05 +00:00
parent aed98c5125
commit 2c086105b1

View File

@ -460,13 +460,16 @@ static const unsigned char *display_rr(const unsigned char *aptr,
const unsigned char *abuf, int alen) const unsigned char *abuf, int alen)
{ {
const unsigned char *p; const unsigned char *p;
char *name;
int type, dnsclass, ttl, dlen, status; int type, dnsclass, ttl, dlen, status;
long len; long len;
char addr[46]; char addr[46];
union {
unsigned char * as_uchar;
char * as_char;
} name;
/* Parse the RR name. */ /* Parse the RR name. */
status = ares_expand_name(aptr, abuf, alen, &name, &len); status = ares_expand_name(aptr, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
aptr += len; aptr += len;
@ -476,7 +479,7 @@ static const unsigned char *display_rr(const unsigned char *aptr,
*/ */
if (aptr + RRFIXEDSZ > abuf + alen) if (aptr + RRFIXEDSZ > abuf + alen)
{ {
ares_free_string(name); ares_free_string(name.as_char);
return NULL; return NULL;
} }
@ -489,16 +492,16 @@ static const unsigned char *display_rr(const unsigned char *aptr,
aptr += RRFIXEDSZ; aptr += RRFIXEDSZ;
if (aptr + dlen > abuf + alen) if (aptr + dlen > abuf + alen)
{ {
ares_free_string(name); ares_free_string(name.as_char);
return NULL; return NULL;
} }
/* Display the RR name, class, and type. */ /* Display the RR name, class, and type. */
printf("\t%-15s.\t%d", name, ttl); printf("\t%-15s.\t%d", name.as_char, ttl);
if (dnsclass != C_IN) if (dnsclass != C_IN)
printf("\t%s", class_name(dnsclass)); printf("\t%s", class_name(dnsclass));
printf("\t%s", type_name(type)); printf("\t%s", type_name(type));
ares_free_string(name); ares_free_string(name.as_char);
/* Display the RR data. Don't touch aptr. */ /* Display the RR data. Don't touch aptr. */
switch (type) switch (type)
@ -512,11 +515,11 @@ static const unsigned char *display_rr(const unsigned char *aptr,
case T_NS: case T_NS:
case T_PTR: case T_PTR:
/* For these types, the RR data is just a domain name. */ /* For these types, the RR data is just a domain name. */
status = ares_expand_name(aptr, abuf, alen, &name, &len); status = ares_expand_name(aptr, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
printf("\t%s.", name); printf("\t%s.", name.as_char);
ares_free_string(name); ares_free_string(name.as_char);
break; break;
case T_HINFO: case T_HINFO:
@ -536,17 +539,17 @@ static const unsigned char *display_rr(const unsigned char *aptr,
case T_MINFO: case T_MINFO:
/* The RR data is two domain names. */ /* The RR data is two domain names. */
p = aptr; p = aptr;
status = ares_expand_name(p, abuf, alen, &name, &len); status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
printf("\t%s.", name); printf("\t%s.", name.as_char);
ares_free_string(name); ares_free_string(name.as_char);
p += len; p += len;
status = ares_expand_name(p, abuf, alen, &name, &len); status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
printf("\t%s.", name); printf("\t%s.", name.as_char);
ares_free_string(name); ares_free_string(name.as_char);
break; break;
case T_MX: case T_MX:
@ -556,11 +559,11 @@ static const unsigned char *display_rr(const unsigned char *aptr,
if (dlen < 2) if (dlen < 2)
return NULL; return NULL;
printf("\t%d", DNS__16BIT(aptr)); printf("\t%d", DNS__16BIT(aptr));
status = ares_expand_name(aptr + 2, abuf, alen, &name, &len); status = ares_expand_name(aptr + 2, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
printf("\t%s.", name); printf("\t%s.", name.as_char);
ares_free_string(name); ares_free_string(name.as_char);
break; break;
case T_SOA: case T_SOA:
@ -568,17 +571,17 @@ static const unsigned char *display_rr(const unsigned char *aptr,
* numbers giving the serial number and some timeouts. * numbers giving the serial number and some timeouts.
*/ */
p = aptr; p = aptr;
status = ares_expand_name(p, abuf, alen, &name, &len); status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
printf("\t%s.\n", name); printf("\t%s.\n", name.as_char);
ares_free_string(name); ares_free_string(name.as_char);
p += len; p += len;
status = ares_expand_name(p, abuf, alen, &name, &len); status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
printf("\t\t\t\t\t\t%s.\n", name); printf("\t\t\t\t\t\t%s.\n", name.as_char);
ares_free_string(name); ares_free_string(name.as_char);
p += len; p += len;
if (p + 20 > aptr + dlen) if (p + 20 > aptr + dlen)
return NULL; return NULL;
@ -629,11 +632,11 @@ static const unsigned char *display_rr(const unsigned char *aptr,
printf(" %d", DNS__16BIT(aptr + 2)); printf(" %d", DNS__16BIT(aptr + 2));
printf(" %d", DNS__16BIT(aptr + 4)); printf(" %d", DNS__16BIT(aptr + 4));
status = ares_expand_name(aptr + 6, abuf, alen, &name, &len); status = ares_expand_name(aptr + 6, abuf, alen, &name.as_char, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
printf("\t%s.", name); printf("\t%s.", name.as_char);
ares_free_string(name); ares_free_string(name.as_char);
break; break;
case T_NAPTR: case T_NAPTR:
@ -642,32 +645,32 @@ static const unsigned char *display_rr(const unsigned char *aptr,
printf(" %d\n", DNS__16BIT(aptr + 2)); /* preference */ printf(" %d\n", DNS__16BIT(aptr + 2)); /* preference */
p = aptr + 4; p = aptr + 4;
status = ares_expand_string(p, abuf, alen, (unsigned char **)&name, &len); status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
printf("\t\t\t\t\t\t%s\n", name); printf("\t\t\t\t\t\t%s\n", name.as_char);
ares_free_string(name); ares_free_string(name.as_char);
p += len; p += len;
status = ares_expand_string(p, abuf, alen, (unsigned char **)&name, &len); status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
printf("\t\t\t\t\t\t%s\n", name); printf("\t\t\t\t\t\t%s\n", name.as_char);
ares_free_string(name); ares_free_string(name.as_char);
p += len; p += len;
status = ares_expand_string(p, abuf, alen, (unsigned char **)&name, &len); status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
printf("\t\t\t\t\t\t%s\n", name); printf("\t\t\t\t\t\t%s\n", name.as_char);
ares_free_string(name); ares_free_string(name.as_char);
p += len; p += len;
status = ares_expand_string(p, abuf, alen, (unsigned char **)&name, &len); status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
if (status != ARES_SUCCESS) if (status != ARES_SUCCESS)
return NULL; return NULL;
printf("\t\t\t\t\t\t%s", name); printf("\t\t\t\t\t\t%s", name.as_char);
ares_free_string(name); ares_free_string(name.as_char);
break; break;