mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 07:47:48 +00:00
LibC: inet_pton() should return 1 on success, 0 or -1 on failure.
This commit is contained in:
parent
d080f6e8dd
commit
d03505bc29
3 changed files with 7 additions and 3 deletions
|
@ -29,7 +29,7 @@ int inet_pton(int af, const char* src, void* dst)
|
|||
int count = sscanf(src, "%u.%u.%u.%u", &a, &b, &c, &d);
|
||||
if (count != 4) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
union {
|
||||
struct {
|
||||
|
@ -45,7 +45,7 @@ int inet_pton(int af, const char* src, void* dst)
|
|||
u.c = c;
|
||||
u.d = d;
|
||||
*(uint32_t*)dst = u.l;
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_addr_t inet_addr(const char* str)
|
||||
|
|
|
@ -38,7 +38,7 @@ int main(int argc, char** argv)
|
|||
dst_addr.sin_family = AF_INET;
|
||||
dst_addr.sin_port = htons(80);
|
||||
rc = inet_pton(AF_INET, addr_str, &dst_addr.sin_addr);
|
||||
if (rc < 0) {
|
||||
if (rc <= 0) {
|
||||
perror("inet_pton");
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,10 @@ int main(int argc, char** argv)
|
|||
dst_addr.sin_family = AF_INET;
|
||||
dst_addr.sin_port = htons(8080);
|
||||
rc = inet_pton(AF_INET, addr_str, &dst_addr.sin_addr);
|
||||
if (rc <= 0) {
|
||||
perror("inet_pton");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char buffer[BUFSIZ];
|
||||
const char* msg = "Test message";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue