]> git.ipfire.org Git - thirdparty/glibc.git/commit
nss: remove undefined behavior and optimize getaddrinfo
authorCollin Funk <collin.funk1@gmail.com>
Mon, 5 May 2025 02:31:34 +0000 (19:31 -0700)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 6 May 2025 16:31:59 +0000 (13:31 -0300)
commitb4495bd40578b455668887b9170059bb0d3c0dc5
treedc21dc2c26d88b579ef66e27abe88aa4fe268ee6
parentac4e8382899ccf4ada1cd2f1dafdcdf40d31ec7d
nss: remove undefined behavior and optimize getaddrinfo

On x86-64 and compiling with -O2 using stdc_leading_zeros compiles to
the bsr instruction.  The fls function removed by this patch is inlined
but still loops while checking each bit individually.

* nss/getaddrinfo.c: Include <stdbit.h>.
(fls): Remove function.  This function contains a left shift of 31 on an
'int' which is undefined.
(rfc3484_sort): Use stdc_leading_zeros instead of fls.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
nss/getaddrinfo.c