Rationale for inet_ntop(3) using socklen_t instead of size_t
Alejandro Colomar
alx.manpages@gmail.com
Thu Dec 22 12:21:08 GMT 2022
Hi Jakub,
inet_ntop(3):
SYNOPSIS
#include <arpa/inet.h>
const char *inet_ntop(int af, const void *restrict src,
char dst[restrict .size], socklen_t size);
STANDARDS
POSIX.1‐2001, POSIX.1‐2008. Note that RFC 2553 defines a prototype
where the last argument size is of type size_t. Many systems follow
RFC 2553. Glibc 2.0 and 2.1 have size_t, but 2.2 and later have
socklen_t.
Glibc did the change here (with no rationale):
commit a1303dc8dc57dbcd4605992dc177d11ae4d45aab
Author: Ulrich Drepper <drepper@redhat.com>
Date: Thu Apr 6 05:04:50 2000 +0000
Update.
2000-04-05 Cristian Gafton <gafton@redhat.com>
* ctype/ctype.h (__isctype_l): Define even if not __OPTIMIZE__
because it is used in generic code.
* wctype/wctrans.c: Define __ctype32_toupper and __ctype32_tolower.
* wcsmbs/wcwidth.h: Declare __ctype32_b.
* intl/gettext.c: Include <locale.h>.
* intl/ngettext.c: Likewise.
2000-04-05 Jakub Jelinek <jakub@redhat.com>
* resolv/inet_ntop.c (inet_ntop4, inet_ntop6, inet_ntop): Use
socklen_t type for size.
* sysdeps/sparc/sparc32/dl-machine.h (RTLD_START): Rewrite for new
init function interface.
* sysdeps/sparc/sparc64/dl-machine.h (RTLD_START): Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/setjmp.h: Don't include
sys/ucontext.h.
(__jmp_buf): Declare the whole type structure here, don't use
ucontext.
* iconv/skeleton.c (put16u): Fix typo.
Reported by Bruno Haible <haible@ilog.fr>.
That's a year before POSIX.1-2001. I'd like to understand why was this change
done. Especially, considering that socklen_t for a string and in this context
is *very* confusing. I guess this is due to historic design mistakes, and
compatibility with other systems that had it wrong? Maybe obscure POSIX
standards prior to 2001 required socklen_t already?
Thanks,
Alex
P.S.: AFAIK, I can't search in the glibc mailing list history; something I can
do in the lore.kernel.org list archives. Is it correct? Or maybe I just don't
know how? <https://sourceware.org/pipermail/libc-alpha/>
--
<http://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20221222/829e2cb9/attachment.sig>
More information about the Libc-alpha
mailing list