瀏覽代碼

opensock: work correctly on IPv6-only config

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko 15 年之前
父節點
當前提交
be6b7aa339
共有 1 個文件被更改,包括 9 次插入9 次删除
  1. 9 9
      libc/inet/opensock.c

+ 9 - 9
libc/inet/opensock.c

@@ -25,19 +25,19 @@
 #include <features.h>
 #include <features.h>
 #include <libc-internal.h>
 #include <libc-internal.h>
 
 
-/* libc_hidden_proto(socket) */
-
 /* Return a socket of any type.  The socket can be used in subsequent
 /* Return a socket of any type.  The socket can be used in subsequent
    ioctl calls to talk to the kernel.  */
    ioctl calls to talk to the kernel.  */
 int __opensock(void) attribute_hidden;
 int __opensock(void) attribute_hidden;
 int
 int
-__opensock (void)
+__opensock(void)
 {
 {
-  int fd;
+	int fd = -1;
 #ifdef __UCLIBC_HAS_IPV6__
 #ifdef __UCLIBC_HAS_IPV6__
-  fd = socket(AF_INET6, SOCK_DGRAM, 0);
+	fd = socket(AF_INET6, SOCK_DGRAM, 0);
-  if (fd<0)
+#endif
-#endif /* __UCLIBC_HAS_IPV6__ */
+#ifdef __UCLIBC_HAS_IPV4__
-    fd = socket(AF_INET, SOCK_DGRAM, 0);
+	if (fd < 0)
-  return(fd);
+		fd = socket(AF_INET, SOCK_DGRAM, 0);
+#endif
+	return fd;
 }
 }