[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH v3 3/3] lib/uktime: Fix checkpath errors for timegm


  • To: Vlad-Andrei BĂDOIU (78692) <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>, "minios-devel@xxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxx>
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Thu, 12 Sep 2019 14:53:47 +0300
  • Delivery-date: Thu, 12 Sep 2019 11:53:54 +0000
  • Ironport-phdr: 9a23:TSop2B1buiG+Zle+smDT+DRfVm0co7zxezQtwd8ZsesWK/jxwZ3uMQTl6Ol3ixeRBMOHsqkC07ed7/uoGTRZp8rY6jZaKN0EfiRGoP1epxYnDs+BBB+zB9/RRAt+Iv5/UkR49WqwK0lfFZW2TVTTpnqv8WxaQU2nZkJ6KevvB4Hdkdm82fys9J3PeQVIgye2ba9vIBmsogjdq8cbjZF+JqsxxRfErXVFcPlSyW90OF6fhRnx6tqu8JJ57yhcp/ct/NNcXKvneKg1UaZWByk8PWAv483ruxjDTQ+R6XYZT24bjBlGDRXb4R/jRpv+vTf0ueR72CmBIM35Vqs0Vii476dqUxDnliEKPCMk/W7Ni8xwiKVboA+9pxF63oXZbp2ZOOZ4c6jAZt4RW3ZPUdhNWCxAGoO8bpUAD+wdPeZDsoLxo0ICoQaiCQWwAe/izCJDiH3r0q0gy+kvDB/I3AIgEdwNvnrbotr6O6UOXu6616TI0SzDYulK1Tvh5oXFcBYsquyMU7JqdsrRzFEiGh3CjlWLtYzlPjWV3fkLvWiG9+pgSP+khmk7pAF2uTiv2sYsio/TioIR11DE7Th5zZ0pKt2jUkJ7ecOkH4BKuyGAMIt7W8UvSHxrtiYi0rAKpJG2cDUQxJkkxxPTceKLf5aK7x75WuudOSp0iXFmdb6lmRq/8VKsxvPzW8S0ylpHoS5In9/RvX4XzRPT8NKISv5l80ek3jaAyh7c5/lfIUAxiarbM5khwqMslpYLsUTMACv2mELuga+Ic0Ur4Omo6+D9brr6vZ+QLZd0ihzlPag0gMy/Bvw0MgkIX2eF5eSxzKDv8ELkTLlQjfA7krPVvI7EKckZvKK0DRdZ0oM55Ba+Czem3s4YnX4CLF9dZB2HiJPpO03PIPD+F/u/h0mskC92x/3dIrLhGY/BLmDekLj6Z7p98UlcxBIpzd9D/5JUFq0BIPXrV0/0tdzYCB45Mwuvw+r+FdpyyJ0eVnyLAqKCNKPSsESI5v40I+WWa44apjD9J+Ii5/70gn8zgUUdcrWx3ZsLdHC4GexrI1udYXX2n9gOCX0FvgwjQ+zwllKCUCRfaG2oUK0h4TE7CZ+mAJzYRoCxnbyOwT23EYdKaWBdEFyMDG/oeJ6eV/cWbyLBavNmxwIAXLTkYoktzxyvgyVR551GE92UpX1G5MiinIxr4+Tfohg0+SZ5DoKX2m2KTnxchX8VS3k/17s5vFR3jE2Eh+wwyflZE91U/LZFXxk3MbbYzvdmEJbiVwSHec2GAh7yR9SgADYqC9483dIKS0J8AMm5yADO2WytGbBDxJKRA5lh2aXHw3n3b+Jg02uOgKImlEUnRI1LKHW7rqVksRDODcjTlBPKxO6Raa0A0XuVpy+4xm2UsRQdCVYoXA==
  • Ironport-sdr: Jek528K4fdYULfvhnpvq6694b5aaA+k+iIAWYcPyYBqxpPb71Pyj0/yp3vfTKTdNZlLHBDAaNx vME6UlTPX4pQ==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

Thanks for the patch, Vlad!

Reviewed-by: Costin Lupu <costin.lupu@xxxxxxxxx>

On 9/12/19 2:31 PM, Vlad-Andrei BĂDOIU (78692) wrote:
> 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;
> 

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.