[Libreoffice-commits] core.git: compilerplugins/clang editeng/qa libreofficekit/qa lingucomponent/source solenv/CompilerTest_compilerplugins_clang.mk tools/source xmlscript/source xmlsecurity/qa xmlsecurity/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Jun 29 06:18:59 UTC 2017
compilerplugins/clang/oncevar.cxx | 6 +++++-
compilerplugins/clang/test/oncevar.cxx | 12 ++++++------
editeng/qa/unit/core-test.cxx | 2 +-
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 3 +--
lingucomponent/source/languageguessing/guesslang.cxx | 3 +--
solenv/CompilerTest_compilerplugins_clang.mk | 1 +
tools/source/stream/stream.cxx | 3 +--
xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx | 3 +--
xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx | 3 +--
xmlsecurity/qa/unit/signing/signing.cxx | 3 +--
xmlsecurity/source/component/documentdigitalsignatures.cxx | 9 +++------
xmlsecurity/source/helper/documentsignaturehelper.cxx | 12 ++++--------
xmlsecurity/source/helper/documentsignaturemanager.cxx | 5 ++---
xmlsecurity/source/helper/xmlsignaturehelper.cxx | 9 +++------
xmlsecurity/source/xmlsec/nss/nssinitializer.cxx | 3 +--
15 files changed, 32 insertions(+), 45 deletions(-)
New commits:
commit 71112060e0930fc58087c3762e836b1e12b60f75
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Tue Jun 13 10:27:38 2017 +0200
loplugin:oncevar various
Change-Id: I8b82d46d4688b1a59d6fe1b05da7d5c8dfc13ca6
Reviewed-on: https://gerrit.libreoffice.org/38766
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/compilerplugins/clang/oncevar.cxx b/compilerplugins/clang/oncevar.cxx
index 9d03512012c1..1fa6cd53acf0 100644
--- a/compilerplugins/clang/oncevar.cxx
+++ b/compilerplugins/clang/oncevar.cxx
@@ -63,6 +63,10 @@ public:
// TODO taking local reference to variable
if (fn == SRCDIR "/sc/source/filter/excel/xechart.cxx")
return;
+ // macros managing to generate to a valid warning
+ if (fn == SRCDIR "/solenv/bin/concat-deps.c")
+ return;
+
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
for (auto const & varDecl : maVarDeclSet)
@@ -272,7 +276,7 @@ bool OnceVar::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
return true;
}
-loplugin::Plugin::Registration< OnceVar > X("oncevar", false);
+loplugin::Plugin::Registration< OnceVar > X("oncevar", true);
}
diff --git a/compilerplugins/clang/test/oncevar.cxx b/compilerplugins/clang/test/oncevar.cxx
index 214293f185e5..32ff42d4479d 100644
--- a/compilerplugins/clang/test/oncevar.cxx
+++ b/compilerplugins/clang/test/oncevar.cxx
@@ -11,12 +11,12 @@
/*int foo() { return 1; }*/
-void call_value(int); // expected-error {{extern prototype in main file without definition [loplugin:externandnotdefined]}}
-void call_const_ref(int const &); // expected-error {{extern prototype in main file without definition [loplugin:externandnotdefined]}}
-void call_ref(int &); // expected-error {{extern prototype in main file without definition [loplugin:externandnotdefined]}}
-void call_value(OUString); // expected-error {{extern prototype in main file without definition [loplugin:externandnotdefined]}}
-void call_const_ref(OUString const &); // expected-error {{extern prototype in main file without definition [loplugin:externandnotdefined]}}
-void call_ref(OUString &); // expected-error {{extern prototype in main file without definition [loplugin:externandnotdefined]}}
+void call_value(int);
+void call_const_ref(int const &);
+void call_ref(int &);
+void call_value(OUString);
+void call_const_ref(OUString const &);
+void call_ref(OUString &);
int main() {
/* TODO
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 0ae12f9bcd70..637342ddf13a 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -402,7 +402,7 @@ void Test::testAutocorrect()
// consider field contents as text for auto quotes
{
OUString sInput("T\x01");
- sal_Unicode cNextChar('"');
+ sal_Unicode const cNextChar('"');
const sal_Unicode EXPECTED[] = { 'T', 0x01, 0x0201d };
OUString sExpected(EXPECTED, SAL_N_ELEMENTS(EXPECTED));
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 88b5ec5d8016..3d9301b7549f 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -1843,9 +1843,8 @@ static void openDocumentCallback (GObject* source_object, GAsyncResult* res, gpo
if (!lok_doc_view_open_document_finish(pDocView, res, &error))
{
- GtkDialogFlags eFlags = GTK_DIALOG_DESTROY_WITH_PARENT;
GtkWidget* pDialog = gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))),
- eFlags,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Error occurred while opening the document: '%s'",
diff --git a/lingucomponent/source/languageguessing/guesslang.cxx b/lingucomponent/source/languageguessing/guesslang.cxx
index 556779504f75..85e041813205 100644
--- a/lingucomponent/source/languageguessing/guesslang.cxx
+++ b/lingucomponent/source/languageguessing/guesslang.cxx
@@ -194,9 +194,8 @@ void LangGuess_Impl::SetFingerPrintsDB(
{
//! text encoding for file name / path needs to be in the same encoding the OS uses
OString path = OUStringToOString( filePath, osl_getThreadTextEncoding() );
- OString conf_file_name( DEFAULT_CONF_FILE_NAME );
OString conf_file_path(path);
- conf_file_path += conf_file_name;
+ conf_file_path += DEFAULT_CONF_FILE_NAME;
m_aGuesser.SetDBPath(conf_file_path.getStr(), path.getStr());
}
diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk
index f1cfe08a1916..193d19271f3f 100644
--- a/solenv/CompilerTest_compilerplugins_clang.mk
+++ b/solenv/CompilerTest_compilerplugins_clang.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
compilerplugins/clang/test/externvar \
compilerplugins/clang/test/finalprotected \
compilerplugins/clang/test/loopvartoosmall \
+ compilerplugins/clang/test/oncevar \
compilerplugins/clang/test/oslendian-1 \
compilerplugins/clang/test/oslendian-2 \
compilerplugins/clang/test/oslendian-3 \
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index db90b56d41fe..cdfac8273470 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -734,8 +734,7 @@ void SvStream::StartWritingUnicodeText()
// BOM, Byte Order Mark, U+FEFF, see
// http://www.unicode.org/faq/utf_bom.html#BOM
// Upon read: 0xfeff(-257) => no swap; 0xfffe(-2) => swap
- sal_uInt16 v = 0xfeff;
- writeNumberWithoutSwap(v); // write native format
+ writeNumberWithoutSwap(sal_uInt16(0xfeff)); // write native format
}
void SvStream::StartReadingUnicodeText( rtl_TextEncoding eReadBomCharSet )
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
index c7045c391210..34605f5010df 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
@@ -1596,8 +1596,7 @@ void ButtonElement::endElement()
sal_Bool bChecked = false;
if (getBoolAttr( &bChecked, "checked", _xAttributes, m_xImport->XMLNS_DIALOGS_UID ) && bChecked)
{
- sal_Int16 nVal = 1;
- ctx.getControlModel()->setPropertyValue( "State" , makeAny( nVal ) );
+ ctx.getControlModel()->setPropertyValue( "State" , makeAny( sal_Int16(1) ) );
}
ctx.importEvents( _events );
diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
index 59ff206e2c28..89ba2751062d 100644
--- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
+++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
@@ -425,8 +425,7 @@ void PDFSigningTest::testTokenize()
// Just make sure the tokenizer finishes without an error, don't look at the signature.
CPPUNIT_ASSERT(aDocument.Read(aStream));
- OUString aNoPages("tdf107149.pdf");
- if (aNoPages == rName)
+ if (OUString(rName) == "tdf107149.pdf")
// This failed, page list was empty.
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aDocument.GetPages().size());
}
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx
index 95fb711a3596..729670dab027 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -353,8 +353,7 @@ void SigningTest::testOOXMLRemoveAll()
CPPUNIT_ASSERT(!xNameAccess->hasByName("_xmlsignatures"));
// And that content types no longer contains signature types.
- sal_Int32 nOpenMode = embed::ElementModes::READWRITE;
- uno::Reference<io::XStream> xStream(xStorage->openStreamElement("[Content_Types].xml", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XStream> xStream(xStorage->openStreamElement("[Content_Types].xml", embed::ElementModes::READWRITE), uno::UNO_QUERY);
uno::Reference<io::XInputStream> xInputStream = xStream->getInputStream();
uno::Sequence< uno::Sequence<beans::StringPair> > aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xInputStream, mxComponentContext);
uno::Sequence<beans::StringPair>& rOverrides = aContentTypeInfo[1];
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index 518b4acb1c93..6cec7f5a9c8e 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -400,8 +400,7 @@ void DocumentDigitalSignatures::manageTrustedSources( )
Reference< css::xml::crypto::XSecurityEnvironment > xSecEnv;
- DocumentSignatureMode eMode{};
- DocumentSignatureManager aSignatureManager(mxCtx, eMode);
+ DocumentSignatureManager aSignatureManager(mxCtx, {});
if (aSignatureManager.init())
xSecEnv = aSignatureManager.getSecurityEnvironment();
@@ -412,8 +411,7 @@ void DocumentDigitalSignatures::manageTrustedSources( )
void DocumentDigitalSignatures::showCertificate(
const Reference< css::security::XCertificate >& Certificate )
{
- DocumentSignatureMode eMode{};
- DocumentSignatureManager aSignatureManager(mxCtx, eMode);
+ DocumentSignatureManager aSignatureManager(mxCtx, {});
bool bInit = aSignatureManager.init();
@@ -454,8 +452,7 @@ Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertif
{
std::vector< Reference< css::xml::crypto::XXMLSecurityContext > > xSecContexts;
- DocumentSignatureMode eMode{};
- DocumentSignatureManager aSignatureManager(mxCtx, eMode);
+ DocumentSignatureManager aSignatureManager(mxCtx, {});
if (aSignatureManager.init()) {
xSecContexts.push_back(aSignatureManager.getSecurityContext());
xSecContexts.push_back(aSignatureManager.getGpgSecurityContext());
diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx
index fadf1a6309b2..1eecea496128 100644
--- a/xmlsecurity/source/helper/documentsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx
@@ -139,13 +139,12 @@ bool DocumentSignatureHelper::isODFPre_1_2(const OUString & sVersion)
bool DocumentSignatureHelper::isOOo3_2_Signature(const SignatureInformation & sigInfo)
{
- OUString sManifestURI("META-INF/manifest.xml");
bool bOOo3_2 = false;
typedef ::std::vector< SignatureReferenceInformation >::const_iterator CIT;
for (CIT i = sigInfo.vSignatureReferenceInfors.begin();
i < sigInfo.vSignatureReferenceInfors.end(); ++i)
{
- if (i->ouURI.equals(sManifestURI))
+ if (i->ouURI == "META-INF/manifest.xml")
{
bOOo3_2 = true;
break;
@@ -223,14 +222,13 @@ DocumentSignatureHelper::CreateElementList(
xSubStore.clear();
// Object folders...
- OUString aMatchStr( "Object " );
Reference < css::container::XNameAccess > xElements( rxStore, UNO_QUERY );
Sequence< OUString > aElementNames = xElements->getElementNames();
sal_Int32 nElements = aElementNames.getLength();
const OUString* pNames = aElementNames.getConstArray();
for ( sal_Int32 n = 0; n < nElements; n++ )
{
- if ( ( pNames[n].match( aMatchStr ) ) && rxStore->isStorageElement( pNames[n] ) )
+ if ( ( pNames[n].match( "Object " ) ) && rxStore->isStorageElement( pNames[n] ) )
{
Reference < css::embed::XStorage > xTmpSubStore = rxStore->openStorageElement( pNames[n], css::embed::ElementModes::READ );
ImplFillElementList(aElements, xTmpSubStore, pNames[n]+aSep, true, mode);
@@ -305,8 +303,7 @@ void DocumentSignatureHelper::AppendContentTypes(const uno::Reference<embed::XSt
// ODF
return;
- sal_Int32 nOpenMode = embed::ElementModes::READ;
- uno::Reference<io::XInputStream> xRelStream(xStorage->openStreamElement("[Content_Types].xml", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XInputStream> xRelStream(xStorage->openStreamElement("[Content_Types].xml", embed::ElementModes::READ), uno::UNO_QUERY);
uno::Sequence< uno::Sequence<beans::StringPair> > aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xRelStream, comphelper::getProcessComponentContext());
if (aContentTypeInfo.getLength() < 2)
{
@@ -362,8 +359,7 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream(
{
try
{
- OUString aSIGStoreName( "META-INF" );
- aHelper.xSignatureStorage = rxStore->openStorageElement( aSIGStoreName, nSubStorageOpenMode );
+ aHelper.xSignatureStorage = rxStore->openStorageElement( "META-INF", nSubStorageOpenMode );
if ( aHelper.xSignatureStorage.is() )
{
OUString aSIGStreamName;
diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx
index 41f7e5594cf2..01bcbc0dab9f 100644
--- a/xmlsecurity/source/helper/documentsignaturemanager.cxx
+++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx
@@ -162,12 +162,11 @@ bool DocumentSignatureManager::isXML(const OUString& rURI)
//Files can only be encrypted if they are in the manifest.xml.
//That is, the current file cannot be encrypted, otherwise bPropsAvailable
//would be true.
- OUString aXMLExt("XML");
sal_Int32 nSep = rURI.lastIndexOf('.');
- if (nSep != (-1))
+ if (nSep != -1)
{
OUString aExt = rURI.copy(nSep+1);
- if (aExt.equalsIgnoreAsciiCase(aXMLExt))
+ if (aExt.equalsIgnoreAsciiCase("XML"))
bIsXML = true;
}
}
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index 6242518ce4e1..b6078d373916 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -201,8 +201,7 @@ void XMLSignatureHelper::ExportSignature(
void XMLSignatureHelper::ExportOOXMLSignature(const uno::Reference<embed::XStorage>& xRootStorage, const uno::Reference<embed::XStorage>& xSignatureStorage, const SignatureInformation& rInformation, int nSignatureIndex)
{
- sal_Int32 nOpenMode = embed::ElementModes::READWRITE;
- uno::Reference<io::XOutputStream> xOutputStream(xSignatureStorage->openStreamElement("sig" + OUString::number(nSignatureIndex) + ".xml", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XOutputStream> xOutputStream(xSignatureStorage->openStreamElement("sig" + OUString::number(nSignatureIndex) + ".xml", embed::ElementModes::READWRITE), uno::UNO_QUERY);
if (rInformation.aSignatureBytes.hasElements())
// This is a signature roundtrip, just write back the signature as-is.
@@ -504,8 +503,7 @@ void XMLSignatureHelper::ExportSignatureRelations(const css::uno::Reference<css:
void XMLSignatureHelper::ExportSignatureContentTypes(const css::uno::Reference<css::embed::XStorage>& xStorage, int nSignatureCount)
{
- sal_Int32 nOpenMode = embed::ElementModes::READWRITE;
- uno::Reference<io::XStream> xStream(xStorage->openStreamElement("[Content_Types].xml", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XStream> xStream(xStorage->openStreamElement("[Content_Types].xml", embed::ElementModes::READWRITE), uno::UNO_QUERY);
uno::Reference<io::XInputStream> xInputStream = xStream->getInputStream();
uno::Sequence< uno::Sequence<beans::StringPair> > aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xInputStream, mxCtx);
if (aContentTypeInfo.getLength() < 2)
@@ -554,8 +552,7 @@ void XMLSignatureHelper::ExportSignatureContentTypes(const css::uno::Reference<c
}
bool XMLSignatureHelper::CreateAndWriteOOXMLSignature(const uno::Reference<embed::XStorage>& xRootStorage, const uno::Reference<embed::XStorage>& xSignatureStorage, int nSignatureIndex)
{
- sal_Int32 nOpenMode = embed::ElementModes::READWRITE;
- uno::Reference<io::XOutputStream> xOutputStream(xSignatureStorage->openStreamElement("sig" + OUString::number(nSignatureIndex) + ".xml", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XOutputStream> xOutputStream(xSignatureStorage->openStreamElement("sig" + OUString::number(nSignatureIndex) + ".xml", embed::ElementModes::READWRITE), uno::UNO_QUERY);
uno::Reference<xml::sax::XWriter> xSaxWriter = xml::sax::Writer::create(mxCtx);
xSaxWriter->setOutputStream(xOutputStream);
xSaxWriter->startDocument();
diff --git a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
index 44ed6971f65d..f4f5a7212373 100644
--- a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
+++ b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
@@ -186,7 +186,6 @@ OString getMozillaCurrentProfile( const css::uno::Reference< css::uno::XComponen
mozilla::MozillaProductType_Thunderbird,
mozilla::MozillaProductType_Firefox,
mozilla::MozillaProductType_Mozilla };
- int nProduct = SAL_N_ELEMENTS(productTypes);
uno::Reference<uno::XInterface> xInstance = rxContext->getServiceManager()->createInstanceWithContext("com.sun.star.mozilla.MozillaBootstrap", rxContext);
OSL_ENSURE( xInstance.is(), "failed to create instance" );
@@ -196,7 +195,7 @@ OString getMozillaCurrentProfile( const css::uno::Reference< css::uno::XComponen
if (xMozillaBootstrap.is())
{
- for (int i=0; i<nProduct; ++i)
+ for (int i=0; i<int(SAL_N_ELEMENTS(productTypes)); ++i)
{
OUString profile = xMozillaBootstrap->getDefaultProfile(productTypes[i]);
More information about the Libreoffice-commits
mailing list