Module Name: src
Committed By: rtr
Date: Sun Apr 5 23:15:54 UTC 2015
Modified Files:
src/tests/lib/libc/sys: t_bind.c
Log Message:
- ATF_REQUIRE(EINVAL == errno);
+ ATF_REQUIRE(EAFNOSUPPORT == errno);
as per http://pubs.opengroup.org/onlinepubs/009695399/functions/bind.html
while here remove some unnecessary initialization of port and addr members
and replace with a comment explaining why.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_bind.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/lib/libc/sys/t_bind.c
diff -u src/tests/lib/libc/sys/t_bind.c:1.1 src/tests/lib/libc/sys/t_bind.c:1.2
--- src/tests/lib/libc/sys/t_bind.c:1.1 Sun Apr 5 06:36:52 2015
+++ src/tests/lib/libc/sys/t_bind.c Sun Apr 5 23:15:54 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: t_bind.c,v 1.1 2015/04/05 06:36:52 martin Exp $ */
+/* $NetBSD: t_bind.c,v 1.2 2015/04/05 23:15:54 rtr Exp $ */
/*
* Copyright (c) 2015 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -50,17 +50,21 @@ ATF_TC_BODY(bind_foreign_family, tc)
{
struct sockaddr_in addr;
+ /* addr.sin_family = AF_UNSPEC = 0 */
memset(&addr, 0, sizeof(addr));
- /* use a sin_family != the socket type */
- addr.sin_port = htons(8000);
- addr.sin_addr.s_addr = INADDR_ANY;
+
+ /*
+ * it is not necessary to initialize sin_{addr,port} since
+ * those structure members shall not be accessed if bind
+ * fails correctly.
+ */
int sock = socket(AF_LOCAL, SOCK_STREAM, 0);
ATF_REQUIRE(sock != -1);
/* should fail but currently doesn't */
ATF_REQUIRE(-1 == bind(sock, (struct sockaddr *)&addr, sizeof(addr)));
- ATF_REQUIRE(EINVAL == errno);
+ ATF_REQUIRE(EAFNOSUPPORT == errno);
close(sock);
}