aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2007-10-19 18:11:06 +0000
committerlloyd <[email protected]>2007-10-19 18:11:06 +0000
commit807b84081f91f1f0cd5255198ce31745d410c28c (patch)
tree20574311297aee66974abce1fa138b0116aff5fc
parent11d6a889becbb8fe6c2d78dd60b9673b791c17b9 (diff)
Remove several uses of old style C casts in favor of C++98's static_cast and
reinterpret_cast
-rw-r--r--checks/dolook2.cpp2
-rw-r--r--checks/pk.cpp17
-rw-r--r--checks/validate.cpp2
-rw-r--r--modules/es_egd/es_egd.cpp2
-rw-r--r--modules/tm_hard/tm_hard.cpp4
5 files changed, 17 insertions, 10 deletions
diff --git a/checks/dolook2.cpp b/checks/dolook2.cpp
index 53e71dc26..b6c9ba339 100644
--- a/checks/dolook2.cpp
+++ b/checks/dolook2.cpp
@@ -19,7 +19,7 @@ class S2K_Filter : public Filter
{
public:
void write(const byte in[], u32bit len)
- { passphrase += std::string((const char*)in, len); }
+ { passphrase += std::string(reinterpret_cast<const char*>(in), len); }
void end_msg()
{
s2k->change_salt(salt, salt.size());
diff --git a/checks/pk.cpp b/checks/pk.cpp
index bb0a27f2a..f2c2401fd 100644
--- a/checks/pk.cpp
+++ b/checks/pk.cpp
@@ -28,7 +28,7 @@ using namespace Botan;
static BigInt to_bigint(const std::string& h)
{
- return BigInt::decode((const byte*)h.data(),
+ return BigInt::decode(reinterpret_cast<const byte*>(h.data()),
h.length(), BigInt::Hexadecimal);
}
@@ -326,7 +326,9 @@ u32bit validate_rsa_enc_pkcs8(const std::string& algo,
strip_newlines(pass); /* it will have a newline thanks to the messy
decoding method we use */
- DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length());
+ DataSource_Memory keysource(reinterpret_cast<const byte*>(str[0].c_str()),
+ str[0].length());
+
Private_Key* privkey = PKCS8::load_key(keysource, pass);
RSA_PrivateKey* rsapriv = dynamic_cast<RSA_PrivateKey*>(privkey);
@@ -441,7 +443,8 @@ u32bit validate_rsa_ver_x509(const std::string& algo,
if(str.size() != 5) /* is actually 3, parse() adds extra empty ones */
throw Exception("Invalid input from pk_valid.dat");
- DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length());
+ DataSource_Memory keysource(reinterpret_cast<const byte*>(str[0].c_str()),
+ str[0].length());
Public_Key* key = X509::load_key(keysource);
@@ -518,7 +521,9 @@ u32bit validate_dsa_sig(const std::string& algo,
strip_newlines(pass); /* it will have a newline thanks to the messy
decoding method we use */
- DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length());
+ DataSource_Memory keysource(reinterpret_cast<const byte*>(str[0].c_str()),
+ str[0].length());
+
Private_Key* privkey = PKCS8::load_key(keysource, pass);
DSA_PrivateKey* dsapriv = dynamic_cast<DSA_PrivateKey*>(privkey);
@@ -545,7 +550,9 @@ u32bit validate_dsa_ver(const std::string& algo,
if(str.size() != 5) /* is actually 3, parse() adds extra empty ones */
throw Exception("Invalid input from pk_valid.dat");
- DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length());
+ DataSource_Memory keysource(reinterpret_cast<const byte*>(str[0].c_str()),
+ str[0].length());
+
Public_Key* key = X509::load_key(keysource);
DSA_PublicKey* dsakey = dynamic_cast<DSA_PublicKey*>(key);
diff --git a/checks/validate.cpp b/checks/validate.cpp
index b10b53b98..d634d3bb3 100644
--- a/checks/validate.cpp
+++ b/checks/validate.cpp
@@ -263,7 +263,7 @@ bool failed_test(const std::string& algo,
bool OK = true;
for(u32bit j = offset; j != offset+length; j++)
- if((byte)output[j] != peekbuf[j-offset])
+ if(static_cast<byte>(output[j]) != peekbuf[j-offset])
OK = false;
if(!OK)
diff --git a/modules/es_egd/es_egd.cpp b/modules/es_egd/es_egd.cpp
index 0ff19a90b..2c377b387 100644
--- a/modules/es_egd/es_egd.cpp
+++ b/modules/es_egd/es_egd.cpp
@@ -56,7 +56,7 @@ u32bit EGD_EntropySource::do_poll(byte output[], u32bit length,
if(fd == -1) return 0;
int len = sizeof(addr.sun_family) + std::strlen(addr.sun_path) + 1;
- if(connect(fd, (struct sockaddr*)&addr, len))
+ if(connect(fd, reinterpret_cast<struct sockaddr*>(&addr), len))
{ close(fd); return 0; }
byte buffer[2];
diff --git a/modules/tm_hard/tm_hard.cpp b/modules/tm_hard/tm_hard.cpp
index da9aa3fd2..251fc9cfd 100644
--- a/modules/tm_hard/tm_hard.cpp
+++ b/modules/tm_hard/tm_hard.cpp
@@ -18,11 +18,11 @@ u64bit Hardware_Timer::clock() const
#if defined(BOTAN_TARGET_ARCH_IS_IA32) || defined(BOTAN_TARGET_ARCH_IS_AMD64)
u32bit rtc_low = 0, rtc_high = 0;
asm volatile("rdtsc" : "=d" (rtc_high), "=a" (rtc_low));
- rtc = ((u64bit)rtc_high << 32) | rtc_low;
+ rtc = (static_cast<u64bit>(rtc_high) << 32) | rtc_low;
#elif defined(BOTAN_TARGET_ARCH_IS_PPC) || defined(BOTAN_TARGET_ARCH_IS_PPC64)
u32bit rtc_low = 0, rtc_high = 0;
asm volatile("mftbu %0; mftb %1" : "=r" (rtc_high), "=r" (rtc_low));
- rtc = ((u64bit)rtc_high << 32) | rtc_low;
+ rtc = (static_cast<u64bit>(rtc_high) << 32) | rtc_low;
#elif defined(BOTAN_TARGET_ARCH_IS_ALPHA)
asm volatile("rpcc %0" : "=r" (rtc));
#elif defined(BOTAN_TARGET_ARCH_IS_SPARC64)