shared: make dns_packet_read_uint{8,32} accept NULL ret
The shared/ dns_packet_read_uint*() functions used to be a bit
inconsistent when it comes to the handling of NULL in *ret. The
helpers dns_packet_read_{uint16,name} accepted NULL but the
dns_packet_read_uint{8,32} did not.
This commit makes them all symmetric in accepting NULL.
This commit is contained in:
@@ -1468,13 +1468,14 @@ int dns_packet_read_uint8(DnsPacket *p, uint8_t *ret, size_t *start) {
|
||||
int r;
|
||||
|
||||
assert(p);
|
||||
assert(ret);
|
||||
|
||||
r = dns_packet_read(p, sizeof(uint8_t), &d, start);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = ((uint8_t*) d)[0];
|
||||
if (ret)
|
||||
*ret = ((uint8_t*) d)[0];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1499,13 +1500,13 @@ int dns_packet_read_uint32(DnsPacket *p, uint32_t *ret, size_t *start) {
|
||||
int r;
|
||||
|
||||
assert(p);
|
||||
assert(ret);
|
||||
|
||||
r = dns_packet_read(p, sizeof(uint32_t), &d, start);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = unaligned_read_be32(d);
|
||||
if (ret)
|
||||
*ret = unaligned_read_be32(d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user