Skip to content
Commit ea61c8c1 authored by Keith Packard's avatar Keith Packard Committed by Johan Hedberg
Browse files

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: default avatarKeith Packard <keithp@keithp.com>
parent f2af4a7b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment