summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-03-18 17:48:29 +0200
committerAndrei Karas <akaras@inbox.ru>2011-03-18 17:49:00 +0200
commitf98d003e354a1792117b7cbc771d1dd91475a156 (patch)
treedc2a297f7c4026394c9954ae4bfd4abd22ef9612 /src/utils
parentbb0a6cb25b2985fd1f74c9d27d5a46f6863e2dee (diff)
downloadmv-f98d003e354a1792117b7cbc771d1dd91475a156.tar.gz
mv-f98d003e354a1792117b7cbc771d1dd91475a156.tar.bz2
mv-f98d003e354a1792117b7cbc771d1dd91475a156.tar.xz
mv-f98d003e354a1792117b7cbc771d1dd91475a156.zip
Fix most old style cast except manaserv and libxml2 defines.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/base64.cpp6
-rw-r--r--src/utils/copynpaste.cpp2
-rw-r--r--src/utils/sha256.cpp8
-rw-r--r--src/utils/stringutils.cpp15
-rw-r--r--src/utils/xml.cpp11
5 files changed, 22 insertions, 20 deletions
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index 1221a7c7f..c7f34a5d9 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -47,8 +47,8 @@ unsigned char *php3_base64_encode(const unsigned char *string,
{
const unsigned char *current = string;
int i = 0;
- unsigned char *result = (unsigned char *)malloc(
- ((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char));
+ unsigned char *result = static_cast<unsigned char *>(malloc(
+ ((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char)));
while (length > 2)
{ /* keep going until we have less than 24 bits */
@@ -97,7 +97,7 @@ unsigned char *php3_base64_decode(const unsigned char *string,
int ch, i = 0, j = 0, k;
char *chp;
- unsigned char *result = (unsigned char *)malloc(length + 1);
+ unsigned char *result = static_cast<unsigned char *>(malloc(length + 1));
if (result == NULL)
return NULL;
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp
index 73ab1b35c..06c959017 100644
--- a/src/utils/copynpaste.cpp
+++ b/src/utils/copynpaste.cpp
@@ -301,7 +301,7 @@ static char* getSelection2(Display *dpy, Window us, Atom selection,
//printf(">>> Got %s: len=%lu left=%lu (event %i)\n", data,
// len, left, 50-max_events);
- return (char*)data;
+ return reinterpret_cast<char*>(data);
}
}
return NULL;
diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp
index 0da2a18fe..80126479a 100644
--- a/src/utils/sha256.cpp
+++ b/src/utils/sha256.cpp
@@ -110,10 +110,10 @@ class SHA256Context
#define UNPACK32(x, str) \
{ \
- *((str) + 3) = (uint8_t) ((x) ); \
- *((str) + 2) = (uint8_t) ((x) >> 8); \
- *((str) + 1) = (uint8_t) ((x) >> 16); \
- *((str) + 0) = (uint8_t) ((x) >> 24); \
+ *((str) + 3) = static_cast<uint8_t> ((x) ); \
+ *((str) + 2) = static_cast<uint8_t> ((x) >> 8); \
+ *((str) + 1) = static_cast<uint8_t> ((x) >> 16); \
+ *((str) + 0) = static_cast<uint8_t> ((x) >> 24); \
}
#define PACK32(str, x) \
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 63924eb78..b5c2abd3e 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -74,10 +74,10 @@ const char *ipToString(int address)
static char asciiIP[18];
sprintf(asciiIP, "%i.%i.%i.%i",
- (unsigned char)(address),
- (unsigned char)(address >> 8),
- (unsigned char)(address >> 16),
- (unsigned char)(address >> 24));
+ static_cast<unsigned char>(address),
+ static_cast<unsigned char>(address >> 8),
+ static_cast<unsigned char>(address >> 16),
+ static_cast<unsigned char>(address >> 24));
return asciiIP;
}
@@ -209,7 +209,7 @@ const std::string encodeStr(unsigned int value, unsigned int size)
while (value);
while (buf.length() < size)
- buf += (char)start;
+ buf += static_cast<char>(start);
return buf;
}
@@ -325,7 +325,7 @@ bool getBoolFromString(const std::string &text)
else if (txt == "false" || txt == "no" || txt == "off" || txt == "0")
return false;
else
- return (bool) atoi(txt.c_str());
+ return static_cast<bool>(atoi(txt.c_str()));
}
void replaceSpecialChars(std::string &text)
@@ -347,7 +347,8 @@ void replaceSpecialChars(std::string &text)
if (idx + 1 < f && text[f] == ';')
{
std::string str = " ";
- str[0] = (char)atoi(text.substr(idx, f - idx).c_str());
+ str[0] = static_cast<char>(atoi(text.substr(
+ idx, f - idx).c_str()));
text = text.substr(0, pos1) + str + text.substr(f + 1);
pos1 += 1;
}
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index adba59fce..0ffd2acfc 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -40,7 +40,8 @@ namespace XML
if (useResman)
{
ResourceManager *resman = ResourceManager::getInstance();
- data = (char*) resman->loadFile(filename.c_str(), size);
+ data = static_cast<char*>(resman->loadFile(
+ filename.c_str(), size));
}
else
{
@@ -54,7 +55,7 @@ namespace XML
size = static_cast<int>(file.tellg());
file.seekg(0, std::ios::beg);
- data = (char*) malloc(size);
+ data = static_cast<char*>(malloc(size));
file.read(data, size);
file.close();
@@ -105,7 +106,7 @@ namespace XML
xmlChar *prop = xmlGetProp(node, BAD_CAST name);
if (prop)
{
- ret = atoi((char*)prop);
+ ret = atoi(reinterpret_cast<char*>(prop));
xmlFree(prop);
}
@@ -119,7 +120,7 @@ namespace XML
xmlChar *prop = xmlGetProp(node, BAD_CAST name);
if (prop)
{
- ret = atof((char*)prop);
+ ret = atof(reinterpret_cast<char*>(prop));
xmlFree(prop);
}
@@ -132,7 +133,7 @@ namespace XML
xmlChar *prop = xmlGetProp(node, BAD_CAST name);
if (prop)
{
- std::string val = (char*)prop;
+ std::string val = reinterpret_cast<char*>(prop);
xmlFree(prop);
return val;
}