Merge "Nullability check for sem module." am: 727ebe08ca am: 4dd2749d3a am: 9bce3d5cab

Original change: https://android-review.googlesource.com/c/platform/bionic/+/2552372

Change-Id: I897f6083ba82b08a4f8b81007ecba1c56012fd36
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Zijun Zhao 2023-04-22 03:25:45 +00:00 committed by Automerger Merge Worker
commit ec08ccacdc
2 changed files with 12 additions and 6 deletions

View file

@ -45,18 +45,18 @@ __BEGIN_DECLS
union semun {
int val;
struct semid_ds* buf;
unsigned short* array;
struct seminfo* __buf;
void* __pad;
struct semid_ds* _Nullable buf;
unsigned short* _Nullable array;
struct seminfo* _Nullable __buf;
void* _Nullable __pad;
};
int semctl(int __sem_id, int __sem_num, int __cmd, ...) __INTRODUCED_IN(26);
int semget(key_t __key, int __sem_count, int __flags) __INTRODUCED_IN(26);
int semop(int __sem_id, struct sembuf* __ops, size_t __op_count) __INTRODUCED_IN(26);
int semop(int __sem_id, struct sembuf* _Nonnull __ops, size_t __op_count) __INTRODUCED_IN(26);
#if defined(__USE_GNU)
int semtimedop(int __sem_id, struct sembuf* __ops, size_t __op_count, const struct timespec* __timeout) __INTRODUCED_IN(26);
int semtimedop(int __sem_id, struct sembuf* _Nonnull __ops, size_t __op_count, const struct timespec* _Nullable __timeout) __INTRODUCED_IN(26);
#endif
__END_DECLS

View file

@ -87,15 +87,21 @@ TEST(sys_sem, semctl_failure) {
}
TEST(sys_sem, semop_failure) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
errno = 0;
ASSERT_EQ(-1, semop(-1, nullptr, 0));
ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
#pragma clang diagnostic pop
}
TEST(sys_sem, semtimedop_failure) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
errno = 0;
ASSERT_EQ(-1, semtimedop(-1, nullptr, 0, nullptr));
ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
#pragma clang diagnostic pop
}
TEST(sys_sem, union_semun) {