Re: [PATCH] winsup/cygwin/times.cc (times): follow Linux and allow for a NULL buf argument

2019-09-15 Thread Ken Brown
On 9/15/2019 12:28 PM, Achim Gratz wrote:
> 
> Adresses a problem reported on the Cygwin list.
> 
> ---
>   winsup/cygwin/times.cc | 17 +++--
>   1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
> index 8908d44f1..909cae1f1 100644
> --- a/winsup/cygwin/times.cc
> +++ b/winsup/cygwin/times.cc
> @@ -72,12 +72,17 @@ times (struct tms *buf)
> /* ticks is in in 100ns, convert to clock ticks. */
> tc = (clock_t) (ticks.QuadPart * CLOCKS_PER_SEC / NS100PERSEC);
>   
> -  buf->tms_stime = __to_clock_t (, 0);
> -  buf->tms_utime = __to_clock_t (, 0);
> -  timeval_to_filetime (>rusage_children.ru_stime, 
> );
> -  buf->tms_cstime = __to_clock_t (, 1);
> -  timeval_to_filetime (>rusage_children.ru_utime, );
> -  buf->tms_cutime = __to_clock_t (, 1);
> +  /* Linux allows a NULL buf and just returns tc in that case, so
> +  mimic that */
> +  if (buf)
> + {
> +   buf->tms_stime = __to_clock_t (, 0);
> +   buf->tms_utime = __to_clock_t (, 0);
> +   timeval_to_filetime (>rusage_children.ru_stime, 
> );
> +   buf->tms_cstime = __to_clock_t (, 1);
> +   timeval_to_filetime (>rusage_children.ru_utime, 
> );
> +   buf->tms_cutime = __to_clock_t (, 1);
> + }
>   }
> __except (EFAULT)
>   {

Pushed, with a slight tweak to the commit message.  Thanks.

Ken


[PATCH] winsup/cygwin/times.cc (times): follow Linux and allow for a NULL buf argument

2019-09-15 Thread Achim Gratz


Adresses a problem reported on the Cygwin list.

---
 winsup/cygwin/times.cc | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 8908d44f1..909cae1f1 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -72,12 +72,17 @@ times (struct tms *buf)
   /* ticks is in in 100ns, convert to clock ticks. */
   tc = (clock_t) (ticks.QuadPart * CLOCKS_PER_SEC / NS100PERSEC);
 
-  buf->tms_stime = __to_clock_t (, 0);
-  buf->tms_utime = __to_clock_t (, 0);
-  timeval_to_filetime (>rusage_children.ru_stime, );
-  buf->tms_cstime = __to_clock_t (, 1);
-  timeval_to_filetime (>rusage_children.ru_utime, );
-  buf->tms_cutime = __to_clock_t (, 1);
+  /* Linux allows a NULL buf and just returns tc in that case, so
+mimic that */
+  if (buf)
+   {
+ buf->tms_stime = __to_clock_t (, 0);
+ buf->tms_utime = __to_clock_t (, 0);
+ timeval_to_filetime (>rusage_children.ru_stime, 
);
+ buf->tms_cstime = __to_clock_t (, 1);
+ timeval_to_filetime (>rusage_children.ru_utime, 
);
+ buf->tms_cutime = __to_clock_t (, 1);
+   }
 }
   __except (EFAULT)
 {
-- 
2.23.0


Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf rackAttack V1.04R1:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada