From 656850deda2bd478b828a761d2231c65b1fa771e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 6 Mar 2023 08:18:41 +0100 Subject: xmloff: fix -Wmaybe-uninitialized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case operator >>=() of uno::Any fails, it leaves nTabIndex uninitialized and it seems gcc notices this sometimes: In file included from include/com/sun/star/uno/Any.h:30, from include/com/sun/star/uno/Any.hxx:35, from include/o3tl/any.hxx:21, from xmloff/source/text/txtparae.cxx:22: include/rtl/ustring.hxx: In member function ‘void XMLTextParagraphExport::ExportContentControl(const com::sun::star::uno::Reference&, bool, bool, bool&)’: include/rtl/ustring.hxx:3044:22: warning: ‘nTabIndex’ may be used uninitialized in this function [-Wmaybe-uninitialized] 3044 | return number( static_cast< unsigned long long >( i ), radix ); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ xmloff/source/text/txtparae.cxx:3999:20: note: ‘nTabIndex’ was declared here 3999 | sal_uInt32 nTabIndex; | ^~~~~~~~~ Change-Id: Ia39e85575bde4011247583265497ddf4d0d4c52b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148598 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- xmloff/source/text/txtparae.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmloff') diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index f9928e402295..a06e027c7190 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -4085,7 +4085,7 @@ void XMLTextParagraphExport::ExportContentControl( GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_ID, OUString::number(nId)); } - sal_uInt32 nTabIndex; + sal_uInt32 nTabIndex = 0; if ((xPropertySet->getPropertyValue("TabIndex") >>= nTabIndex) && nTabIndex) { GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_TAB_INDEX, -- cgit