Nullability check for inet module.
Bugs: b/245972273
Test: adb shell
Change-Id: I5acb1910f25dc025e1c8924ebf8b6801503f5161
diff --git a/libc/include/arpa/inet.h b/libc/include/arpa/inet.h
index db054c9..748b7a1 100644
--- a/libc/include/arpa/inet.h
+++ b/libc/include/arpa/inet.h
@@ -36,17 +36,17 @@
__BEGIN_DECLS
-in_addr_t inet_addr(const char* __s);
-int inet_aton(const char* __s, struct in_addr* __addr);
+in_addr_t inet_addr(const char* _Nonnull __s);
+int inet_aton(const char* _Nonnull __s, struct in_addr* _Nullable __addr);
in_addr_t inet_lnaof(struct in_addr __addr) __INTRODUCED_IN(21);
struct in_addr inet_makeaddr(in_addr_t __net, in_addr_t __host) __INTRODUCED_IN(21);
in_addr_t inet_netof(struct in_addr __addr) __INTRODUCED_IN(21);
-in_addr_t inet_network(const char* __s) __INTRODUCED_IN(21);
-char* inet_ntoa(struct in_addr __addr);
-const char* inet_ntop(int __af, const void* __src, char* __dst, socklen_t __size);
-unsigned int inet_nsap_addr(const char* __ascii, unsigned char* __binary, int __n);
-char* inet_nsap_ntoa(int __binary_length, const unsigned char* __binary, char* __ascii);
-int inet_pton(int __af, const char* __src, void* __dst);
+in_addr_t inet_network(const char* _Nonnull __s) __INTRODUCED_IN(21);
+char* _Nonnull inet_ntoa(struct in_addr __addr);
+const char* _Nullable inet_ntop(int __af, const void* _Nonnull __src, char* _Nonnull __dst, socklen_t __size);
+unsigned int inet_nsap_addr(const char* _Nonnull __ascii, unsigned char* _Nonnull __binary, int __n);
+char* _Nonnull inet_nsap_ntoa(int __binary_length, const unsigned char* _Nonnull __binary, char* _Nullable __ascii);
+int inet_pton(int __af, const char* _Nonnull __src, void* _Nonnull __dst);
__END_DECLS
diff --git a/libc/include/netdb.h b/libc/include/netdb.h
index 7afdc1a..88214d5 100644
--- a/libc/include/netdb.h
+++ b/libc/include/netdb.h
@@ -78,32 +78,34 @@
* supplied in host order, and returned in network order (suitable for
* use in system calls).
*/
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnullability-completeness"
struct hostent {
- char * _Nullable h_name; /* official name of host */
- char * _Nullable * _Nullable h_aliases; /* alias list */
+ char *h_name; /* official name of host */
+ char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
- char * _Nullable * _Nullable h_addr_list; /* list of addresses from name server */
+ char **h_addr_list; /* list of addresses from name server */
#define h_addr h_addr_list[0] /* address, for backward compatibility */
};
struct netent {
- char * _Nullable n_name; /* official name of net */
- char * _Nullable * _Nullable n_aliases; /* alias list */
+ char *n_name; /* official name of net */
+ char **n_aliases; /* alias list */
int n_addrtype; /* net address type */
uint32_t n_net; /* network # */
};
struct servent {
- char * _Nullable s_name; /* official service name */
- char * _Nullable * _Nullable s_aliases; /* alias list */
+ char *s_name; /* official service name */
+ char **s_aliases; /* alias list */
int s_port; /* port # */
char * _Nullable s_proto; /* protocol to use */
};
struct protoent {
- char * _Nullable p_name; /* official protocol name */
- char * _Nullable * _Nullable p_aliases; /* alias list */
+ char *p_name; /* official protocol name */
+ char **p_aliases; /* alias list */
int p_proto; /* protocol # */
};
@@ -113,10 +115,11 @@
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
socklen_t ai_addrlen; /* length of ai_addr */
- char * _Nullable ai_canonname; /* canonical name for hostname */
- struct sockaddr * _Nullable ai_addr; /* binary address */
- struct addrinfo * _Nullable ai_next; /* next structure in linked list */
+ char *ai_canonname; /* canonical name for hostname */
+ struct sockaddr *ai_addr; /* binary address */
+ struct addrinfo *ai_next; /* next structure in linked list */
};
+#pragma clang diagnostic pop
/*
* Error return codes from gethostbyname() and gethostbyaddr()