Good catch - this is a Linux-specific behavior (not part of Posix) which we
indeed forgot to handle.
Thanks for the patch!

I just have a few stylistic requests below:

On Tue, Mar 9, 2021 at 9:11 PM 'Shawn Barber' via OSv Development <
osv-dev@googlegroups.com> wrote:

> Signed-off by: Shawn M Barber <shawn.bar...@dornerworks.com>
> ---
>  runtime.cc | 19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/runtime.cc b/runtime.cc
> index 78710504..ad5bb07f 100644
> --- a/runtime.cc
> +++ b/runtime.cc
> @@ -435,6 +435,7 @@ clock_t times(struct tms *buffer)
>  {
>      using namespace std::chrono;
>      struct timespec ts;
> +    clock_t         ret_val = 0;
>

There is no need for this variable, and certainly not in assigning it a
value. Below you have exactly
two cases - if and else, and each one returns a value. So it can just
"return" the value it wants to
return. There is no reason to insist that there only be one return
statement in the function.


>      clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
>
> @@ -442,12 +443,20 @@ clock_t times(struct tms *buffer)
>      clockseconds time;
>      time = duration_cast<clockseconds>(seconds(ts.tv_sec) +
> nanoseconds(ts.tv_nsec));
>
> -    buffer->tms_utime = time.count();
> -    buffer->tms_stime = 0;
> -    buffer->tms_cutime = 0;
> -    buffer->tms_cstime = 0;
> +    if (NULL != buffer)
> +    {
>

As you can see in CODINGSTYLE.md and of course throughout the code, our
coding style is that
the brace comes on the same line as the if, not in a separate line:

  if (NULL != buffer) {

or even simpler,

 if (buffer) {


> +        buffer->tms_utime = time.count();
> +        buffer->tms_stime = 0;
> +        buffer->tms_cutime = 0;
> +        buffer->tms_cstime = 0;
> +        ret_val = buffer->tms_utime;
> +    }
> +    else
> +    {
>

Again, the coding style is the last three lines on one line:

   } else {

+        ret_val = time.count();
> +    }
>
> -    return buffer->tms_utime;
> +    return ret_val;
>  }
>
>  static int prio_find_thread(sched::thread **th, int which, int id)
> --
> 2.17.1
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to osv-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/osv-dev/20210309190801.19821-1-shawn.barber%40dornerworks.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CANEVyjvBUm_J4BxqvfkO5fV1gX7%2Bc%3D4FMkcKGXyeu%3DTgf_i-tQ%40mail.gmail.com.

Reply via email to