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:
Alejandro Colomar
2022-11-02 21:45:40 +01:00
parent 1b05161107
commit ebf02266a2
10 changed files with 23 additions and 27 deletions

View File

@@ -1637,7 +1637,7 @@ nxt_controller_process_cert(nxt_task_t *task,
name.length = path->length - 1;
name.start = path->start + 1;
p = nxt_memchr(name.start, '/', name.length);
p = memchr(name.start, '/', name.length);
if (p != NULL) {
name.length = p - name.start;