Some more loplugin:cstylecast: io

Change-Id: Iefd3268299b43ba08b9bc7699aa104288119ff4a
This commit is contained in:
Stephan Bergmann
2015-01-17 18:48:08 +01:00
parent e3ec05960a
commit 14c12fac0e
3 changed files with 22 additions and 33 deletions

View File

@@ -310,7 +310,7 @@ sal_Int32 OTextInputStream::implReadNext()
nTargetCount += rtl_convertTextToUnicode( nTargetCount += rtl_convertTextToUnicode(
mConvText2Unicode, mConvText2Unicode,
mContextText2Unicode, mContextText2Unicode,
(const sal_Char*) &( pbSource[nSourceCount] ), reinterpret_cast<const char*>(&( pbSource[nSourceCount] )),
nTotalRead - nSourceCount, nTotalRead - nSourceCount,
mpBuffer + mnCharsInBuffer + nTargetCount, mpBuffer + mnCharsInBuffer + nTargetCount,
nFreeBufferSize - nTargetCount, nFreeBufferSize - nTargetCount,

View File

@@ -128,7 +128,7 @@ Sequence<sal_Int8> OTextOutputStream::implConvert( const OUString& rSource )
sal_Int32 nSeqSize = nSourceSize * 3; sal_Int32 nSeqSize = nSourceSize * 3;
Sequence<sal_Int8> seqText( nSeqSize ); Sequence<sal_Int8> seqText( nSeqSize );
sal_Char *pTarget = (sal_Char *) seqText.getArray(); sal_Char *pTarget = reinterpret_cast<char *>(seqText.getArray());
while( true ) while( true )
{ {
nTargetCount += rtl_convertUnicodeToText( nTargetCount += rtl_convertUnicodeToText(
@@ -148,7 +148,7 @@ Sequence<sal_Int8> OTextOutputStream::implConvert( const OUString& rSource )
{ {
nSeqSize *= 2; nSeqSize *= 2;
seqText.realloc( nSeqSize ); // double array size seqText.realloc( nSeqSize ); // double array size
pTarget = (sal_Char*) seqText.getArray(); pTarget = reinterpret_cast<char*>(seqText.getArray());
continue; continue;
} }
break; break;

View File

@@ -26,6 +26,7 @@
#include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase4.hxx> #include <cppuhelper/implbase4.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
#include <osl/endian.h>
#include <com/sun/star/io/XObjectInputStream.hpp> #include <com/sun/star/io/XObjectInputStream.hpp>
#include <com/sun/star/io/XObjectOutputStream.hpp> #include <com/sun/star/io/XObjectOutputStream.hpp>
@@ -235,7 +236,7 @@ sal_Unicode ODataInputStream::readChar(void) throw (IOException, RuntimeExceptio
throw UnexpectedEOFException(); 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]; return ((sal_Unicode)pBytes[0] << 8) + pBytes[1];
} }
@@ -247,7 +248,7 @@ sal_Int16 ODataInputStream::readShort(void) throw (IOException, RuntimeException
throw UnexpectedEOFException(); 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]; return ((sal_Int16)pBytes[0] << 8) + pBytes[1];
} }
@@ -260,7 +261,7 @@ sal_Int32 ODataInputStream::readLong(void) throw (IOException, RuntimeException,
throw UnexpectedEOFException( ); 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]; 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( ); throw UnexpectedEOFException( );
} }
const sal_uInt8 * pBytes = ( const sal_uInt8 * ) aTmp.getConstArray(); const sal_uInt8 * pBytes = reinterpret_cast<const sal_uInt8 *>(aTmp.getConstArray());
return return
(((sal_Int64)pBytes[0]) << 56) + (((sal_Int64)pBytes[0]) << 56) +
(((sal_Int64)pBytes[1]) << 48) + (((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) 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; union { double d; struct { sal_uInt32 n1; sal_uInt32 n2; } ad; } a;
if( *(sal_uInt8 *)&n == 1 ) #if defined OSL_LITENDIAN
{ a.ad.n2 = readLong();
// little endian a.ad.n1 = readLong();
a.ad.n2 = readLong(); #else
a.ad.n1 = readLong(); a.ad.n1 = readLong();
} a.ad.n2 = readLong();
else #endif
{
// big endian
a.ad.n1 = readLong();
a.ad.n2 = readLong();
}
return a.d; return a.d;
} }
@@ -713,21 +708,15 @@ void ODataOutputStream::writeDouble(double Value)
throw ( IOException, throw ( IOException,
RuntimeException, std::exception) RuntimeException, std::exception)
{ {
sal_uInt32 n = 1;
union { double d; struct { sal_uInt32 n1; sal_uInt32 n2; } ad; } a; union { double d; struct { sal_uInt32 n1; sal_uInt32 n2; } ad; } a;
a.d = Value; a.d = Value;
if( *(sal_Int8 *)&n == 1 ) #if defined OSL_LITENDIAN
{ writeLong( a.ad.n2 );
// little endian writeLong( a.ad.n1 );
writeLong( a.ad.n2 ); #else
writeLong( a.ad.n1 ); writeLong( a.ad.n1 );
} writeLong( a.ad.n2 );
else #endif
{
// big endian
writeLong( a.ad.n1 );
writeLong( a.ad.n2 );
}
} }
void ODataOutputStream::writeUTF(const OUString& Value) void ODataOutputStream::writeUTF(const OUString& Value)