This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] winsup/cygwin/times.cc (times): follow Linux and allow for a NULL buf argument
- From: Ken Brown <kbrown at cornell dot edu>
- To: "cygwin-patches at cygwin dot com" <cygwin-patches at cygwin dot com>
- Date: Sun, 15 Sep 2019 17:17:26 +0000
- Subject: Re: [PATCH] winsup/cygwin/times.cc (times): follow Linux and allow for a NULL buf argument
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l0gDBGhoc6TNN0SUk0u/OClBh1ajsfO23JBj+ghfmOI=; b=ZEV7O8fwtrirj/kInz7qgLmJgWg8QlBYY2cKNXO9Ax8jEibJdFnxw28qctGzg9eGKpnKAUguJVn76y1ScSpm+j/U/B1zJ7dFvE+RmiLq6PQIerlB//w80TMw5M0t1xUrw2/kjUi0gW9tXkBvWHE7RqXV9Xgaj1TTPDQZ9exni2vge/T3Ryiyw3+dxTRmRxfRHnEKmvEMOmtGwUXYhsYMMZlvMxaopznBEG98Rb47u7e31hgvsezR80nHZBWs9sCD2epgGGO02+u128t/kasf94yw1yBtiCCrSBekmVgwtQ5DbfNYX1x9Zr7rY/TKtAbx6meTcYB8S8CetlI1t1RG3w==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OLvOkEWxYNNLcJDCrPgjlfNAWWOH/w5vhSEsgDX+AqAHN1TmZQV3BPGaMxsJHulthhfloDmKVDQyPRhnkJKLe+6+mKOQO7l4AbyCj+9eRQymyAeUo98YI4e3DrZ5nEoiyvIq0CTKRc/5usbNS/nv5osABvadjXCe79NbDeZXKt1ASVXanTZEBJDFwPLCVTcW4rKh6sr01w6ajwBNTRvHM/Fk7JbT9hPxuNpfK1jI5fyelTmzqEAc0wP8x9bmGPj5f0eFnPXeDUGMx6TWlT9mjlP8IfQypNkdDtjTnMj93GhDxDF7yJjvqJ1BhgN3vUwHjy2gijj63Ye+nwhVvTIhxA==
- References: <87pnk17cd6.fsf@Rainer.invalid>
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 (&kut.KernelTime, 0);
> - buf->tms_utime = __to_clock_t (&kut.UserTime, 0);
> - timeval_to_filetime (&myself->rusage_children.ru_stime, &kut.KernelTime);
> - buf->tms_cstime = __to_clock_t (&kut.KernelTime, 1);
> - timeval_to_filetime (&myself->rusage_children.ru_utime, &kut.UserTime);
> - buf->tms_cutime = __to_clock_t (&kut.UserTime, 1);
> + /* Linux allows a NULL buf and just returns tc in that case, so
> + mimic that */
> + if (buf)
> + {
> + buf->tms_stime = __to_clock_t (&kut.KernelTime, 0);
> + buf->tms_utime = __to_clock_t (&kut.UserTime, 0);
> + timeval_to_filetime (&myself->rusage_children.ru_stime, &kut.KernelTime);
> + buf->tms_cstime = __to_clock_t (&kut.KernelTime, 1);
> + timeval_to_filetime (&myself->rusage_children.ru_utime, &kut.UserTime);
> + buf->tms_cutime = __to_clock_t (&kut.UserTime, 1);
> + }
> }
> __except (EFAULT)
> {
Pushed, with a slight tweak to the commit message. Thanks.
Ken