This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Time-HiRes: initialize the unslept timespec
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 3 Mar 2016 22:29:58 +0000 (17:29 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Fri, 4 Mar 2016 22:46:47 +0000 (17:46 -0500)
Found by clang scan-build.

dist/Time-HiRes/HiRes.xs

index 304bad3..1ec5e9f 100644 (file)
@@ -973,6 +973,8 @@ nanosleep(nsec)
            croak("Time::HiRes::nanosleep(%"NVgf"): negative time not invented yet", nsec);
        sleepfor.tv_sec = (Time_t)(nsec / 1e9);
        sleepfor.tv_nsec = (long)(nsec - ((NV)sleepfor.tv_sec) * 1e9);
+       unslept.tv_sec = 0;
+       unslept.tv_nsec = 0;
        if (!nanosleep(&sleepfor, &unslept)) {
            RETVAL = nsec;
        } else {
@@ -1374,6 +1376,8 @@ clock_nanosleep(clock_id, nsec, flags = 0)
            croak("Time::HiRes::clock_nanosleep(..., %"NVgf"): negative time not invented yet", nsec);
        sleepfor.tv_sec = (Time_t)(nsec / 1e9);
        sleepfor.tv_nsec = (long)(nsec - ((NV)sleepfor.tv_sec) * 1e9);
+       unslept.tv_sec = 0;
+       unslept.tv_nsec = 0;
        if (!clock_nanosleep(clock_id, flags, &sleepfor, &unslept)) {
            RETVAL = nsec;
        } else {