inet_addr: return INADDR_NONE(-1) when input string is invalid

now:
inet_network("300.10.10.10"); return 0
inet_addr("300.10.10.10"); return 0

glibc and muscle both return INADDR_NONE or -1.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2023-05-05 21:52:24 +08:00 committed by Xiang Xiao
parent 6f8cb7edd3
commit d59a9ea189

View File

@ -88,7 +88,7 @@ in_addr_t inet_addr(FAR const char *cp)
unsigned int b;
unsigned int c;
unsigned int d;
uint32_t result = 0;
uint32_t result = INADDR_NONE;
switch (sscanf(cp, "%u.%u.%u.%u", &a, &b, &c, &d))
{