-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
In addition to passing NULL as buffers (which asserts Haiku's inet_pton()), the inet_pton test uses arbitrary hardcoded values to test error reporting, which can and actually do collide with some other tested values.
For example, AF_INET6 is 5 on Haiku.
And do we really need to test two of those?
If you really want to test with some other value, we could try AF_MAX, although on BSD it doesn't seem to be always defined (_BSD_VISIBLE) and when it is it actually is one of the possible values.
How about max(AF_INET, AF_INET6)+1 ?
It still seems fragile though, as it can still be a valid and actually implemented address family.
Also note that not all systems actually support (and even define) AF_INET6. MiNT (not the GNU/Linux distro!) comes to mind (but it does define AF_APPLETALK).
I'd propose some fallbacks from the least known family, something like:
#if defined(AF_DECnet)
#define AF_BAD AF_DECnet
#elif defined(AF_CHAOS)
#define AF_BAD AF_CHAOS
#elif defined(AF_APPLETALK)
#define AF_BAD AF_APPLETALK
#elif defined(AF_MAX)
#define AF_BAD AF_MAX
#else
#define AF_BAD (max(AF_INET, AF_INET6)+1)
#endif