From ad9871a5d1119593068f7e3a01d4249b4dff982a Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 23 Jan 2018 11:06:22 +0100 Subject: Introduce SbxValues::clear MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...to avoid upcoming GCC 8 -Werror=class-memaccess ("clearing an object of non- trivial type ‘struct SbxValues’") Change-Id: Icf610e692b81030bfd6f2f940c43ee8bf6f1d4e0 Reviewed-on: https://gerrit.libreoffice.org/48389 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- basic/source/sbx/sbxvalue.cxx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'basic/source') diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index dcf336544c3e..0f609d866135 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -44,8 +44,7 @@ SbxValue::SbxValue( SbxDataType t ) : SbxBase() n = SbxEMPTY; else SetFlag( SbxFlagBits::Fixed ); - memset( &aData, 0, sizeof( SbxValues ) ); - aData.eType = SbxDataType( n ); + aData.clear(SbxDataType( n )); } SbxValue::SbxValue( const SbxValue& r ) @@ -172,8 +171,7 @@ void SbxValue::Clear() default: { SbxValues aEmpty; - memset( &aEmpty, 0, sizeof( SbxValues ) ); - aEmpty.eType = GetType(); + aEmpty.clear(GetType()); Put( aEmpty ); } } @@ -341,8 +339,7 @@ bool SbxValue::Get( SbxValues& rRes ) const { // Object contained itself SbxDataType eTemp = rRes.eType; - memset( &rRes, 0, sizeof( SbxValues ) ); - rRes.eType = eTemp; + rRes.clear(eTemp); } } if( !IsError() ) @@ -753,9 +750,7 @@ bool SbxValue::SetType( SbxDataType t ) break; default: break; } - // This works always, because the Float representations are 0 as well. - memset( &aData, 0, sizeof( SbxValues ) ); - aData.eType = t; + aData.clear(t); } } return true; @@ -1502,9 +1497,8 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) case SbxWCHAR: break; default: - memset (&aData,0,sizeof(aData)); + aData.clear(SbxNULL); ResetFlag(SbxFlagBits::Fixed); - aData.eType = SbxNULL; SAL_WARN( "basic.sbx", "Loaded a non-supported data type" ); return false; -- cgit