sys/time_units.h: Work around clang div-by-zero warning
clang emits a warning for this code:
foo.c:1:25: warning: division by zero is undefined [-Wdivision-by-zero]
int i = (10 > 100 ? (20 / (10 / 100)) : (20 * (100 / 10)));
^ ~~~~~~~~~~
The warning is generated for code whose value does not affect the
expression result, but technically it is still 'undefined behavior'.
Work around this warning by checking for a zero divisor and substituting
one to make the compiler happy.
Signed-off-by:
Keith Packard <keithp@keithp.com>
Loading
Please sign in to comment