[Libreoffice-commits] online.git: common/Png.hpp common/SigUtil.cpp common/SpookyV2.cpp kit/Kit.cpp
Noel Grandin
noel.grandin at collabora.co.uk
Tue Dec 27 10:47:15 UTC 2016
common/Png.hpp | 8 ++++----
common/SigUtil.cpp | 8 ++++----
common/SpookyV2.cpp | 26 +++++++++++++-------------
kit/Kit.cpp | 2 +-
4 files changed, 22 insertions(+), 22 deletions(-)
New commits:
commit d6b767b840555b9df4f4f2e178192b529b6c445c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri Dec 23 09:31:35 2016 +0200
loplugin:cstylecast
Change-Id: I5a0524aca89b16ba336d69028faf76cccab22d59
Reviewed-on: https://gerrit.libreoffice.org/32371
Reviewed-by: Tor Lillqvist <tml at collabora.com>
Tested-by: Tor Lillqvist <tml at collabora.com>
diff --git a/common/Png.hpp b/common/Png.hpp
index f859408..395da6a 100644
--- a/common/Png.hpp
+++ b/common/Png.hpp
@@ -64,7 +64,7 @@ extern "C"
static void user_write_fn(png_structp png_ptr, png_bytep data, png_size_t length)
{
- std::vector<char>* outputp = (std::vector<char>*)png_get_io_ptr(png_ptr);
+ std::vector<char>* outputp = static_cast<std::vector<char>*>(png_get_io_ptr(png_ptr));
const size_t oldsize = outputp->size();
outputp->resize(oldsize + length);
std::memcpy(outputp->data() + oldsize, data, length);
@@ -194,15 +194,15 @@ void readTileData(png_structp png_ptr, png_bytep data, png_size_t length)
assert(io_ptr);
assert(io_ptr != nullptr);
- std::stringstream& streamTile = *(std::stringstream*)io_ptr;
- streamTile.read((char*)data, length);
+ std::stringstream& streamTile = *static_cast<std::stringstream*>(io_ptr);
+ streamTile.read(reinterpret_cast<char*>(data), length);
}
inline
std::vector<png_bytep> decodePNG(std::stringstream& stream, png_uint_32& height, png_uint_32& width, png_uint_32& rowBytes)
{
png_byte signature[0x08];
- stream.read((char *)signature, 0x08);
+ stream.read(reinterpret_cast<char *>(signature), 0x08);
if (png_sig_cmp(signature, 0x00, 0x08))
{
throw std::runtime_error("Invalid PNG signature.");
diff --git a/common/SigUtil.cpp b/common/SigUtil.cpp
index ee3c776..476fe09 100644
--- a/common/SigUtil.cpp
+++ b/common/SigUtil.cpp
@@ -195,13 +195,13 @@ namespace SigUtil
if (symbols != nullptr)
{
struct iovec ioVector[maxSlots*2+1];
- ioVector[0].iov_base = (void*)header;
- ioVector[0].iov_len = std::strlen((const char*)ioVector[0].iov_base);
+ ioVector[0].iov_base = static_cast<void*>(header);
+ ioVector[0].iov_len = std::strlen(static_cast<const char*>(ioVector[0].iov_base));
for (int i = 0; i < numSlots; i++)
{
ioVector[1+i*2+0].iov_base = symbols[i];
- ioVector[1+i*2+0].iov_len = std::strlen((const char *)ioVector[1+i*2+0].iov_base);
- ioVector[1+i*2+1].iov_base = (void*)"\n";
+ ioVector[1+i*2+0].iov_len = std::strlen(static_cast<const char *>(ioVector[1+i*2+0].iov_base));
+ ioVector[1+i*2+1].iov_base = const_cast<void*>(static_cast<const void*>("\n"));
ioVector[1+i*2+1].iov_len = 1;
}
diff --git a/common/SpookyV2.cpp b/common/SpookyV2.cpp
index c758a41..5a4b0f3 100644
--- a/common/SpookyV2.cpp
+++ b/common/SpookyV2.cpp
@@ -33,7 +33,7 @@ void SpookyHash::Short(
size_t i;
} u;
- u.p8 = (const uint8 *)message;
+ u.p8 = static_cast<const uint8 *>(message);
if (!ALLOW_UNALIGNED_READS && (u.i & 0x7))
{
@@ -151,7 +151,7 @@ void SpookyHash::Hash128(
h1=h4=h7=h10 = *hash2;
h2=h5=h8=h11 = sc_const;
- u.p8 = (const uint8 *)message;
+ u.p8 = static_cast<const uint8 *>(message);
end = u.p64 + (length/sc_blockSize)*sc_numVars;
// handle all whole sc_blockSize blocks of bytes
@@ -174,10 +174,10 @@ void SpookyHash::Hash128(
}
// handle the last partial block of sc_blockSize bytes
- remainder = (length - ((const uint8 *)end-(const uint8 *)message));
+ remainder = (length - (reinterpret_cast<const uint8 *>(end) - static_cast<const uint8 *>(message)));
memcpy(buf, end, remainder);
- memset(((uint8 *)buf)+remainder, 0, sc_blockSize-remainder);
- ((uint8 *)buf)[sc_blockSize-1] = remainder;
+ memset((reinterpret_cast<uint8 *>(buf))+remainder, 0, sc_blockSize-remainder);
+ (reinterpret_cast<uint8 *>(buf))[sc_blockSize-1] = remainder;
// do some final mixing
End(buf, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
@@ -214,7 +214,7 @@ void SpookyHash::Update(const void *message, size_t length)
// Is this message fragment too short? If it is, stuff it away.
if (newLength < sc_bufSize)
{
- memcpy(&((uint8 *)m_data)[m_remainder], message, length);
+ memcpy(&(reinterpret_cast<uint8 *>(m_data))[m_remainder], message, length);
m_length = length + m_length;
m_remainder = (uint8)newLength;
return;
@@ -248,21 +248,21 @@ void SpookyHash::Update(const void *message, size_t length)
if (m_remainder)
{
uint8 prefix = sc_bufSize-m_remainder;
- memcpy(&(((uint8 *)m_data)[m_remainder]), message, prefix);
+ memcpy(&((reinterpret_cast<uint8 *>(m_data))[m_remainder]), message, prefix);
u.p64 = m_data;
Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
Mix(&u.p64[sc_numVars], h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
- u.p8 = ((const uint8 *)message) + prefix;
+ u.p8 = (static_cast<const uint8 *>(message)) + prefix;
length -= prefix;
}
else
{
- u.p8 = (const uint8 *)message;
+ u.p8 = static_cast<const uint8 *>(message);
}
// handle all whole blocks of sc_blockSize bytes
end = u.p64 + (length/sc_blockSize)*sc_numVars;
- remainder = (uint8)(length-((const uint8 *)end-u.p8));
+ remainder = static_cast<uint8>(length-(reinterpret_cast<const uint8 *>(end)-u.p8));
if (ALLOW_UNALIGNED_READS || (u.i & 0x7) == 0)
{
while (u.p64 < end)
@@ -313,7 +313,7 @@ void SpookyHash::Final(uint64 *hash1, uint64 *hash2)
return;
}
- const uint64 *data = (const uint64 *)m_data;
+ uint64 *data = static_cast<uint64 *>(m_data);
uint8 remainder = m_remainder;
uint64 h0 = m_state[0];
@@ -338,9 +338,9 @@ void SpookyHash::Final(uint64 *hash1, uint64 *hash2)
}
// mix in the last partial block, and the length mod sc_blockSize
- memset(&((uint8 *)data)[remainder], 0, (sc_blockSize-remainder));
+ memset(&(reinterpret_cast<uint8 *>(data))[remainder], 0, (sc_blockSize-remainder));
- ((uint8 *)data)[sc_blockSize-1] = remainder;
+ (reinterpret_cast<uint8 *>(data))[sc_blockSize-1] = remainder;
// do some final mixing
End(data, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 02c442c..c39a31b 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1780,7 +1780,7 @@ bool globalPreinit(const std::string &loTemplate)
}
}
- LokHookPreInit* preInit = (LokHookPreInit *)dlsym(handle, "lok_preinit");
+ LokHookPreInit* preInit = reinterpret_cast<LokHookPreInit *>(dlsym(handle, "lok_preinit"));
if (!preInit)
{
LOG_FTL("No lok_preinit symbol in " << loadedLibrary << ": " << dlerror());
More information about the Libreoffice-commits
mailing list