From 5e617ff1a1daaf7146e5d0f03ab0ab71f3e7e5f8 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Mon, 28 Mar 2022 10:50:52 +0200 Subject: [PATCH] Teach scanbuild that two divisions are safe: one by adding an assert, one by using a *const* table --- pdns/pdns_recursor.cc | 1 + pdns/sillyrecords.cc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) 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) -- 2.47.2