summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-01-17 18:48:08 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-01-20 09:06:48 +0100
commit14c12fac0e76cb5f9533c942f1421d7ce09154df (patch)
treeb474d002232b55123ddf3fa1e9355654deac6368
parente3ec05960a12d3598fefce8bb2e1c04457de90b6 (diff)
Some more loplugin:cstylecast: io
Change-Id: Iefd3268299b43ba08b9bc7699aa104288119ff4a
-rw-r--r--io/source/TextInputStream/TextInputStream.cxx2
-rw-r--r--io/source/TextOutputStream/TextOutputStream.cxx4
-rw-r--r--io/source/stm/odata.cxx49
3 files changed, 22 insertions, 33 deletions
diff --git a/io/source/TextInputStream/TextInputStream.cxx b/io/source/TextInputStream/TextInputStream.cxx
index ceee33a90634..09d2eec3da69 100644
--- a/io/source/TextInputStream/TextInputStream.cxx
+++ b/io/source/TextInputStream/TextInputStream.cxx
@@ -310,7 +310,7 @@ sal_Int32 OTextInputStream::implReadNext()
nTargetCount += rtl_convertTextToUnicode(
mConvText2Unicode,
mContextText2Unicode,
- (const sal_Char*) &( pbSource[nSourceCount] ),
+ reinterpret_cast<const char*>(&( pbSource[nSourceCount] )),
nTotalRead - nSourceCount,
mpBuffer + mnCharsInBuffer + nTargetCount,
nFreeBufferSize - nTargetCount,
diff --git a/io/source/TextOutputStream/TextOutputStream.cxx b/io/source/TextOutputStream/TextOutputStream.cxx
index c1ebdddfcdf9..e9f643329594 100644
--- a/io/source/TextOutputStream/TextOutputStream.cxx
+++ b/io/source/TextOutputStream/TextOutputStream.cxx
@@ -128,7 +128,7 @@ Sequence<sal_Int8> OTextOutputStream::implConvert( const OUString& rSource )
sal_Int32 nSeqSize = nSourceSize * 3;
Sequence<sal_Int8> seqText( nSeqSize );
- sal_Char *pTarget = (sal_Char *) seqText.getArray();
+ sal_Char *pTarget = reinterpret_cast<char *>(seqText.getArray());
while( true )
{
nTargetCount += rtl_convertUnicodeToText(
@@ -148,7 +148,7 @@ Sequence<sal_Int8> OTextOutputStream::implConvert( const OUString& rSource )
{
nSeqSize *= 2;
seqText.realloc( nSeqSize ); // double array size
- pTarget = (sal_Char*) seqText.getArray();
+ pTarget = reinterpret_cast<char*>(seqText.getArray());
continue;
}
break;
diff --git a/io/source/stm/odata.cxx b/io/source/stm/odata.cxx
index 358d226c9e79..f671572dc18f 100644
--- a/io/source/stm/odata.cxx
+++ b/io/source/stm/odata.cxx
@@ -26,6 +26,7 @@
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <osl/endian.h>
#include <com/sun/star/io/XObjectInputStream.hpp>
#include <com/sun/star/io/XObjectOutputStream.hpp>
@@ -235,7 +236,7 @@ sal_Unicode ODataInputStream::readChar(void) throw (IOException, RuntimeExceptio
throw UnexpectedEOFException();
}
- const sal_uInt8 * pBytes = ( const sal_uInt8 * )aTmp.getConstArray();
+ const sal_uInt8 * pBytes = reinterpret_cast<const sal_uInt8 *>(aTmp.getConstArray());
return ((sal_Unicode)pBytes[0] << 8) + pBytes[1];
}
@@ -247,7 +248,7 @@ sal_Int16 ODataInputStream::readShort(void) throw (IOException, RuntimeException
throw UnexpectedEOFException();
}
- const sal_uInt8 * pBytes = ( const sal_uInt8 * ) aTmp.getConstArray();
+ const sal_uInt8 * pBytes = reinterpret_cast<const sal_uInt8 *>(aTmp.getConstArray());
return ((sal_Int16)pBytes[0] << 8) + pBytes[1];
}
@@ -260,7 +261,7 @@ sal_Int32 ODataInputStream::readLong(void) throw (IOException, RuntimeException,
throw UnexpectedEOFException( );
}
- const sal_uInt8 * pBytes = ( const sal_uInt8 * ) aTmp.getConstArray();
+ const sal_uInt8 * pBytes = reinterpret_cast<const sal_uInt8 *>(aTmp.getConstArray());
return ((sal_Int32)pBytes[0] << 24) + ((sal_Int32)pBytes[1] << 16) + ((sal_Int32)pBytes[2] << 8) + pBytes[3];
}
@@ -273,7 +274,7 @@ sal_Int64 ODataInputStream::readHyper(void) throw (IOException, RuntimeException
throw UnexpectedEOFException( );
}
- const sal_uInt8 * pBytes = ( const sal_uInt8 * ) aTmp.getConstArray();
+ const sal_uInt8 * pBytes = reinterpret_cast<const sal_uInt8 *>(aTmp.getConstArray());
return
(((sal_Int64)pBytes[0]) << 56) +
(((sal_Int64)pBytes[1]) << 48) +
@@ -294,20 +295,14 @@ float ODataInputStream::readFloat(void) throw (IOException, RuntimeException, st
double ODataInputStream::readDouble(void) throw (IOException, RuntimeException, std::exception)
{
- sal_uInt32 n = 1;
union { double d; struct { sal_uInt32 n1; sal_uInt32 n2; } ad; } a;
- if( *(sal_uInt8 *)&n == 1 )
- {
- // little endian
- a.ad.n2 = readLong();
- a.ad.n1 = readLong();
- }
- else
- {
- // big endian
- a.ad.n1 = readLong();
- a.ad.n2 = readLong();
- }
+#if defined OSL_LITENDIAN
+ a.ad.n2 = readLong();
+ a.ad.n1 = readLong();
+#else
+ a.ad.n1 = readLong();
+ a.ad.n2 = readLong();
+#endif
return a.d;
}
@@ -713,21 +708,15 @@ void ODataOutputStream::writeDouble(double Value)
throw ( IOException,
RuntimeException, std::exception)
{
- sal_uInt32 n = 1;
union { double d; struct { sal_uInt32 n1; sal_uInt32 n2; } ad; } a;
a.d = Value;
- if( *(sal_Int8 *)&n == 1 )
- {
- // little endian
- writeLong( a.ad.n2 );
- writeLong( a.ad.n1 );
- }
- else
- {
- // big endian
- writeLong( a.ad.n1 );
- writeLong( a.ad.n2 );
- }
+#if defined OSL_LITENDIAN
+ writeLong( a.ad.n2 );
+ writeLong( a.ad.n1 );
+#else
+ writeLong( a.ad.n1 );
+ writeLong( a.ad.n2 );
+#endif
}
void ODataOutputStream::writeUTF(const OUString& Value)