From 2a215927cef95de29f36622b6a34aab474c8e646 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Wed, 31 Oct 2012 17:58:35 +0400 Subject: [PATCH] Fix some warnings --- aard.cc | 22 +++++++++++----------- article_maker.cc | 8 +++++++- articleview.cc | 2 +- btreeidx.cc | 2 +- config.hh | 2 +- dictinfo.cc | 1 + dictzip.c | 2 ++ dsl.cc | 18 +++++++++++++++--- dsl_details.cc | 13 +++++++++++-- externalviewer.cc | 2 +- forvo.cc | 8 +++++++- hotkeywrapper.cc | 1 + hunspell.cc | 8 +++++++- indexedzip.cc | 2 +- langcoder.cc | 1 - maintabwidget.cc | 3 +++ mediawiki.cc | 9 ++++++++- mouseover.cc | 9 ++++++--- mruqmenu.cc | 1 + sdict.cc | 2 +- stardict.cc | 2 +- transliteration.cc | 2 +- uiauto.hh | 4 ++++ wordbyauto.cc | 2 +- xdxf.cc | 5 +++-- zipfile.cc | 2 +- zipsounds.cc | 1 + 27 files changed, 98 insertions(+), 36 deletions(-) diff --git a/aard.cc b/aard.cc index d43735b5..f043ff64 100644 --- a/aard.cc +++ b/aard.cc @@ -223,36 +223,36 @@ map< string, string > parseMetaData( string const & metaData ) string name, value; string::size_type n = 0; - while( metaData[n] != '{' && n < metaData.length() ) + while( n < metaData.length() && metaData[n] != '{' ) n++; while( n < metaData.length() ) { // Skip to '"' - while( metaData[n] != '\"' && n < metaData.length() ) + while( n < metaData.length() && metaData[n] != '\"' ) n++; if( ++n >= metaData.length() ) break; // Read name - while( !( ( metaData[n] == '\"' || metaData[n] == '{' ) && metaData[n-1] != '\\' ) - && n < metaData.length() ) + while( n < metaData.length() && + !( ( metaData[n] == '\"' || metaData[n] == '{' ) && metaData[n-1] != '\\' ) ) name.push_back( metaData[n++]); // Skip to ':' if( ++n >= metaData.length() ) break; - while( metaData[n] != ':' && n < metaData.length() ) + while( n < metaData.length() && metaData[n] != ':' ) n++; if( ++n >= metaData.length() ) break; // Find value start after ':' - while( !( ( metaData[n] == '\"' - || metaData[n] == '{' - || metaData[n] == '[' - || ( metaData[n] >= '0' && metaData[n] <= '9' ) ) - && metaData[n-1] != '\\' ) - && n < metaData.length() ) + while( n < metaData.length() + && !( ( metaData[n] == '\"' + || metaData[n] == '{' + || metaData[n] == '[' + || ( metaData[n] >= '0' && metaData[n] <= '9' ) ) + && metaData[n-1] != '\\' ) ) n++; if( n >= metaData.length() ) break; diff --git a/article_maker.cc b/article_maker.cc index ca52faa9..5a551b2e 100644 --- a/article_maker.cc +++ b/article_maker.cc @@ -340,7 +340,13 @@ void ArticleRequest::altSearchFinished() for( unsigned x = 0; x < altsVector.size(); ++x ) { - DPRINTF( "Alt: %ls\n", altsVector[ x ].c_str() ); + DPRINTF( "Alt: %ls\n", +#ifdef Q_OS_WIN + gd::toQString( altsVector[ x ] ).toStdWString().c_str() +#else + altsVector[ x ].c_str() +#endif + ); } wstring wordStd = gd::toWString( word ); diff --git a/articleview.cc b/articleview.cc index 485a95db..65d8f6c0 100644 --- a/articleview.cc +++ b/articleview.cc @@ -1274,7 +1274,7 @@ void ArticleView::resourceDownloadFinished() QTemporaryFile tmp( QDir::temp().filePath( "XXXXXX-" + resourceDownloadUrl.path().section( '/', -1 ) ), this ); - if ( !tmp.open() || tmp.write( &data.front(), data.size() ) != data.size() ) + if ( !tmp.open() || (size_t) tmp.write( &data.front(), data.size() ) != data.size() ) { QMessageBox::critical( this, tr( "GoldenDict" ), tr( "Failed to create temporary file." ) ); return; diff --git a/btreeidx.cc b/btreeidx.cc index 2526b341..aea9adf6 100644 --- a/btreeidx.cc +++ b/btreeidx.cc @@ -1032,7 +1032,7 @@ IndexInfo buildIndex( IndexedWords const & indexedWords, File::Class & file ) if ( btreeMaxElements > BtreeMaxElements ) btreeMaxElements = BtreeMaxElements; - DPRINTF( "Building a tree of %u elements\n", btreeMaxElements ); + DPRINTF( "Building a tree of %u elements\n", (unsigned) btreeMaxElements ); uint32_t lastLeafOffset = 0; diff --git a/config.hh b/config.hh index 6a24f1e6..076d42c4 100644 --- a/config.hh +++ b/config.hh @@ -90,7 +90,7 @@ struct Group dictionaries == other.dictionaries && shortcut == other.shortcut && mutedDictionaries == other.mutedDictionaries && popupMutedDictionaries == other.popupMutedDictionaries && - iconData == iconData; } + iconData == other.iconData; } bool operator != ( Group const & other ) const { return ! operator == ( other ); } diff --git a/dictinfo.cc b/dictinfo.cc index d579b051..ce2b2fba 100644 --- a/dictinfo.cc +++ b/dictinfo.cc @@ -7,6 +7,7 @@ DictInfo::DictInfo( Config::Class &cfg_, QWidget *parent ) : cfg( cfg_) { + (void) parent; ui.setupUi( this ); if( cfg.dictInfoGeometry.size() > 0 ) restoreGeometry( cfg.dictInfoGeometry ); diff --git a/dictzip.c b/dictzip.c index 981f804d..9d349e05 100644 --- a/dictzip.c +++ b/dictzip.c @@ -502,6 +502,8 @@ char *dict_data_read_ ( dictData *h, unsigned long start, unsigned long size, const char *preFilter, const char *postFilter ) { + (void) preFilter; + (void) postFilter; char *buffer, *pt; unsigned long end; int count; diff --git a/dsl.cc b/dsl.cc index 0a30e541..137293a5 100644 --- a/dsl.cc +++ b/dsl.cc @@ -1480,7 +1480,13 @@ vector< sptr< Dictionary::Class > > makeDictionaries( // Building the index initializing.indexingDictionary( Utf8::encode( scanner.getDictionaryName() ) ); - DPRINTF( "Dictionary name: %ls\n", scanner.getDictionaryName().c_str() ); + DPRINTF( "Dictionary name: %ls\n", +#ifdef Q_OS_WIN + gd::toQString( scanner.getDictionaryName() ).toStdWString().c_str() +#else + scanner.getDictionaryName().c_str() +#endif + ); File::Class idx( indexFile, "wb" ); @@ -1627,7 +1633,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( { if ( !isDslWs( curString[ x ] ) ) { - FDPRINTF( stderr, "Warning: garbage string in %s at offset 0x%X\n", i->c_str(), curOffset ); + FDPRINTF( stderr, "Warning: garbage string in %s at offset 0x%lX\n", i->c_str(), (unsigned long) curOffset ); break; } } @@ -1662,7 +1668,13 @@ vector< sptr< Dictionary::Class > > makeDictionaries( if ( isDslWs( curString[ 0 ] ) ) break; // No more headwords - DPRINTF( "Alt headword: %ls\n", curString.c_str() ); + DPRINTF( "Alt headword: %ls\n", +#ifdef Q_OS_WIN + gd::toQString( curString ).toStdWString().c_str() +#else + curString.c_str() +#endif + ); processUnsortedParts( curString, true ); expandTildes( curString, allEntryWords.front() ); diff --git a/dsl_details.cc b/dsl_details.cc index a2b14cb3..20f3c710 100644 --- a/dsl_details.cc +++ b/dsl_details.cc @@ -9,6 +9,10 @@ #include "dprintf.hh" #include "ufile.hh" +#ifdef Q_OS_WIN +#include "wstring_qt.hh" +#endif + namespace Dsl { namespace Details { @@ -381,7 +385,7 @@ ArticleDom::ArticleDom( wstring const & str ): stack.pop_back(); if ( stack.size() ) - FDPRINTF( stderr, "Warning: %u tags were unclosed.\n", stack.size() ); + FDPRINTF( stderr, "Warning: %u tags were unclosed.\n", (unsigned) stack.size() ); } void ArticleDom::closeTag( wstring const & name, @@ -455,7 +459,12 @@ void ArticleDom::closeTag( wstring const & name, if ( warn ) { FDPRINTF( stderr, "Warning: no corresponding opening tag for closing tag \"/%ls\" found.\n", - name.c_str() ); +#ifdef Q_OS_WIN + gd::toQString( name ).toStdWString().c_str() +#else + name.c_str() +#endif + ); } } diff --git a/externalviewer.cc b/externalviewer.cc index 00407f8b..034333b6 100644 --- a/externalviewer.cc +++ b/externalviewer.cc @@ -17,7 +17,7 @@ ExternalViewer::ExternalViewer( QObject * parent, vector< char > const & data, viewer( this ), viewerCmdLine( viewerCmdLine_ ) { - if ( !tempFile.open() || tempFile.write( &data.front(), data.size() ) != data.size() ) + if ( !tempFile.open() || (size_t) tempFile.write( &data.front(), data.size() ) != data.size() ) throw exCantCreateTempFile(); tempFileName = tempFile.fileName(); // For some reason it loses it after it was closed() diff --git a/forvo.cc b/forvo.cc index c211d41e..be74f17b 100644 --- a/forvo.cc +++ b/forvo.cc @@ -146,7 +146,13 @@ ForvoArticleRequest::ForvoArticleRequest( wstring const & str, void ForvoArticleRequest::addQuery( QNetworkAccessManager & mgr, wstring const & str ) { - DPRINTF( "Requesting article %ls\n", str.c_str() ); + DPRINTF( "Requesting article %ls\n", +#ifdef Q_OS_WIN + gd::toQString( str ).toStdWString().c_str() +#else + str.c_str() +#endif + ); QString key; diff --git a/hotkeywrapper.cc b/hotkeywrapper.cc index 7bfe5556..b07c7f3c 100644 --- a/hotkeywrapper.cc +++ b/hotkeywrapper.cc @@ -214,6 +214,7 @@ bool HotkeyWrapper::setGlobalKey( int key, int key2, bool HotkeyWrapper::winEvent ( MSG * message, long * result ) { + (void) result; if (message->message == WM_HOTKEY) return checkState( (message->lParam >> 16), (message->lParam & 0xffff) ); diff --git a/hunspell.cc b/hunspell.cc index 5d4e609c..82d952c8 100644 --- a/hunspell.cc +++ b/hunspell.cc @@ -470,7 +470,13 @@ QVector< wstring > HunspellHeadwordsRequest::suggest( wstring & word ) if ( Folding::applySimpleCaseOnly( alt ) != lowercasedWord ) // No point in providing same word { - DPRINTF( ">>>>>Alt: %ls\n", alt.c_str() ); + DPRINTF( ">>>>>Alt: %ls\n", +#ifdef Q_OS_WIN + gd::toQString( alt ).toStdWString().c_str() +#else + alt.c_str() +#endif + ); result.append( alt ); } } diff --git a/indexedzip.cc b/indexedzip.cc index 606e0875..f61fdb1b 100644 --- a/indexedzip.cc +++ b/indexedzip.cc @@ -68,7 +68,7 @@ bool IndexedZip::loadFile( uint32_t offset, vector< char > & data ) case ZipFile::Uncompressed: DPRINTF( "Uncompressed\n" ); data.resize( header.uncompressedSize ); - return zip.read( &data.front(), data.size() ) == data.size(); + return (size_t) zip.read( &data.front(), data.size() ) == data.size(); case ZipFile::Deflated: { diff --git a/langcoder.cc b/langcoder.cc index 7453dd52..13ff4576 100644 --- a/langcoder.cc +++ b/langcoder.cc @@ -10,7 +10,6 @@ LangCoder langCoder; LangCoder::LangCoder() { - LangStruct ls; for (int i = 0; true; i++) { const LangCode &lc = LangCodes[i]; if (lc.lang[0] == 0) diff --git a/maintabwidget.cc b/maintabwidget.cc index 2ca829cf..185d19ac 100644 --- a/maintabwidget.cc +++ b/maintabwidget.cc @@ -16,6 +16,7 @@ void MainTabWidget::setHideSingleTab(bool hide) void MainTabWidget::tabInserted(int index) { + (void) index; updateTabBarVisibility(); // Avoid bug in Qt 4.8.0 @@ -24,6 +25,7 @@ void MainTabWidget::tabInserted(int index) void MainTabWidget::tabRemoved(int index) { + (void) index; updateTabBarVisibility(); // Avoid bug in Qt 4.8.0 @@ -37,5 +39,6 @@ void MainTabWidget::updateTabBarVisibility() void MainTabWidget::mouseDoubleClickEvent ( QMouseEvent * event ) { + (void) event; emit doubleClicked(); } diff --git a/mediawiki.cc b/mediawiki.cc index cbf7467c..58dbebd0 100644 --- a/mediawiki.cc +++ b/mediawiki.cc @@ -220,7 +220,13 @@ MediaWikiArticleRequest::MediaWikiArticleRequest( wstring const & str, void MediaWikiArticleRequest::addQuery( QNetworkAccessManager & mgr, wstring const & str ) { - DPRINTF( "Requesting article %ls\n", str.c_str() ); + DPRINTF( "Requesting article %ls\n", +#ifdef Q_OS_WIN + gd::toQString( str ).toStdWString().c_str() +#else + str.c_str() +#endif + ); QUrl reqUrl( url + "/api.php?action=parse&prop=text|revid&format=xml&redirects" ); @@ -361,6 +367,7 @@ sptr< WordSearchRequest > MediaWikiDictionary::prefixMatch( wstring const & word unsigned long maxResults ) throw( std::exception ) { + (void) maxResults; if ( word.size() > 80 ) { // Don't make excessively large queries -- they're fruitless anyway diff --git a/mouseover.cc b/mouseover.cc index 539f4d8c..94f0fd2c 100644 --- a/mouseover.cc +++ b/mouseover.cc @@ -40,18 +40,21 @@ typedef BOOL WINAPI ( *ChangeWindowMessageFilterExFunc )( HWND, UINT, DWORD, PCH #ifdef Q_OS_WIN32 +#ifndef ConvertStringSecurityDescriptorToSecurityDescriptor + extern "C" BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorW( LPCWSTR StringSecurityDescriptor, DWORD StringSDRevision, PSECURITY_DESCRIPTOR *SecurityDescriptor, PULONG SecurityDescriptorSize ); +#endif static void SetLowLabelToGDSynchroObjects() { // The LABEL_SECURITY_INFORMATION SDDL SACL to be set for low integrity #define LOW_INTEGRITY_SDDL_SACL_W L"S:(ML;;NW;;;LW)" - DWORD dwErr = ERROR_SUCCESS; +// DWORD dwErr = ERROR_SUCCESS; PSECURITY_DESCRIPTOR pSD = NULL; PACL pSacl = NULL; // not allocated @@ -67,10 +70,10 @@ static void SetLowLabelToGDSynchroObjects() // Note that psidOwner, psidGroup, and pDacl are // all NULL and set the new LABEL_SECURITY_INFORMATION - dwErr = SetNamedSecurityInfoW( (LPWSTR)pwszMapFileName, + /* dwErr = */ SetNamedSecurityInfoW( (LPWSTR)pwszMapFileName, SE_KERNEL_OBJECT, LABEL_SECURITY_INFORMATION, NULL, NULL, NULL, pSacl); - dwErr = SetNamedSecurityInfoW( (LPWSTR)pwszSpyMutexName, + /* dwErr = */ SetNamedSecurityInfoW( (LPWSTR)pwszSpyMutexName, SE_KERNEL_OBJECT, LABEL_SECURITY_INFORMATION, NULL, NULL, NULL, pSacl); } diff --git a/mruqmenu.cc b/mruqmenu.cc index 95efee08..e505880f 100644 --- a/mruqmenu.cc +++ b/mruqmenu.cc @@ -9,6 +9,7 @@ MRUQMenu::MRUQMenu(const QString title, QWidget *parent): bool MRUQMenu::eventFilter(QObject *obj, QEvent *event) { + (void) obj; if (event->type() == QEvent::KeyRelease){ QKeyEvent *keyevent = static_cast(event); if (keyevent->key() == Qt::Key_Control){ diff --git a/sdict.cc b/sdict.cc index 555c10d2..2e88a06b 100644 --- a/sdict.cc +++ b/sdict.cc @@ -664,7 +664,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( df.read( &el, sizeof(el) ); uint32_t articleOffset = dictHeader.articlesOffset + el.articleOffset; size = el.nextWord - sizeof(el); - if( size < 0 ) + if( el.nextWord < sizeof(el) ) break; wordCount++; data.resize( size ); diff --git a/stardict.cc b/stardict.cc index fc306d5f..140414e3 100644 --- a/stardict.cc +++ b/stardict.cc @@ -1111,7 +1111,7 @@ static void handleIdxSynFile( string const & fileName, indexedWords.addWord( Utf8::decode( word ), offset ); } - DPRINTF( "%u entires made\n", indexedWords.size() ); + DPRINTF( "%u entires made\n", (unsigned) indexedWords.size() ); } diff --git a/transliteration.cc b/transliteration.cc index a2ebf62b..2e370a77 100644 --- a/transliteration.cc +++ b/transliteration.cc @@ -119,7 +119,7 @@ sptr< Dictionary::WordSearchRequest > TransliterationDictionary::findHeadwordsFo vector< wstring > alts = getAlternateWritings( str ); - DPRINTF( "alts = %u\n", alts.size() ); + DPRINTF( "alts = %u\n", (unsigned) alts.size() ); for( unsigned x = 0; x < alts.size(); ++x ) result->getMatches().push_back( alts[ x ] ); diff --git a/uiauto.hh b/uiauto.hh index 5d7205bb..4e40ff48 100644 --- a/uiauto.hh +++ b/uiauto.hh @@ -118,6 +118,10 @@ const long UIA_ItemContainerPatternId = 10019; const long UIA_VirtualizedItemPatternId = 10020; const long UIA_SynchronizedInputPatternId = 10021; +#ifdef INTERFACE +#undef INTERFACE +#endif + #define INTERFACE IUIAutomation DECLARE_INTERFACE_(IUIAutomation, IUnknown) { diff --git a/wordbyauto.cc b/wordbyauto.cc index 4e8490e0..bc20309d 100644 --- a/wordbyauto.cc +++ b/wordbyauto.cc @@ -57,7 +57,7 @@ bool bGoUp; buffer[0] = 0; pElement = NULL; hr = pGDAutomation->ElementFromPoint( pt, &pElement ); - DPRINTF("ElementFromPoint return hr=%08X, ptr=%p\n", hr, pElement); + DPRINTF("ElementFromPoint return hr=%08lX, ptr=%p\n", hr, pElement); if( hr != S_OK || pElement == NULL ) return false; diff --git a/xdxf.cc b/xdxf.cc index 87468fc0..66c9f919 100644 --- a/xdxf.cc +++ b/xdxf.cc @@ -1295,8 +1295,9 @@ vector< sptr< Dictionary::Class > > makeDictionaries( if ( stream.hasError() ) { - DPRINTF( "Warning: %s had a parse error %ls at line %I64u, and therefore was indexed only up to the point of error.", - dictFiles[ 0 ].c_str(), stream.errorString().toStdWString().c_str(), stream.lineNumber() ); + DPRINTF( "Warning: %s had a parse error %ls at line %lu, and therefore was indexed only up to the point of error.", + dictFiles[ 0 ].c_str(), stream.errorString().toStdWString().c_str(), + (unsigned long) stream.lineNumber() ); } } diff --git a/zipfile.cc b/zipfile.cc index 78291b0b..70462268 100644 --- a/zipfile.cc +++ b/zipfile.cc @@ -60,7 +60,7 @@ bool positionAtCentralDir( QFile & zip ) if ( zip.size() > maxEofBufferSize ) zip.seek( zip.size() - maxEofBufferSize ); else - if ( zip.size() < sizeof( EndOfCdirRecord ) ) + if ( (size_t) zip.size() < sizeof( EndOfCdirRecord ) ) return false; else zip.seek( 0 ); diff --git a/zipsounds.cc b/zipsounds.cc index 52ec7e07..3f2b1af5 100644 --- a/zipsounds.cc +++ b/zipsounds.cc @@ -278,6 +278,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Dictionary::Initializing & initializing ) throw( std::exception ) { + (void) initializing; vector< sptr< Dictionary::Class > > dictionaries; for( vector< string >::const_iterator i = fileNames.begin(); i != fileNames.end();