Removed the unsafe nxt_memchr() wrapper for memchr(3).
The casts are unnecessary, since memchr(3)'s argument is 'const void *'. It might have been necessary in the times of K&R, where 'void *' didn't exist. Nowadays, it's unnecessary, and _very_ unsafe, since casts can hide all classes of bugs by silencing most compiler warnings. The changes from nxt_memchr() to memchr(3) were scripted: $ find src/ -type f \ | grep '\.[ch]$' \ | xargs sed -i 's/nxt_memchr/memchr/' Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Signed-off-by: Alejandro Colomar <alx@nginx.com>
This commit is contained in:
@@ -653,7 +653,7 @@ nxt_sockaddr_inet6_parse(nxt_mp_t *mp, nxt_str_t *addr)
|
||||
length = addr->length - 1;
|
||||
start = addr->start + 1;
|
||||
|
||||
end = nxt_memchr(start, ']', length);
|
||||
end = memchr(start, ']', length);
|
||||
if (nxt_slow_path(end == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -723,7 +723,7 @@ nxt_sockaddr_inet_parse(nxt_mp_t *mp, nxt_str_t *addr)
|
||||
in_addr_t inaddr;
|
||||
nxt_sockaddr_t *sa;
|
||||
|
||||
p = nxt_memchr(addr->start, ':', addr->length);
|
||||
p = memchr(addr->start, ':', addr->length);
|
||||
|
||||
if (p == NULL) {
|
||||
length = addr->length;
|
||||
@@ -964,11 +964,11 @@ nxt_inet6_probe(nxt_str_t *str)
|
||||
{
|
||||
u_char *colon, *end;
|
||||
|
||||
colon = nxt_memchr(str->start, ':', str->length);
|
||||
colon = memchr(str->start, ':', str->length);
|
||||
|
||||
if (colon != NULL) {
|
||||
end = str->start + str->length;
|
||||
colon = nxt_memchr(colon + 1, ':', end - (colon + 1));
|
||||
colon = memchr(colon + 1, ':', end - (colon + 1));
|
||||
}
|
||||
|
||||
return (colon != NULL);
|
||||
|
||||
Reference in New Issue
Block a user