2022-05-02 Paul Eggert <eggert@cs.ucla.edu>
+ gettime-res: help the compiler
+ * lib/gettime-res.c (gettime_res): Pacify GCC versions that
+ incorrectly complain about earlier.tv_sec not being initialized.
+ Let GCC know that gcd args are always positive.
+
af_alg: port to Ubuntu 22.04
Without this patch, maintainer builds of coreutils fail on Ubuntu
22.04 with diagnostics like "./lib/gl_openssl.h:79:1: error:
/* On all Gnulib platforms the following calculations do not overflow. */
long int hz = TIMESPEC_HZ;
- long int r = hz * res.tv_sec + res.tv_nsec;
- struct timespec earlier;
- earlier.tv_nsec = -1;
+ long int r = res.tv_nsec <= 0 ? hz : res.tv_nsec;
+ struct timespec earlier = { .tv_nsec = -1 };
/* On some platforms, clock_getres (CLOCK_REALTIME, ...) yields a
too-large resolution, under the mistaken theory that it should
return the timer interval. For example, on AIX 7.2 POWER8
- clock_getres yields 10 ms even though clock_gettime yields 1 µs
+ clock_getres yields 10 ms even though clock_gettime yields 1 μs
resolution. Work around the problem with high probability by
trying clock_gettime several times and observing the resulting
bounds on resolution. */
}
earlier = now;
- r = gcd (r, now.tv_nsec ? now.tv_nsec : hz);
+ if (0 < now.tv_nsec)
+ r = gcd (r, now.tv_nsec);
}
return r;