From: Otto Moerbeek Date: Mon, 28 Mar 2022 08:50:52 +0000 (+0200) Subject: Teach scanbuild that two divisions are safe: one by adding an assert, one by using... X-Git-Tag: rec-4.7.0-beta1~31^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e617ff1a1daaf7146e5d0f03ab0ab71f3e7e5f8;p=thirdparty%2Fpdns.git Teach scanbuild that two divisions are safe: one by adding an assert, one by using a *const* table --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index c696a76703..4dd6bcb73b 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -2406,6 +2406,7 @@ static unsigned int getWorkerLoad(size_t workerIdx) static unsigned int selectWorker(unsigned int hash) { + assert(RecThreadInfo::numWorkers() != 0); if (g_balancingFactor == 0) { return RecThreadInfo::numHandlers() + RecThreadInfo::numDistributors() + (hash % RecThreadInfo::numWorkers()); } diff --git a/pdns/sillyrecords.cc b/pdns/sillyrecords.cc index d1319a1a42..5e4623a007 100644 --- a/pdns/sillyrecords.cc +++ b/pdns/sillyrecords.cc @@ -13,8 +13,8 @@ #include #include "dnsrecords.hh" -static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000, - 1000000,10000000,100000000,1000000000}; +const static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000, + 1000000,10000000,100000000,1000000000}; /* converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer.*/ static uint8_t precsize_aton(const char **strptr)