Change cast type (fix SonarCloud issues)

This commit is contained in:
Ervin Hegedus 2025-08-11 22:29:30 +02:00
parent 47bc24a808
commit 9fea1ca454
No known key found for this signature in database
GPG Key ID: 5FA5BC3F5EC41F61
2 changed files with 5 additions and 2 deletions

View File

@ -226,9 +226,12 @@ bool Rbl::evaluate(Transaction *t, RuleWithActions *rule,
return false;
}
// NOSONAR
// SonarCloud suggested to use the init-statement to declare "addr" inside the if statement.
// I think that's not good here, because we need that in the else block
struct sockaddr *addr = info->ai_addr;
if (addr->sa_family == AF_INET) { // only IPv4 address is allowed
struct sockaddr_in *sin = reinterpret_cast<struct sockaddr_in *>(addr);
struct sockaddr_in *sin = (struct sockaddr_in *) addr; // cppcheck-suppress[dangerousTypeCast]
furtherInfo(sin, ipStr, t, m_provider);
}
else {

View File

@ -91,7 +91,7 @@ void XML::evaluate(Transaction *t,
} else {
std::vector<actions::Action *> acts = rule->getActionsByName("xmlns", t);
for (auto &x : acts) {
actions::XmlNS *z = reinterpret_cast<actions::XmlNS *>(x);
actions::XmlNS *z = static_cast<actions::XmlNS *>(x);
if (xmlXPathRegisterNs(xpathCtx, reinterpret_cast<const xmlChar*>(z->m_scope.c_str()),
reinterpret_cast<const xmlChar*>(z->m_href.c_str())) != 0) {
ms_dbg_a(t, 1, "Failed to register XML namespace href \"" + \