Enable reinterpre_cast checks

We seem to use reinterpret cast in a few cases unfortunately.  For the
moment, simply ignore most of them, and make it so we don't get more.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ic860cf922576b18cdc8d51d6132f5a9cbcc1d9dc
diff --git a/.clang-tidy b/.clang-tidy
index 8a14cfa..61f2c68 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -202,6 +202,7 @@
 clang-analyzer-webkit.NoUncountedMemberChecker,
 clang-analyzer-webkit.RefCntblBaseVirtualDtor,
 cppcoreguidelines-init-variables,
+cppcoreguidelines-pro-type-reinterpret-cast,
 cppcoreguidelines-special-member-functions,
 misc-misplaced-const,
 #misc-no-recursion,
diff --git a/http/http_connection.hpp b/http/http_connection.hpp
index 77886c5..840f2b6 100644
--- a/http/http_connection.hpp
+++ b/http/http_connection.hpp
@@ -98,9 +98,11 @@
         {
             adaptor.set_verify_mode(boost::asio::ssl::verify_peer);
             std::string id = "bmcweb";
+
+            // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
+            auto* idC = reinterpret_cast<const unsigned char*>(id.c_str());
             int ret = SSL_set_session_id_context(
-                adaptor.native_handle(),
-                reinterpret_cast<const unsigned char*>(id.c_str()),
+                adaptor.native_handle(), idC,
                 static_cast<unsigned int>(id.length()));
             if (ret == 0)
             {
diff --git a/include/hostname_monitor.hpp b/include/hostname_monitor.hpp
index 65a5c1c..30186b6 100644
--- a/include/hostname_monitor.hpp
+++ b/include/hostname_monitor.hpp
@@ -103,6 +103,7 @@
         X509_get_ext_d2i(cert, NID_netscape_comment, nullptr, nullptr));
     if (asn1)
     {
+        // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
         std::string_view comment(reinterpret_cast<const char*>(asn1->data),
                                  static_cast<size_t>(asn1->length));
         BMCWEB_LOG_DEBUG << "x509Comment: " << comment;
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp
index 8e04b84..4fbb503 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -530,7 +530,9 @@
 inline bool Lock::checkByte(uint64_t resourceId1, uint64_t resourceId2,
                             uint32_t position)
 {
+    // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
     uint8_t* p = reinterpret_cast<uint8_t*>(&resourceId1);
+    // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
     uint8_t* q = reinterpret_cast<uint8_t*>(&resourceId2);
 
     BMCWEB_LOG_DEBUG << "Comparing bytes " << std::to_string(p[position]) << ","
diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp
index a24270f..0ce0bb4 100644
--- a/include/pam_authenticate.hpp
+++ b/include/pam_authenticate.hpp
@@ -32,6 +32,7 @@
         /* Assume PAM is only prompting for the password as hidden input */
         /* Allocate memory only when PAM_PROMPT_ECHO_OFF is encounterred */
 
+        // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
         char* appPass = reinterpret_cast<char*>(appdataPtr);
         size_t appPassSize = std::strlen(appPass);
 
@@ -39,8 +40,14 @@
         {
             return PAM_CONV_ERR;
         }
+        // IDeally we'd like to avoid using malloc here, but because we're
+        // passing off ownership of this to a C application, there aren't a lot
+        // of sane ways to avoid it.
 
-        char* pass = reinterpret_cast<char*>(malloc(appPassSize + 1));
+        // NOLINTNEXTLINE(cppcoreguidelines-no-malloc)'
+        void* passPtr = malloc(appPassSize + 1);
+        // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
+        char* pass = reinterpret_cast<char*>(passPtr);
         if (pass == nullptr)
         {
             return PAM_BUF_ERR;
@@ -48,15 +55,17 @@
 
         std::strncpy(pass, appPass, appPassSize + 1);
 
-        void* ptr =
-            calloc(static_cast<size_t>(numMsg), sizeof(struct pam_response));
+        size_t numMsgSize = static_cast<size_t>(numMsg);
+        void* ptr = calloc(numMsgSize, sizeof(struct pam_response));
         if (ptr == nullptr)
         {
             free(pass);
             return PAM_BUF_ERR;
         }
 
+        // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
         *resp = reinterpret_cast<pam_response*>(ptr);
+
         resp[i]->resp = pass;
 
         return PAM_SUCCESS;
diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp
index eb59bee..dbe596a 100644
--- a/include/ssl_key_handler.hpp
+++ b/include/ssl_key_handler.hpp
@@ -281,15 +281,20 @@
             // get the subject name
             X509_NAME* name = X509_get_subject_name(x509);
 
-            X509_NAME_add_entry_by_txt(
-                name, "C", MBSTRING_ASC,
-                reinterpret_cast<const unsigned char*>("US"), -1, -1, 0);
-            X509_NAME_add_entry_by_txt(
-                name, "O", MBSTRING_ASC,
-                reinterpret_cast<const unsigned char*>("OpenBMC"), -1, -1, 0);
-            X509_NAME_add_entry_by_txt(
-                name, "CN", MBSTRING_ASC,
-                reinterpret_cast<const unsigned char*>(cn.c_str()), -1, -1, 0);
+            using x509String = const unsigned char;
+            // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
+            x509String* country = reinterpret_cast<x509String*>("US");
+            // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
+            x509String* company = reinterpret_cast<x509String*>("OpenBMC");
+            // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
+            x509String* cnStr = reinterpret_cast<x509String*>(cn.c_str());
+
+            X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, country, -1, -1,
+                                       0);
+            X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, company, -1, -1,
+                                       0);
+            X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, cnStr, -1, -1,
+                                       0);
             // set the CSR options
             X509_set_issuer_name(x509, name);
 
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index ddd124b..2cd35df 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -136,8 +136,10 @@
     size_t length = 0;
     int ret = 0;
     // Get the metadata from the requested field of the journal entry
-    ret = sd_journal_get_data(journal, field.data(),
-                              reinterpret_cast<const void**>(&data), &length);
+    // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
+    const void** dataVoid = reinterpret_cast<const void**>(&data);
+
+    ret = sd_journal_get_data(journal, field.data(), dataVoid, &length);
     if (ret < 0)
     {
         return ret;
@@ -3462,18 +3464,17 @@
                             return;
                         }
 
-                        auto& [tID, code] = postcodes[value];
-                        if (code.empty())
+                        auto& [tID, c] = postcodes[value];
+                        if (c.empty())
                         {
                             BMCWEB_LOG_INFO << "No found post code data";
                             messages::resourceNotFound(asyncResp->res,
                                                        "LogEntry", postCodeID);
                             return;
                         }
-
-                        std::string_view strData(
-                            reinterpret_cast<const char*>(code.data()),
-                            code.size());
+                        // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
+                        const char* d = reinterpret_cast<const char*>(c.data());
+                        std::string_view strData(d, c.size());
 
                         asyncResp->res.addHeader("Content-Type",
                                                  "application/octet-stream");