aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2022-02-06 14:04:47 -0500
committerJack Lloyd <[email protected]>2022-02-06 14:04:47 -0500
commit25682391a043c35ee19f4ac3863b6e73d1d80e0f (patch)
tree2444ecd59af0782939b6b105adf5c04b555a364c
parentd76a8917b0351979aeb36d4a690392d03aa215a7 (diff)
Remove static from data in anonymous namespaces
-rw-r--r--src/lib/pbkdf/argon2/argon2.cpp2
-rw-r--r--src/lib/pbkdf/pgp_s2k/rfc4880.cpp2
-rw-r--r--src/lib/pk_pad/padding.cpp2
-rw-r--r--src/lib/pk_pad/padding.h2
-rw-r--r--src/lib/prov/pkcs11/p11_mechanism.cpp10
-rw-r--r--src/lib/pubkey/newhope/newhope.cpp4
-rw-r--r--src/lib/utils/os_utils.cpp2
-rw-r--r--src/lib/x509/x509_dn_ub.cpp2
-rwxr-xr-xsrc/scripts/run_clang_tidy.py42
9 files changed, 46 insertions, 22 deletions
diff --git a/src/lib/pbkdf/argon2/argon2.cpp b/src/lib/pbkdf/argon2/argon2.cpp
index f6d3ec43e..97d32e4eb 100644
--- a/src/lib/pbkdf/argon2/argon2.cpp
+++ b/src/lib/pbkdf/argon2/argon2.cpp
@@ -15,7 +15,7 @@ namespace Botan {
namespace {
-static const size_t SYNC_POINTS = 4;
+const size_t SYNC_POINTS = 4;
secure_vector<uint8_t> argon2_H0(HashFunction& blake2b,
size_t output_len,
diff --git a/src/lib/pbkdf/pgp_s2k/rfc4880.cpp b/src/lib/pbkdf/pgp_s2k/rfc4880.cpp
index b47a3e5cb..d431cced1 100644
--- a/src/lib/pbkdf/pgp_s2k/rfc4880.cpp
+++ b/src/lib/pbkdf/pgp_s2k/rfc4880.cpp
@@ -16,7 +16,7 @@ PGP stores the iteration count as a single byte
Thus it can only actually take on one of 256 values, based on the
formula in RFC 4880 section 3.6.1.3
*/
-static const uint32_t OPENPGP_S2K_ITERS[256] = {
+const uint32_t OPENPGP_S2K_ITERS[256] = {
1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600,
1664, 1728, 1792, 1856, 1920, 1984, 2048, 2176, 2304, 2432,
2560, 2688, 2816, 2944, 3072, 3200, 3328, 3456, 3584, 3712,
diff --git a/src/lib/pk_pad/padding.cpp b/src/lib/pk_pad/padding.cpp
index cb1e406ac..23219b480 100644
--- a/src/lib/pk_pad/padding.cpp
+++ b/src/lib/pk_pad/padding.cpp
@@ -29,7 +29,7 @@ const std::map<const std::string, std::vector<std::string>> allowed_signature_pa
{ "RSA", {"EMSA4", "EMSA3"} },
};
-const std::vector<std::string> get_sig_paddings(const std::string& algo)
+std::vector<std::string> get_sig_paddings(const std::string& algo)
{
if(allowed_signature_paddings.count(algo) > 0)
return allowed_signature_paddings.at(algo);
diff --git a/src/lib/pk_pad/padding.h b/src/lib/pk_pad/padding.h
index 349e1c0f8..e9631d2a9 100644
--- a/src/lib/pk_pad/padding.h
+++ b/src/lib/pk_pad/padding.h
@@ -20,7 +20,7 @@ namespace Botan {
* @param algo the algorithm for which to look up supported padding schemes
* @return a vector of supported padding schemes
*/
-BOTAN_TEST_API const std::vector<std::string> get_sig_paddings(const std::string& algo);
+BOTAN_TEST_API std::vector<std::string> get_sig_paddings(const std::string& algo);
/**
* Returns true iff the given padding scheme is valid for the given
diff --git a/src/lib/prov/pkcs11/p11_mechanism.cpp b/src/lib/prov/pkcs11/p11_mechanism.cpp
index 04f347814..2b521538a 100644
--- a/src/lib/prov/pkcs11/p11_mechanism.cpp
+++ b/src/lib/prov/pkcs11/p11_mechanism.cpp
@@ -20,7 +20,7 @@ namespace {
using PSS_Params = std::tuple<size_t, MechanismType, MGF>;
// maps a PSS mechanism type to the number of bytes used for the salt, the mechanism type of the underlying hash algorithm and the MGF
-static const std::map<MechanismType, PSS_Params> PssOptions =
+const std::map<MechanismType, PSS_Params> PssOptions =
{
{ MechanismType::RsaPkcsPss, PSS_Params(0, MechanismType::Sha1, MGF::Mgf1Sha1) },
{ MechanismType::Sha1RsaPkcsPss, PSS_Params(20, MechanismType::Sha1, MGF::Mgf1Sha1) },
@@ -71,7 +71,7 @@ struct RSA_SignMechanism final : public MechanismData
};
// note: when updating this map, update the documentation for `MechanismWrapper::create_rsa_sign_mechanism`
-static std::map<std::string, RSA_SignMechanism> SignMechanisms =
+const std::map<std::string, RSA_SignMechanism> SignMechanisms =
{
{ "Raw", RSA_SignMechanism(MechanismType::RsaX509) },
@@ -133,7 +133,7 @@ struct RSA_CryptMechanism final : public MechanismData
};
// note: when updating this map, update the documentation for `MechanismWrapper::create_rsa_crypt_mechanism`
-static const std::map<std::string, RSA_CryptMechanism> CryptMechanisms =
+const std::map<std::string, RSA_CryptMechanism> CryptMechanisms =
{
{ "Raw", RSA_CryptMechanism(MechanismType::RsaX509, 0) },
{ "EME-PKCS1-v1_5", RSA_CryptMechanism(MechanismType::RsaPkcs, 11) },
@@ -145,7 +145,7 @@ static const std::map<std::string, RSA_CryptMechanism> CryptMechanisms =
};
// note: when updating this map, update the documentation for `MechanismWrapper::create_ecdsa_mechanism`
-static std::map<std::string, MechanismType> EcdsaHash =
+const std::map<std::string, MechanismType> EcdsaHash =
{
{ "Raw", MechanismType::Ecdsa },
{ "SHA-160", MechanismType::EcdsaSha1 },
@@ -156,7 +156,7 @@ static std::map<std::string, MechanismType> EcdsaHash =
};
// note: when updating this map, update the documentation for `MechanismWrapper::create_ecdh_mechanism`
-static std::map<std::string, KeyDerivation> EcdhHash =
+const std::map<std::string, KeyDerivation> EcdhHash =
{
{ "Raw", KeyDerivation::Null },
{ "SHA-160", KeyDerivation::Sha1Kdf },
diff --git a/src/lib/pubkey/newhope/newhope.cpp b/src/lib/pubkey/newhope/newhope.cpp
index b6ef8e350..81e9c6a00 100644
--- a/src/lib/pubkey/newhope/newhope.cpp
+++ b/src/lib/pubkey/newhope/newhope.cpp
@@ -26,8 +26,8 @@ typedef newhope_poly poly;
namespace {
-static const uint16_t PARAM_Q = 12289;
-static const size_t PARAM_N = 1024;
+const uint16_t PARAM_Q = 12289;
+const size_t PARAM_N = 1024;
/* Incomplete-reduction routines; for details on allowed input ranges
* and produced output ranges, see the description in the paper:
diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp
index e89463b63..443091764 100644
--- a/src/lib/utils/os_utils.cpp
+++ b/src/lib/utils/os_utils.cpp
@@ -659,7 +659,7 @@ void OS::free_locked_pages(const std::vector<void*>& pages)
namespace {
-static ::sigjmp_buf g_sigill_jmp_buf;
+::sigjmp_buf g_sigill_jmp_buf;
void botan_sigill_handler(int /*unused*/)
{
diff --git a/src/lib/x509/x509_dn_ub.cpp b/src/lib/x509/x509_dn_ub.cpp
index b5c7645a1..2762f42fd 100644
--- a/src/lib/x509/x509_dn_ub.cpp
+++ b/src/lib/x509/x509_dn_ub.cpp
@@ -21,7 +21,7 @@ namespace {
* Maps OID string representations instead of human readable strings in order
* to avoid an additional lookup.
*/
-static const std::map<Botan::OID, size_t> DN_UB =
+const std::map<Botan::OID, size_t> DN_UB =
{
{ Botan::OID({2,5,4,10}), 64 }, // X520.Organization
{ Botan::OID({2,5,4,11}), 64 }, // X520.OrganizationalUnit
diff --git a/src/scripts/run_clang_tidy.py b/src/scripts/run_clang_tidy.py
index 0a1df47ea..8007f43ce 100755
--- a/src/scripts/run_clang_tidy.py
+++ b/src/scripts/run_clang_tidy.py
@@ -10,16 +10,19 @@ import re
from multiprocessing.pool import ThreadPool
enabled_checks = [
- 'clang-analyzer-*',
- 'performance-*',
- 'bugprone-*',
- 'cert-*',
- 'cppcoreguidelines-*',
+ #'clang-analyzer-*',
+ #'performance-*',
+ #'bugprone-*',
+ #'cert-*',
+ #'cppcoreguidelines-*',
#'hicpp-*',
#'modernize-*',
- 'portability-*',
+ #'portability-*',
#'readability-*',
- 'readability-container-size-empty',
+ #'readability-container-size-empty',
+ 'readability-static-definition-in-anonymous-namespace',
+ #'modernize-make-unique',
+ #'modernize-concat-nested-namespaces',
#'readability-inconsistent-declaration-parameter-name',
]
@@ -30,6 +33,9 @@ disabled_checks = [
'*-no-array-decay',
'*-else-after-return',
'*-function-size', # don't care
+ '*-use-auto', # not universally a good idea
+ 'modernize-use-nodiscard', # maybe
+ 'modernize-loop-convert', # sometimes very ugly
'readability-implicit-bool-conversion', # maybe fix this
'bugprone-easily-swappable-parameters',
'bugprone-implicit-widening-of-multiplication-result',
@@ -42,12 +48,16 @@ disabled_checks = [
'performance-no-int-to-ptr',
'readability-function-cognitive-complexity', # bogus
'portability-simd-intrinsics', # not a problem
- 'bugprone-macro-parenthesis', # should be fixed (using inline/constexpr)
+ 'bugprone-macro-parentheses', # should be fixed (using inline/constexpr)
'*-magic-numbers', # not a problem
'hicpp-signed-bitwise', # djb shit
'cppcoreguidelines-pro-type-reinterpret-cast', # not possible thanks though
'cert-err58-cpp', # shut up whiner
'modernize-return-braced-init-list', # thanks I hate it
+ 'cppcoreguidelines-no-malloc',
+ 'cppcoreguidelines-owning-memory',
+ 'cppcoreguidelines-init-variables',
+ 'readability-inconsistent-declaration-parameter-name', # should fix this
]
def create_check_option(enabled, disabled):
@@ -90,6 +100,15 @@ def run_clang_tidy(compile_commands_file,
if stdout != "":
print(stdout)
+def file_matches(file, args):
+ if args is None or len(args) == 0:
+ return True
+
+ for arg in args:
+ if file.find(arg) > 0:
+ return True
+ return False
+
def main(args = None):
if args is None:
args = sys.argv
@@ -115,11 +134,16 @@ def main(args = None):
results = []
for info in compile_commands:
+ file = info['file']
+
+ if not file_matches(file, args[1:]):
+ continue
+
results.append(pool.apply_async(
run_clang_tidy,
(compile_commands_file,
check_config,
- info['file'],
+ file,
options)))
for result in results: