From 49bef63a6aae47c86c1fd9f3f56c5471b57f01fe Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Thu, 16 Sep 2021 14:21:08 -0500 Subject: [PATCH] Ensure we have more siblings than cores --- src/lib/util/hw.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/util/hw.c b/src/lib/util/hw.c index 8a8e3cb636..dcc87e4d5f 100644 --- a/src/lib/util/hw.c +++ b/src/lib/util/hw.c @@ -90,10 +90,20 @@ uint32_t fr_hw_num_cores_active(void) fclose(cpu); } +#ifdef __clang_analyzer__ /* * Prevent clang scanner from warning about divide by zero */ - if ((tsibs == 0) || (lcores == 0)) return 1; + if ((tsibs / lcores) == 0) return 1; +#neidf + + /* + * Catch Linux weirdness. + * + * You'd think this'd be enough to quite clang scan, + * but it's not. + */ + if (unlikely((tsibs == 0) || (lcores == 0) || (lcores > tsibs))) return 1; return lcores / (tsibs / lcores); } -- 2.47.2