Kaydet (Commit) 71112060 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:oncevar various

Change-Id: I8b82d46d4688b1a59d6fe1b05da7d5c8dfc13ca6
Reviewed-on: https://gerrit.libreoffice.org/38766Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst d6da9e49
......@@ -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);
}
......
......@@ -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
......
......@@ -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));
......
......@@ -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'",
......
......@@ -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());
}
......
......@@ -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 \
......
......@@ -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 )
......
......@@ -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 );
......
......@@ -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());
}
......
......@@ -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];
......
......@@ -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());
......
......@@ -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;
......
......@@ -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;
}
}
......
......@@ -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();
......
......@@ -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]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment