Fix some warnings

This commit is contained in:
Abs62 2012-10-31 17:58:35 +04:00
parent 4951b7f6b2
commit 2a215927ce
27 changed files with 98 additions and 36 deletions

22
aard.cc
View file

@ -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;

View file

@ -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 );

View file

@ -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;

View file

@ -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;

View file

@ -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 ); }

View file

@ -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 );

View file

@ -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;

18
dsl.cc
View file

@ -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() );

View file

@ -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
);
}
}

View file

@ -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()

View file

@ -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;

View file

@ -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) );

View file

@ -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 );
}
}

View file

@ -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:
{

View file

@ -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)

View file

@ -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();
}

View file

@ -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

View file

@ -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);
}

View file

@ -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<QKeyEvent*>(event);
if (keyevent->key() == Qt::Key_Control){

View file

@ -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 );

View file

@ -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() );
}

View file

@ -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 ] );

View file

@ -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)
{

View file

@ -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;

View file

@ -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() );
}
}

View file

@ -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 );

View file

@ -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();