Merge "Nullability check for time module." am: b167b90b4c
am: 68364d0074
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2580375 Change-Id: Ib40792ce001c407f8aff63556173a8ab15a26f5d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
0ddab67369
5 changed files with 26 additions and 25 deletions
|
@ -38,21 +38,34 @@
|
|||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int gettimeofday(struct timeval* __tv, struct timezone* __tz);
|
||||
int settimeofday(const struct timeval* __tv, const struct timezone* __tz);
|
||||
int gettimeofday(struct timeval* _Nullable __tv, struct timezone* _Nullable __tz);
|
||||
int settimeofday(const struct timeval* _Nullable __tv, const struct timezone* _Nullable __tz);
|
||||
|
||||
int getitimer(int __which, struct itimerval* __current_value);
|
||||
int setitimer(int __which, const struct itimerval* __new_value, struct itimerval* __old_value);
|
||||
int getitimer(int __which, struct itimerval* _Nonnull __current_value);
|
||||
int setitimer(int __which, const struct itimerval* _Nonnull __new_value, struct itimerval* _Nullable __old_value);
|
||||
|
||||
int utimes(const char* __path, const struct timeval __times[2]);
|
||||
int utimes(const char* _Nonnull __path, const struct timeval __times[_Nullable 2]);
|
||||
|
||||
#if defined(__USE_BSD)
|
||||
int futimes(int __fd, const struct timeval __times[2]) __INTRODUCED_IN(26);
|
||||
int lutimes(const char* __path, const struct timeval __times[2]) __INTRODUCED_IN(26);
|
||||
int futimes(int __fd, const struct timeval __times[_Nullable 2]) __INTRODUCED_IN(26);
|
||||
int lutimes(const char* _Nonnull __path, const struct timeval __times[_Nullable 2]) __INTRODUCED_IN(26);
|
||||
#endif
|
||||
|
||||
#if defined(__USE_GNU)
|
||||
int futimesat(int __dir_fd, const char* __path, const struct timeval __times[2]) __INTRODUCED_IN(26);
|
||||
/**
|
||||
* [futimesat(2)](https://man7.org/linux/man-pages/man2/futimesat.2.html) sets
|
||||
* file timestamps.
|
||||
*
|
||||
* Note: Linux supports `__path` being NULL (in which case `__dir_fd` need not
|
||||
* be a directory), allowing futimensat() to be implemented with utimensat().
|
||||
* Most callers should just use utimensat() directly, especially on Android
|
||||
* where utimensat() has been available for longer than futimesat().
|
||||
*
|
||||
* Returns 0 on success and -1 and sets `errno` on failure.
|
||||
*
|
||||
* Available since API level 26.
|
||||
*/
|
||||
int futimesat(int __dir_fd, const char* __BIONIC_COMPLICATED_NULLNESS __path, const struct timeval __times[_Nullable 2]) __INTRODUCED_IN(26);
|
||||
#endif
|
||||
|
||||
#define timerclear(a) \
|
||||
|
|
|
@ -68,7 +68,7 @@ int timerfd_create(clockid_t __clock, int __flags) __INTRODUCED_IN(19);
|
|||
*
|
||||
* Available since API level 19.
|
||||
*/
|
||||
int timerfd_settime(int __fd, int __flags, const struct itimerspec* __new_value, struct itimerspec* __old_value) __INTRODUCED_IN(19);
|
||||
int timerfd_settime(int __fd, int __flags, const struct itimerspec* _Nonnull __new_value, struct itimerspec* _Nullable __old_value) __INTRODUCED_IN(19);
|
||||
|
||||
/**
|
||||
* [timerfd_gettime(2)](http://man7.org/linux/man-pages/man2/timerfd_gettime.2.html) queries the
|
||||
|
@ -78,6 +78,6 @@ int timerfd_settime(int __fd, int __flags, const struct itimerspec* __new_value,
|
|||
*
|
||||
* Available since API level 19.
|
||||
*/
|
||||
int timerfd_gettime(int __fd, struct itimerspec* __current_value) __INTRODUCED_IN(19);
|
||||
int timerfd_gettime(int __fd, struct itimerspec* _Nonnull __current_value) __INTRODUCED_IN(19);
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -46,6 +46,6 @@ __BEGIN_DECLS
|
|||
* Returns a (possibly overflowed) absolute time on success,
|
||||
* and returns -1 and sets `errno` on failure.
|
||||
*/
|
||||
clock_t times(struct tms* __buf);
|
||||
clock_t times(struct tms* _Nullable __buf);
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -46,7 +46,7 @@ __BEGIN_DECLS
|
|||
*
|
||||
* Available since API level 24.
|
||||
*/
|
||||
int adjtimex(struct timex* __buf) __INTRODUCED_IN(24);
|
||||
int adjtimex(struct timex* _Nonnull __buf) __INTRODUCED_IN(24);
|
||||
|
||||
/**
|
||||
* clock_adjtime adjusts a specific kernel clock.
|
||||
|
@ -55,6 +55,6 @@ int adjtimex(struct timex* __buf) __INTRODUCED_IN(24);
|
|||
*
|
||||
* Available since API level 24.
|
||||
*/
|
||||
int clock_adjtime(clockid_t __clock, struct timex* __tx) __INTRODUCED_IN(24);
|
||||
int clock_adjtime(clockid_t __clock, struct timex* _Nonnull __tx) __INTRODUCED_IN(24);
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -27,21 +27,9 @@ TEST(sys_timex, adjtimex_smoke) {
|
|||
ASSERT_NE(-1, adjtimex(&t));
|
||||
}
|
||||
|
||||
TEST(sys_timex, adjtimex_EFAULT) {
|
||||
errno = 0;
|
||||
ASSERT_EQ(-1, adjtimex(nullptr));
|
||||
ASSERT_EQ(EFAULT, errno);
|
||||
}
|
||||
|
||||
TEST(sys_timex, clock_adjtime_smoke) {
|
||||
timex t;
|
||||
memset(&t, 0, sizeof(t));
|
||||
// adjtimex/clock_adjtime return the clock state on success, -1 on failure.
|
||||
ASSERT_NE(-1, clock_adjtime(CLOCK_REALTIME, &t));
|
||||
}
|
||||
|
||||
TEST(sys_timex, clock_adjtime_EFAULT) {
|
||||
errno = 0;
|
||||
ASSERT_EQ(-1, clock_adjtime(CLOCK_REALTIME, nullptr));
|
||||
ASSERT_EQ(EFAULT, errno);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue