Merge "Nullability check for mman module." am: b72900c5c9 am: ebd33d5977

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

Change-Id: I93552a62eabb0464233ff53937ce9d9e04f22f81
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Zijun Zhao 2023-05-19 01:02:15 +00:00 committed by Automerger Merge Worker
commit c5ce34172c
2 changed files with 18 additions and 15 deletions

View file

@ -50,9 +50,9 @@ __BEGIN_DECLS
* and returns `MAP_FAILED` and sets `errno` on failure.
*/
#if defined(__USE_FILE_OFFSET64)
void* mmap(void* __addr, size_t __size, int __prot, int __flags, int __fd, off_t __offset) __RENAME(mmap64);
void* _Nonnull mmap(void* _Nullable __addr, size_t __size, int __prot, int __flags, int __fd, off_t __offset) __RENAME(mmap64);
#else
void* mmap(void* __addr, size_t __size, int __prot, int __flags, int __fd, off_t __offset);
void* _Nonnull mmap(void* _Nullable __addr, size_t __size, int __prot, int __flags, int __fd, off_t __offset);
#endif
/**
@ -62,7 +62,7 @@ void* mmap(void* __addr, size_t __size, int __prot, int __flags, int __fd, off_t
*
* Available since API level 21.
*/
void* mmap64(void* __addr, size_t __size, int __prot, int __flags, int __fd, off64_t __offset) __INTRODUCED_IN(21);
void* _Nonnull mmap64(void* _Nullable __addr, size_t __size, int __prot, int __flags, int __fd, off64_t __offset) __INTRODUCED_IN(21);
/**
* [munmap(2)](http://man7.org/linux/man-pages/man2/munmap.2.html)
@ -70,7 +70,7 @@ void* mmap64(void* __addr, size_t __size, int __prot, int __flags, int __fd, off
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*/
int munmap(void* __addr, size_t __size);
int munmap(void* _Nonnull __addr, size_t __size);
/**
* [msync(2)](http://man7.org/linux/man-pages/man2/msync.2.html)
@ -78,7 +78,7 @@ int munmap(void* __addr, size_t __size);
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*/
int msync(void* __addr, size_t __size, int __flags);
int msync(void* _Nonnull __addr, size_t __size, int __flags);
/**
* [mprotect(2)](http://man7.org/linux/man-pages/man2/mprotect.2.html)
@ -86,7 +86,7 @@ int msync(void* __addr, size_t __size, int __flags);
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*/
int mprotect(void* __addr, size_t __size, int __prot);
int mprotect(void* _Nonnull __addr, size_t __size, int __prot);
/** Flag for mremap(). */
#define MREMAP_MAYMOVE 1
@ -101,7 +101,7 @@ int mprotect(void* __addr, size_t __size, int __prot);
* Returns the address of the mapping on success,
* and returns `MAP_FAILED` and sets `errno` on failure.
*/
void* mremap(void* __old_addr, size_t __old_size, size_t __new_size, int __flags, ...);
void* _Nonnull mremap(void* _Nonnull __old_addr, size_t __old_size, size_t __new_size, int __flags, ...);
/**
* [mlockall(2)](http://man7.org/linux/man-pages/man2/mlockall.2.html)
@ -129,7 +129,7 @@ int munlockall(void) __INTRODUCED_IN(17);
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*/
int mlock(const void* __addr, size_t __size);
int mlock(const void* _Nonnull __addr, size_t __size);
/**
* [mlock2(2)](http://man7.org/linux/man-pages/man2/mlock.2.html)
@ -139,7 +139,7 @@ int mlock(const void* __addr, size_t __size);
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*/
int mlock2(const void* __addr, size_t __size, int __flags) __INTRODUCED_IN(30);
int mlock2(const void* _Nonnull __addr, size_t __size, int __flags) __INTRODUCED_IN(30);
/**
* [munlock(2)](http://man7.org/linux/man-pages/man2/munlock.2.html)
@ -147,7 +147,7 @@ int mlock2(const void* __addr, size_t __size, int __flags) __INTRODUCED_IN(30);
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*/
int munlock(const void* __addr, size_t __size);
int munlock(const void* _Nonnull __addr, size_t __size);
/**
* [mincore(2)](http://man7.org/linux/man-pages/man2/mincore.2.html)
@ -155,7 +155,7 @@ int munlock(const void* __addr, size_t __size);
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*/
int mincore(void* __addr, size_t __size, unsigned char* __vector);
int mincore(void* _Nonnull __addr, size_t __size, unsigned char* _Nonnull __vector);
/**
* [madvise(2)](http://man7.org/linux/man-pages/man2/madvise.2.html)
@ -163,7 +163,7 @@ int mincore(void* __addr, size_t __size, unsigned char* __vector);
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*/
int madvise(void* __addr, size_t __size, int __advice);
int madvise(void* _Nonnull __addr, size_t __size, int __advice);
/**
* [process_madvise(2)](http://man7.org/linux/man-pages/man2/process_madvise.2.html)
@ -177,7 +177,7 @@ int madvise(void* __addr, size_t __size, int __advice);
*
* Returns the number of bytes advised on success, and returns -1 and sets `errno` on failure.
*/
ssize_t process_madvise(int __pid_fd, const struct iovec* __iov, size_t __count, int __advice, unsigned __flags) __INTRODUCED_IN(31);
ssize_t process_madvise(int __pid_fd, const struct iovec* _Nonnull __iov, size_t __count, int __advice, unsigned __flags) __INTRODUCED_IN(31);
#if defined(__USE_GNU)
@ -189,7 +189,7 @@ ssize_t process_madvise(int __pid_fd, const struct iovec* __iov, size_t __count,
*
* Returns an fd on success, and returns -1 and sets `errno` on failure.
*/
int memfd_create(const char* __name, unsigned __flags) __INTRODUCED_IN(30);
int memfd_create(const char* _Nonnull __name, unsigned __flags) __INTRODUCED_IN(30);
#endif
@ -226,6 +226,6 @@ int memfd_create(const char* __name, unsigned __flags) __INTRODUCED_IN(30);
*
* Returns 0 on success, and returns a positive error number on failure.
*/
int posix_madvise(void* __addr, size_t __size, int __advice) __INTRODUCED_IN(23);
int posix_madvise(void* _Nonnull __addr, size_t __size, int __advice) __INTRODUCED_IN(23);
__END_DECLS

View file

@ -218,7 +218,10 @@ TEST(sys_mman, posix_madvise_POSIX_MADV_DONTNEED) {
}
TEST(sys_mman, mremap) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
ASSERT_EQ(MAP_FAILED, mremap(nullptr, 0, 0, 0));
#pragma clang diagnostic pop
}
constexpr size_t kHuge = size_t(PTRDIFF_MAX) + 1;