Nullability check for sched module.

Bugs: b/245972273
Test: adb shell
Change-Id: Icb8028ec5864370c0ebfb300f9b6df01edf2742d
This commit is contained in:
zijunzhao 2023-03-18 00:38:14 +00:00 committed by Zijun Zhao
parent 9dfcaa64e8
commit 2146303272
2 changed files with 13 additions and 10 deletions

View file

@ -104,7 +104,7 @@ struct sched_param {
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int sched_setscheduler(pid_t __pid, int __policy, const struct sched_param* __param);
int sched_setscheduler(pid_t __pid, int __policy, const struct sched_param* _Nonnull __param);
/**
* [sched_getscheduler(2)](http://man7.org/linux/man-pages/man2/sched_getcpu.2.html)
@ -145,7 +145,7 @@ int sched_get_priority_min(int __policy);
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int sched_setparam(pid_t __pid, const struct sched_param* __param);
int sched_setparam(pid_t __pid, const struct sched_param* _Nonnull __param);
/**
* [sched_getparam(2)](http://man7.org/linux/man-pages/man2/sched_getparam.2.html)
@ -153,7 +153,7 @@ int sched_setparam(pid_t __pid, const struct sched_param* __param);
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int sched_getparam(pid_t __pid, struct sched_param* __param);
int sched_getparam(pid_t __pid, struct sched_param* _Nonnull __param);
/**
* [sched_rr_get_interval(2)](http://man7.org/linux/man-pages/man2/sched_rr_get_interval.2.html)
@ -161,7 +161,7 @@ int sched_getparam(pid_t __pid, struct sched_param* __param);
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int sched_rr_get_interval(pid_t __pid, struct timespec* __quantum);
int sched_rr_get_interval(pid_t __pid, struct timespec* _Nonnull __quantum);
#if defined(__USE_GNU)
@ -172,7 +172,7 @@ int sched_rr_get_interval(pid_t __pid, struct timespec* __quantum);
* Returns the pid of the child to the caller on success and
* returns -1 and sets `errno` on failure.
*/
int clone(int (*__fn)(void*), void* __child_stack, int __flags, void* __arg, ...) __INTRODUCED_IN_ARM(9) __INTRODUCED_IN_X86(17);
int clone(int (* __BIONIC_COMPLICATED_NULLNESS __fn)(void* __BIONIC_COMPLICATED_NULLNESS ), void* __BIONIC_COMPLICATED_NULLNESS __child_stack, int __flags, void* _Nullable __arg, ...) __INTRODUCED_IN_ARM(9) __INTRODUCED_IN_X86(17);
/**
* [unshare(2)](http://man7.org/linux/man-pages/man2/unshare.2.html)
@ -228,7 +228,7 @@ typedef struct {
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int sched_setaffinity(pid_t __pid, size_t __set_size, const cpu_set_t* __set);
int sched_setaffinity(pid_t __pid, size_t __set_size, const cpu_set_t* _Nonnull __set);
/**
* [sched_getaffinity(2)](http://man7.org/linux/man-pages/man2/sched_getaffinity.2.html)
@ -236,7 +236,7 @@ int sched_setaffinity(pid_t __pid, size_t __set_size, const cpu_set_t* __set);
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
*/
int sched_getaffinity(pid_t __pid, size_t __set_size, cpu_set_t* __set);
int sched_getaffinity(pid_t __pid, size_t __set_size, cpu_set_t* _Nonnull __set);
/**
* [CPU_ZERO](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) clears all
@ -308,7 +308,7 @@ int sched_getaffinity(pid_t __pid, size_t __set_size, cpu_set_t* __set);
* how many bits are set in a dynamic CPU set allocated by `CPU_ALLOC`.
*/
#define CPU_COUNT_S(setsize, set) __sched_cpucount((setsize), (set))
int __sched_cpucount(size_t __set_size, const cpu_set_t* __set);
int __sched_cpucount(size_t __set_size, const cpu_set_t* _Nonnull __set);
/**
* [CPU_EQUAL](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) tests
@ -379,14 +379,14 @@ int __sched_cpucount(size_t __set_size, const cpu_set_t* __set);
* allocates a CPU set large enough for CPUs in the range 0..count-1.
*/
#define CPU_ALLOC(count) __sched_cpualloc((count))
cpu_set_t* __sched_cpualloc(size_t __count);
cpu_set_t* _Nullable __sched_cpualloc(size_t __count);
/**
* [CPU_FREE](https://man7.org/linux/man-pages/man3/CPU_SET.3.html)
* deallocates a CPU set allocated by `CPU_ALLOC`.
*/
#define CPU_FREE(set) __sched_cpufree((set))
void __sched_cpufree(cpu_set_t* __set);
void __sched_cpufree(cpu_set_t* _Nonnull __set);
#endif /* __USE_GNU */

View file

@ -303,5 +303,8 @@ TEST(sched, sched_getscheduler_sched_setscheduler) {
}
TEST(sched, sched_getaffinity_failure) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
ASSERT_EQ(-1, sched_getaffinity(getpid(), 0, nullptr));
#pragma clang diagnostic pop
}