diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-12-04 15:55:14 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-12-04 16:00:16 +0100 |
commit | bda7beac5b9ea434ddd3185e71d253c9ba11c098 (patch) | |
tree | 6115329f6995c3a328e55af8cdbcd08fbc12f288 /sal/inc | |
parent | c349164824d7c4d467a7a9a9148a7cd6555e3684 (diff) |
sal: warning C4267: return: conversion from 'size_t' to 'int'...
... possible loss of data.
Minimal fix that inserts casts when calling strlen; other option would
be to change all length() to return size_t...
Change-Id: I5d1e0b0c7175a1957aad3acd89884fcd37089454
Diffstat (limited to 'sal/inc')
-rw-r--r-- | sal/inc/rtl/strbuf.hxx | 2 | ||||
-rw-r--r-- | sal/inc/rtl/string.hxx | 2 | ||||
-rw-r--r-- | sal/inc/rtl/stringconcat.hxx | 12 | ||||
-rw-r--r-- | sal/inc/rtl/ustrbuf.hxx | 2 | ||||
-rw-r--r-- | sal/inc/rtl/ustring.hxx | 4 |
5 files changed, 14 insertions, 8 deletions
diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx index 5f1c351238b6..ed627ced949d 100644 --- a/sal/inc/rtl/strbuf.hxx +++ b/sal/inc/rtl/strbuf.hxx @@ -228,7 +228,7 @@ public: template< typename T1, typename T2 > OStringBuffer( const OStringConcat< T1, T2 >& c ) { - const int l = c.length(); + const sal_Int32 l = c.length(); rtl_String* buffer = NULL; nCapacity = l + 16; rtl_string_new_WithLength( &buffer, nCapacity ); diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index f1e51b70005a..cbd4b9a1b043 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -260,7 +260,7 @@ public: template< typename T1, typename T2 > OString( const OStringConcat< T1, T2 >& c ) { - const int l = c.length(); + const sal_Int32 l = c.length(); rtl_String* buffer = NULL; rtl_string_new_WithLength( &buffer, l ); if (l != 0) diff --git a/sal/inc/rtl/stringconcat.hxx b/sal/inc/rtl/stringconcat.hxx index bf0244af6e77..2b4fc31f60c6 100644 --- a/sal/inc/rtl/stringconcat.hxx +++ b/sal/inc/rtl/stringconcat.hxx @@ -100,7 +100,9 @@ sal_Unicode* addDataUString( sal_Unicode* buffer, const sal_Unicode* str ) template<> struct ToStringHelper< const char* > { - static int length( const char* str ) { return strlen( str ); } + static int length( const char* str ) { + return sal::static_int_cast<int>(strlen( str )); + } static char* addData( char* buffer, const char* str ) { return addDataCString( buffer, str ); } static const bool allowOStringConcat = true; static const bool allowOUStringConcat = false; @@ -109,7 +111,9 @@ struct ToStringHelper< const char* > template<> struct ToStringHelper< char* > { - static int length( const char* str ) { return strlen( str ); } + static int length( const char* str ) { + return sal::static_int_cast<int>(strlen( str )); + } static char* addData( char* buffer, const char* str ) { return addDataCString( buffer, str ); } static const bool allowOStringConcat = true; static const bool allowOUStringConcat = false; @@ -118,7 +122,9 @@ struct ToStringHelper< char* > template< int N > struct ToStringHelper< char[ N ] > { - static int length( const char str[ N ] ) { return strlen( str ); } + static int length( const char str[ N ] ) { + return sal::static_int_cast<int>(strlen( str )); + } static char* addData( char* buffer, const char str[ N ] ) { return addDataCString( buffer, str ); } static sal_Unicode* addData( sal_Unicode* buffer, const char str[ N ] ) { return addDataLiteral( buffer, str, N - 1 ); } static const bool allowOStringConcat = true; diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx index f49f7f8bbd4c..b8f2d0566193 100644 --- a/sal/inc/rtl/ustrbuf.hxx +++ b/sal/inc/rtl/ustrbuf.hxx @@ -220,7 +220,7 @@ public: template< typename T1, typename T2 > OUStringBuffer( const OUStringConcat< T1, T2 >& c ) { - const int l = c.length(); + const sal_Int32 l = c.length(); rtl_uString* buffer = NULL; nCapacity = l + 16; rtl_uString_new_WithLength( &buffer, nCapacity ); // TODO this clears, not necessary diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 4408dfd3d7b6..36295116dbe9 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -328,7 +328,7 @@ public: template< typename T1, typename T2 > OUString( const OUStringConcat< T1, T2 >& c ) { - const int l = c.length(); + const sal_Int32 l = c.length(); rtl_uString* buffer = NULL; rtl_uString_new_WithLength( &buffer, l ); // TODO this clears, not necessary if (l != 0) @@ -1592,7 +1592,7 @@ public: @since LibreOffice 4.0 */ - OUString replaceAll(OUString const & from, OUString const & to, int fromIndex = 0) const { + OUString replaceAll(OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const { rtl_uString * s = 0; rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex); return OUString(s, SAL_NO_ACQUIRE); |