linux/lib/math
David Laight 08092babd3 lib: mul_u64_u64_div_u64(): combine overflow and divide by zero checks
Since the overflow check always triggers when the divisor is zero
move the check for divide by zero inside the overflow check.
This means there is only one test in the normal path.

Link: https://lkml.kernel.org/r/20251105201035.64043-3-david.laight.linux@gmail.com
Signed-off-by: David Laight <david.laight.linux@gmail.com>
Reviewed-by: Nicolas Pitre <npitre@baylibre.com>
Cc: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Borislav Betkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Li RongQing <lirongqing@baidu.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleinxer <tglx@linutronix.de>
Cc: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-11-20 14:03:41 -08:00
..
tests lib/prime_numbers: convert self-test to KUnit 2025-02-12 14:00:11 -08:00
cordic.c lib: Move mathematic helpers to separate folder 2019-05-14 19:52:49 -07:00
div64.c lib: mul_u64_u64_div_u64(): combine overflow and divide by zero checks 2025-11-20 14:03:41 -08:00
gcd.c lib/math/gcd: use static key to select implementation at runtime 2025-07-19 19:08:28 -07:00
int_log.c lib/math/int_log: Replace LGPL-2.1-or-later boilerplate with SPDX identifier 2023-07-09 22:47:50 +01:00
int_pow.c kernel.h: split out mathematical helpers 2020-12-15 22:46:15 -08:00
int_sqrt.c kernel.h: split out mathematical helpers 2020-12-15 22:46:15 -08:00
Kconfig math: make RATIONAL tristate 2021-09-08 11:50:26 -07:00
lcm.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
Makefile lib: math: Move KUnit tests into tests/ subdir 2025-02-10 18:24:57 -08:00
prime_numbers.c lib/prime_numbers: convert self-test to KUnit 2025-02-12 14:00:11 -08:00
prime_numbers_private.h lib/prime_numbers: convert self-test to KUnit 2025-02-12 14:00:11 -08:00
rational.c math: rational: add missing MODULE_DESCRIPTION() macro 2024-07-04 23:43:11 -07:00
reciprocal_div.c kernel.h: split out mathematical helpers 2020-12-15 22:46:15 -08:00
test_div64.c lib/math/test_div64: add some edge cases relevant to __div64_const32() 2024-10-28 21:44:28 +00:00
test_mul_u64_u64_div_u64.c mul_u64_u64_div_u64: basic sanity test 2024-09-01 20:43:22 -07:00