zephyr/include
Keith Packard ea61c8c1bd 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>
2023-10-06 20:05:07 +03:00
..
zephyr sys/time_units.h: Work around clang div-by-zero warning 2023-10-06 20:05:07 +03:00