From 9b4871054d01a47b4c546952a0948553413840d6 Mon Sep 17 00:00:00 2001 From: erik Date: Mon, 22 Jan 2007 22:56:12 +0000 Subject: Every file in this commit makes a call to a function which returns a value. Each file also didn't check the return value. This commit changes it so that every single non-checked call in these files is checked. --- (limited to 'noncore/apps') diff --git a/noncore/apps/opie-console/filereceive.cpp b/noncore/apps/opie-console/filereceive.cpp index 452be60..41e6888 100644 --- a/noncore/apps/opie-console/filereceive.cpp +++ b/noncore/apps/opie-console/filereceive.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "io_layer.h" @@ -148,7 +149,8 @@ void FileReceive::slotRead() { } void FileReceive::slotExec() { char buf[2]; - ::read(m_term[0], buf, 1 ); + if (::read(m_term[0], buf, 1 ) == -1) + owarn << "read of m_term[0] failed" << oendl; delete m_proc; delete m_not; m_not = m_proc = 0l; diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp index 7eebc65..6e2d2d5 100644 --- a/noncore/apps/opie-console/filetransfer.cpp +++ b/noncore/apps/opie-console/filetransfer.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include "procctl.h" @@ -234,7 +235,8 @@ void FileTransfer::cancel() { } void FileTransfer::slotExec() { char buf[2]; - ::read(m_term[0], buf, 1 ); + if (::read(m_term[0], buf, 1 ) == -1) + owarn << "read of m_term[0] failed" << oendl; delete m_proc; delete m_not; m_proc = m_not = 0l; diff --git a/noncore/apps/opie-console/logger.cpp b/noncore/apps/opie-console/logger.cpp index 6620faf..0fdeca0 100644 --- a/noncore/apps/opie-console/logger.cpp +++ b/noncore/apps/opie-console/logger.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "logger.h" @@ -8,7 +9,8 @@ Logger::Logger() {} Logger::Logger(const QString fileName) { m_file.setName(fileName); - m_file.open(IO_ReadWrite); + if ( !m_file.open(IO_ReadWrite) ) + owarn << "failed to open " << m_file.name() << oendl; } Logger::~Logger() { diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 18c0434..aba7244 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -824,7 +824,8 @@ void MainWindow::slotSaveHistory() { QFile file(filename); - file.open(IO_WriteOnly ); + if ( !file.open(IO_WriteOnly ) ) return; + QTextStream str(&file ); if ( currentSession() ) currentSession()->emulationHandler()->emulation()->streamHistory(&str); diff --git a/noncore/apps/opie-console/script.cpp b/noncore/apps/opie-console/script.cpp index faea412..8d35776 100644 --- a/noncore/apps/opie-console/script.cpp +++ b/noncore/apps/opie-console/script.cpp @@ -6,13 +6,15 @@ Script::Script() { Script::Script(const QString fileName) { QFile file(fileName); - file.open(IO_ReadOnly ); + if ( !file.open(IO_ReadOnly ) ) + return; m_script = file.readAll(); } void Script::saveTo(const QString fileName) const { QFile file(fileName); - file.open(IO_WriteOnly); + if ( !file.open(IO_WriteOnly) ) + return; file.writeBlock(m_script); file.close(); } diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp index 733db17..8b02f9f 100644 --- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp +++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp @@ -845,22 +845,16 @@ bool Gutenbrowser::load( const char *fileName) { } // end load void Gutenbrowser::Search() { - - // if( searchDlg->isHidden()) - { - odebug << "Starting search dialog" << oendl; - searchDlg = new SearchDialog( this, "Etext Search", true); - searchDlg->setCaption( tr( "Etext Search" )); - // searchDlg->setLabel( "- searches etext"); - connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); - connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); - - QString resultString; - QString string = searchDlg->searchString; - Lview->deselect(); - searchDlg->show(); - searchDlg->result(); - } + odebug << "Starting search dialog" << oendl; + searchDlg = new SearchDialog( this, "Etext Search", true); + searchDlg->setCaption( tr( "Etext Search" )); + connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); + connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); + + QString resultString; + QString string = searchDlg->searchString; + Lview->deselect(); + searchDlg->show(); } void Gutenbrowser::search_slot( ) { diff --git a/noncore/apps/opie-gutenbrowser/helpwindow.cpp b/noncore/apps/opie-gutenbrowser/helpwindow.cpp index 4bdac02..f444a2e 100644 --- a/noncore/apps/opie-gutenbrowser/helpwindow.cpp +++ b/noncore/apps/opie-gutenbrowser/helpwindow.cpp @@ -193,36 +193,29 @@ HelpWindow::~HelpWindow() history.clear(); QMap::Iterator it = mHistory.begin(); for ( ; it != mHistory.end(); ++it ) - history.append( *it ); + history.append( *it ); QFile f( QDir::currentDirPath() + "/.history" ); - f.open( IO_WriteOnly ); - QDataStream s( &f ); - s << history; - f.close(); + if ( f.open( IO_WriteOnly ) ) { + QDataStream s( &f ); + s << history; + f.close(); + } bookmarks.clear(); QMap::Iterator it2 = mBookmarks.begin(); for ( ; it2 != mBookmarks.end(); ++it2 ) - bookmarks.append( *it2 ); + bookmarks.append( *it2 ); QFile f2( QDir::currentDirPath() + "/.bookmarks" ); - f2.open( IO_WriteOnly ); + if ( !f2.open( IO_WriteOnly ) ) + return; + QDataStream s2( &f2 ); s2 << bookmarks; f2.close(); } -// void HelpWindow::about() -// { -// QMessageBox::about( this, "Gutenbrowser", "

Thanks to Trolltech for this

" ); -// } - -// void HelpWindow::aboutQt() -// { -// QMessageBox::aboutQt( this, "QBrowser" ); -// } - void HelpWindow::openFile() { #ifndef QT_NO_FILEDIALOG @@ -292,26 +285,31 @@ void HelpWindow::pathSelected( const QString &_path ) void HelpWindow::readHistory() { - if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { - QFile f( QDir::currentDirPath() + "/.history" ); - f.open( IO_ReadOnly ); - QDataStream s( &f ); - s >> history; - f.close(); - while ( history.count() > 20 ) - history.remove( history.begin() ); - } + if ( !QFile::exists( QDir::currentDirPath() + "/.history" ) ) + return; + + QFile f( QDir::currentDirPath() + "/.history" ); + if ( !f.open( IO_ReadOnly ) ) + return; + + QDataStream s( &f ); + s >> history; + f.close(); + while ( history.count() > 20 ) + history.remove( history.begin() ); } void HelpWindow::readBookmarks() { - if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { - QFile f( QDir::currentDirPath() + "/.bookmarks" ); - f.open( IO_ReadOnly ); - QDataStream s( &f ); - s >> bookmarks; - f.close(); - } + if ( !QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) + return; + + QFile f( QDir::currentDirPath() + "/.bookmarks" ); + if ( !f.open( IO_ReadOnly ) ) + return; + QDataStream s( &f ); + s >> bookmarks; + f.close(); } void HelpWindow::histChosen( int i ) -- cgit v0.9.0.2