[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH v3 3/3] lib/uktime: Fix checkpath errors for timegm
We fix the checkpath errors of the imported files. We omit the "function definition argument * should also have an identifier name" warnings since the functions are commented out. Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx> --- lib/uktime/musl-imported/include/time.h | 56 +++++++++---------- .../musl-imported/src/__month_to_secs.c | 4 +- lib/uktime/musl-imported/src/__secs_to_tm.c | 4 +- lib/uktime/musl-imported/src/__tm_to_secs.c | 3 + lib/uktime/musl-imported/src/__year_to_secs.c | 22 +++++--- lib/uktime/musl-imported/src/timegm.c | 1 + 6 files changed, 52 insertions(+), 38 deletions(-) diff --git a/lib/uktime/musl-imported/include/time.h b/lib/uktime/musl-imported/include/time.h index a77926c1..b34b0f30 100644 --- a/lib/uktime/musl-imported/include/time.h +++ b/lib/uktime/musl-imported/include/time.h @@ -54,15 +54,15 @@ struct tm { }; #if 0 -clock_t clock (void); -time_t time (time_t *); -double difftime (time_t, time_t); -time_t mktime (struct tm *); -size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict); -struct tm *gmtime (const time_t *); -struct tm *localtime (const time_t *); -char *asctime (const struct tm *); -char *ctime (const time_t *); +clock_t clock(void); +time_t time(time_t *); +double difftime(time_t, time_t); +time_t mktime(struct tm *); +size_t strftime(char *__restrict, size_t, const char *__restrict, const struct tm *__restrict); +struct tm *gmtime(const time_t *); +struct tm *localtime(const time_t *); +char *asctime(const struct tm *); +char *ctime(const time_t *); int timespec_get(struct timespec *, int); #endif @@ -75,14 +75,14 @@ int timespec_get(struct timespec *, int); || defined(_BSD_SOURCE) #if 0 -size_t strftime_l (char * __restrict, size_t, const char * __restrict, const struct tm * __restrict, locale_t); +size_t strftime_l(char *__restrict, size_t, const char *__restrict, const struct tm *__restrict, locale_t); -struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict); -struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict); -char *asctime_r (const struct tm *__restrict, char *__restrict); -char *ctime_r (const time_t *, char *); +struct tm *gmtime_r(const time_t *__restrict, struct tm *__restrict); +struct tm *localtime_r(const time_t *__restrict, struct tm *__restrict); +char *asctime_r(const struct tm *__restrict, char *__restrict); +char *ctime_r(const time_t *, char *); -void tzset (void); +void tzset(void); #endif struct itimerspec { @@ -105,22 +105,22 @@ struct itimerspec { #define TIMER_ABSTIME 1 -int nanosleep (const struct timespec *, struct timespec *); +int nanosleep(const struct timespec *, struct timespec *); #if 0 -int clock_getres (clockid_t, struct timespec *); +int clock_getres(clockid_t, struct timespec *); #endif -int clock_gettime (clockid_t, struct timespec *); +int clock_gettime(clockid_t, struct timespec *); #if 0 -int clock_settime (clockid_t, const struct timespec *); -int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *); -int clock_getcpuclockid (pid_t, clockid_t *); +int clock_settime(clockid_t, const struct timespec *); +int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *); +int clock_getcpuclockid(pid_t, clockid_t *); struct sigevent; -int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict); -int timer_delete (timer_t); -int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict); -int timer_gettime (timer_t, struct itimerspec *); -int timer_getoverrun (timer_t); +int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict); +int timer_delete(timer_t); +int timer_settime(timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict); +int timer_gettime(timer_t, struct itimerspec *); +int timer_getoverrun(timer_t); extern char *tzname[2]; #endif @@ -128,11 +128,11 @@ extern char *tzname[2]; #if 0 #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE) -char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict); +char *strptime(const char *__restrict, const char *__restrict, struct tm *__restrict); extern int daylight; extern long timezone; extern int getdate_err; -struct tm *getdate (const char *); +struct tm *getdate(const char *); #endif #endif diff --git a/lib/uktime/musl-imported/src/__month_to_secs.c b/lib/uktime/musl-imported/src/__month_to_secs.c index 43248fb3..c3ae57f3 100644 --- a/lib/uktime/musl-imported/src/__month_to_secs.c +++ b/lib/uktime/musl-imported/src/__month_to_secs.c @@ -5,6 +5,8 @@ int __month_to_secs(int month, int is_leap) 120*86400, 151*86400, 181*86400, 212*86400, 243*86400, 273*86400, 304*86400, 334*86400 }; int t = secs_through_month[month]; - if (is_leap && month >= 2) t+=86400; + + if (is_leap && month >= 2) + t += 86400; return t; } diff --git a/lib/uktime/musl-imported/src/__secs_to_tm.c b/lib/uktime/musl-imported/src/__secs_to_tm.c index 093d9021..4a9f53a3 100644 --- a/lib/uktime/musl-imported/src/__secs_to_tm.c +++ b/lib/uktime/musl-imported/src/__secs_to_tm.c @@ -15,7 +15,7 @@ int __secs_to_tm(long long t, struct tm *tm) int qc_cycles, c_cycles, q_cycles; int months; int wday, yday, leap; - static const char days_in_month[] = {31,30,31,30,31,31,30,31,30,31,31,29}; + static const char days_in_month[] = {31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29}; /* Reject time_t values whose year would overflow int */ if (t < INT_MIN * 31622400LL || t > INT_MAX * 31622400LL) @@ -57,7 +57,7 @@ int __secs_to_tm(long long t, struct tm *tm) years = remyears + 4*q_cycles + 100*c_cycles + 400LL*qc_cycles; - for (months=0; days_in_month[months] <= remdays; months++) + for (months = 0; days_in_month[months] <= remdays; months++) remdays -= days_in_month[months]; if (months >= 10) { diff --git a/lib/uktime/musl-imported/src/__tm_to_secs.c b/lib/uktime/musl-imported/src/__tm_to_secs.c index c29fa985..aaf7d13c 100644 --- a/lib/uktime/musl-imported/src/__tm_to_secs.c +++ b/lib/uktime/musl-imported/src/__tm_to_secs.c @@ -5,8 +5,10 @@ long long __tm_to_secs(const struct tm *tm) int is_leap; long long year = tm->tm_year; int month = tm->tm_mon; + if (month >= 12 || month < 0) { int adj = month / 12; + month %= 12; if (month < 0) { adj--; @@ -15,6 +17,7 @@ long long __tm_to_secs(const struct tm *tm) year += adj; } long long t = __year_to_secs(year, &is_leap); + t += __month_to_secs(month, is_leap); t += 86400LL * (tm->tm_mday-1); t += 3600LL * tm->tm_hour; diff --git a/lib/uktime/musl-imported/src/__year_to_secs.c b/lib/uktime/musl-imported/src/__year_to_secs.c index 2824ec6d..16d71c55 100644 --- a/lib/uktime/musl-imported/src/__year_to_secs.c +++ b/lib/uktime/musl-imported/src/__year_to_secs.c @@ -3,16 +3,20 @@ long long __year_to_secs(long long year, int *is_leap) if (year-2ULL <= 136) { int y = year; int leaps = (y-68)>>2; + if (!((y-68)&3)) { leaps--; - if (is_leap) *is_leap = 1; - } else if (is_leap) *is_leap = 0; + if (is_leap) + *is_leap = 1; + } else if (is_leap) + *is_leap = 0; return 31536000*(y-70) + 86400*leaps; } int cycles, centuries, leaps, rem; - if (!is_leap) is_leap = &(int){0}; + if (!is_leap) + is_leap = &(int){0}; cycles = (year-100) / 400; rem = (year-100) % 400; if (rem < 0) { @@ -25,11 +29,15 @@ long long __year_to_secs(long long year, int *is_leap) leaps = 0; } else { if (rem >= 200) { - if (rem >= 300) centuries = 3, rem -= 300; - else centuries = 2, rem -= 200; + if (rem >= 300) + centuries = 3, rem -= 300; + else + centuries = 2, rem -= 200; } else { - if (rem >= 100) centuries = 1, rem -= 100; - else centuries = 0; + if (rem >= 100) + centuries = 1, rem -= 100; + else + centuries = 0; } if (!rem) { *is_leap = 0; diff --git a/lib/uktime/musl-imported/src/timegm.c b/lib/uktime/musl-imported/src/timegm.c index 80e2506d..bde40b90 100644 --- a/lib/uktime/musl-imported/src/timegm.c +++ b/lib/uktime/musl-imported/src/timegm.c @@ -8,6 +8,7 @@ time_t timegm(struct tm *tm) { struct tm new; long long t = __tm_to_secs(tm); + if (__secs_to_tm(t, &new) < 0) { errno = EOVERFLOW; return -1; -- 2.20.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |