From: Remi Gacogne Date: Mon, 20 Apr 2020 12:32:33 +0000 (+0200) Subject: auth: Fix 'value is never actually read' warnings from clang++ 10 X-Git-Tag: dnsdist-1.5.0-rc2~14^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5d2c081d227b96992adeef4c2a1f5a89b014ac6;p=thirdparty%2Fpdns.git auth: Fix 'value is never actually read' warnings from clang++ 10 --- diff --git a/modules/gmysqlbackend/smysql.cc b/modules/gmysqlbackend/smysql.cc index 74087425e2..152c987739 100644 --- a/modules/gmysqlbackend/smysql.cc +++ b/modules/gmysqlbackend/smysql.cc @@ -181,8 +181,6 @@ public: } SSqlStatement* execute() { - int err; - prepareStatement(); if (!d_stmt) return this; @@ -192,20 +190,20 @@ public: d_dtime.set(); } - if ((err = mysql_stmt_bind_param(d_stmt, d_req_bind))) { + if (mysql_stmt_bind_param(d_stmt, d_req_bind) != 0) { string error(mysql_stmt_error(d_stmt)); releaseStatement(); throw SSqlException("Could not bind mysql statement: " + d_query + string(": ") + error); } - if ((err = mysql_stmt_execute(d_stmt))) { + if (mysql_stmt_execute(d_stmt) != 0) { string error(mysql_stmt_error(d_stmt)); releaseStatement(); throw SSqlException("Could not execute mysql statement: " + d_query + string(": ") + error); } // MySQL documentation says you can call this safely for all queries - if ((err = mysql_stmt_store_result(d_stmt))) { + if (mysql_stmt_store_result(d_stmt) != 0) { string error(mysql_stmt_error(d_stmt)); releaseStatement(); throw SSqlException("Could not store mysql statement: " + d_query + string(": ") + error); @@ -241,7 +239,7 @@ public: stmt->bind_result_done to false, causing the second to reset the existing binding), and we can't bind it right after the call to mysql_stmt_store_result() if it returned no rows, because then the statement 'contains no metadata' */ - if (d_res_bind != nullptr && (err = mysql_stmt_bind_result(d_stmt, d_res_bind))) { + if (d_res_bind != nullptr && mysql_stmt_bind_result(d_stmt, d_res_bind) != 0) { string error(mysql_stmt_error(d_stmt)); releaseStatement(); throw SSqlException("Could not bind parameters to mysql statement: " + d_query + string(": ") + error); @@ -295,7 +293,7 @@ public: if (d_residx >= d_resnum) { mysql_stmt_free_result(d_stmt); while(!mysql_stmt_next_result(d_stmt)) { - if ((err = mysql_stmt_store_result(d_stmt))) { + if (mysql_stmt_store_result(d_stmt) != 0) { string error(mysql_stmt_error(d_stmt)); releaseStatement(); throw SSqlException("Could not store mysql statement while processing additional sets: " + d_query + string(": ") + error); @@ -304,7 +302,7 @@ public: // XXX: For some reason mysql_stmt_result_metadata returns NULL here, so we cannot // ensure row field count matches first result set. if (d_resnum > 0) { // ignore empty result set - if (d_res_bind != nullptr && (err = mysql_stmt_bind_result(d_stmt, d_res_bind))) { + if (d_res_bind != nullptr && mysql_stmt_bind_result(d_stmt, d_res_bind) != 0) { string error(mysql_stmt_error(d_stmt)); releaseStatement(); throw SSqlException("Could not bind parameters to mysql statement: " + d_query + string(": ") + error); @@ -367,8 +365,6 @@ public: private: void prepareStatement() { - int err; - if (d_prepared) return; if (d_query.empty()) { d_prepared = true; @@ -378,7 +374,7 @@ private: if ((d_stmt = mysql_stmt_init(d_db))==NULL) throw SSqlException("Could not initialize mysql statement, out of memory: " + d_query); - if ((err = mysql_stmt_prepare(d_stmt, d_query.c_str(), d_query.size()))) { + if (mysql_stmt_prepare(d_stmt, d_query.c_str(), d_query.size()) != 0) { string error(mysql_stmt_error(d_stmt)); releaseStatement(); throw SSqlException("Could not prepare statement: " + d_query + string(": ") + error); diff --git a/pdns/misc.cc b/pdns/misc.cc index af33b56e3e..2d22f38089 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -777,9 +777,8 @@ int makeIPv6sockaddr(const std::string& addr, struct sockaddr_in6* ret) hints.ai_family = AF_INET6; hints.ai_flags = AI_NUMERICHOST; - int error; // getaddrinfo has anomalous return codes, anything nonzero is an error, positive or negative - if((error=getaddrinfo(ourAddr.c_str(), 0, &hints, &res))) { + if (getaddrinfo(ourAddr.c_str(), 0, &hints, &res) != 0) { return -1; } diff --git a/pdns/pkcs11signers.cc b/pdns/pkcs11signers.cc index 1d3c5ffb62..c999a57393 100644 --- a/pdns/pkcs11signers.cc +++ b/pdns/pkcs11signers.cc @@ -784,7 +784,6 @@ void PKCS11DNSCryptoKeyEngine::create(unsigned int bits) { std::vector privAttr; CK_MECHANISM mech; CK_OBJECT_HANDLE pubKey, privKey; - CK_RV rv; std::shared_ptr d_slot; d_slot = Pkcs11Token::GetToken(d_module, d_slot_id, d_label, d_pub_label); if (d_slot->LoggedIn() == false) @@ -819,7 +818,7 @@ void PKCS11DNSCryptoKeyEngine::create(unsigned int bits) { mech.pParameter = NULL; mech.ulParameterLen = 0; - if ((rv = d_slot->GenerateKeyPair(&mech, pubAttr, privAttr, &pubKey, &privKey))) { + if (d_slot->GenerateKeyPair(&mech, pubAttr, privAttr, &pubKey, &privKey)) { throw PDNSException("Keypair generation failed"); } };