From: Arran Cudbard-Bell Date: Thu, 16 Sep 2021 19:21:08 +0000 (-0500) Subject: Ensure we have more siblings than cores X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49bef63a6aae47c86c1fd9f3f56c5471b57f01fe;p=thirdparty%2Ffreeradius-server.git Ensure we have more siblings than cores --- 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); }