Nullability check for system_properties module.
Bug: b/245972273
Test: adb shell
Change-Id: I3a55b8107898014fe74fd1a6f442f1ec00e08790
diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h
index 744a45b..943d4c6 100644
--- a/libc/include/sys/_system_properties.h
+++ b/libc/include/sys/_system_properties.h
@@ -61,7 +61,7 @@
** This was previously for testing, but now that SystemProperties is its own testable class,
** there is never a reason to call this function and its implementation simply returns -1.
*/
-int __system_property_set_filename(const char* __filename);
+int __system_property_set_filename(const char* __unused __filename);
/*
** Initialize the area to be used to store properties. Can
@@ -102,7 +102,7 @@
**
** Returns 0 on success, -1 if the property area is full.
*/
-int __system_property_add(const char* __name, unsigned int __name_length, const char* __value, unsigned int __value_length);
+int __system_property_add(const char* _Nonnull __name, unsigned int __name_length, const char* _Nonnull __value, unsigned int __value_length);
/* Update the value of a system property returned by
** __system_property_find. Can only be done by a single process
@@ -112,14 +112,14 @@
**
** Returns 0 on success, -1 if the parameters are incorrect.
*/
-int __system_property_update(prop_info* __pi, const char* __value, unsigned int __value_length);
+int __system_property_update(prop_info* _Nonnull __pi, const char* _Nonnull __value, unsigned int __value_length);
/* Read the serial number of a system property returned by
** __system_property_find.
**
** Returns the serial number on success, -1 on error.
*/
-uint32_t __system_property_serial(const prop_info* __pi);
+uint32_t __system_property_serial(const prop_info* _Nonnull __pi);
/* Initialize the system properties area in read only mode.
* Should be done by all processes that need to read system
diff --git a/libc/include/sys/system_properties.h b/libc/include/sys/system_properties.h
index a2e1923..06b2188 100644
--- a/libc/include/sys/system_properties.h
+++ b/libc/include/sys/system_properties.h
@@ -43,7 +43,7 @@
/*
* Sets system property `name` to `value`, creating the system property if it doesn't already exist.
*/
-int __system_property_set(const char* __name, const char* __value);
+int __system_property_set(const char* _Nonnull __name, const char* _Nonnull __value);
/*
* Returns a `prop_info` corresponding system property `name`, or nullptr if it doesn't exist.
@@ -51,14 +51,14 @@
*
* Property lookup is expensive, so it can be useful to cache the result of this function.
*/
-const prop_info* __system_property_find(const char* __name);
+const prop_info* _Nullable __system_property_find(const char* _Nonnull __name);
/*
* Calls `callback` with a consistent trio of name, value, and serial number for property `pi`.
*/
-void __system_property_read_callback(const prop_info* __pi,
- void (*__callback)(void* __cookie, const char* __name, const char* __value, uint32_t __serial),
- void* __cookie) __INTRODUCED_IN(26);
+void __system_property_read_callback(const prop_info* _Nonnull __pi,
+ void (* _Nonnull __callback)(void* _Nullable __cookie, const char* _Nonnull __name, const char* _Nonnull __value, uint32_t __serial),
+ void* _Nullable __cookie) __INTRODUCED_IN(26);
/*
* Passes a `prop_info` for each system property to the provided
@@ -66,13 +66,13 @@
*
* This method is for inspecting and debugging the property system, and not generally useful.
*/
-int __system_property_foreach(void (*__callback)(const prop_info* __pi, void* __cookie), void* __cookie)
+int __system_property_foreach(void (* _Nonnull __callback)(const prop_info* _Nonnull __pi, void* _Nullable __cookie), void* _Nullable __cookie)
__INTRODUCED_IN(19);
/*
* Waits for the specific system property identified by `pi` to be updated
* past `old_serial`. Waits no longer than `relative_timeout`, or forever
- * if `relaive_timeout` is null.
+ * if `relative_timeout` is null.
*
* If `pi` is null, waits for the global serial number instead.
*
@@ -82,17 +82,17 @@
* timed out.
*/
struct timespec;
-bool __system_property_wait(const prop_info* __pi, uint32_t __old_serial, uint32_t* __new_serial_ptr, const struct timespec* __relative_timeout)
+bool __system_property_wait(const prop_info* _Nullable __pi, uint32_t __old_serial, uint32_t* _Nonnull __new_serial_ptr, const struct timespec* _Nullable __relative_timeout)
__INTRODUCED_IN(26);
/* Deprecated. In Android O and above, there's no limit on property name length. */
#define PROP_NAME_MAX 32
/* Deprecated. Use __system_property_read_callback instead. */
-int __system_property_read(const prop_info* __pi, char* __name, char* __value);
+int __system_property_read(const prop_info* _Nonnull __pi, char* _Nullable __name, char* _Nonnull __value);
/* Deprecated. Use __system_property_read_callback instead. */
-int __system_property_get(const char* __name, char* __value);
+int __system_property_get(const char* _Nonnull __name, char* _Nonnull __value);
/* Deprecated. Use __system_property_foreach instead. */
-const prop_info* __system_property_find_nth(unsigned __n);
+const prop_info* _Nullable __system_property_find_nth(unsigned __n);
__END_DECLS