author | erik <erik> | 2007-01-22 22:56:12 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-22 22:56:12 (UTC) |
commit | 9b4871054d01a47b4c546952a0948553413840d6 (patch) (unidiff) | |
tree | 4e0248489c2790cf4225a116cfb903b637d4cdf0 /noncore/apps/opie-console | |
parent | f60301bab1f8aa3693089036a3791a01ae6f9db8 (diff) | |
download | opie-9b4871054d01a47b4c546952a0948553413840d6.zip opie-9b4871054d01a47b4c546952a0948553413840d6.tar.gz opie-9b4871054d01a47b4c546952a0948553413840d6.tar.bz2 |
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.
-rw-r--r-- | noncore/apps/opie-console/filereceive.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/filetransfer.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/logger.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/script.cpp | 6 |
5 files changed, 15 insertions, 6 deletions
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 | |||
@@ -1,29 +1,30 @@ | |||
1 | #include <unistd.h> | 1 | #include <unistd.h> |
2 | #include <fcntl.h> | 2 | #include <fcntl.h> |
3 | #include <signal.h> | 3 | #include <signal.h> |
4 | #include <errno.h> | 4 | #include <errno.h> |
5 | 5 | ||
6 | #include <opie2/odebug.h> | ||
6 | #include <qsocketnotifier.h> | 7 | #include <qsocketnotifier.h> |
7 | 8 | ||
8 | #include "io_layer.h" | 9 | #include "io_layer.h" |
9 | #include "procctl.h" | 10 | #include "procctl.h" |
10 | #include "filereceive.h" | 11 | #include "filereceive.h" |
11 | 12 | ||
12 | FileReceive::FileReceive( Type t, IOLayer* lay, const QString& dir ) | 13 | FileReceive::FileReceive( Type t, IOLayer* lay, const QString& dir ) |
13 | : ReceiveLayer(lay, dir ), m_type( t ) | 14 | : ReceiveLayer(lay, dir ), m_type( t ) |
14 | { | 15 | { |
15 | m_fd = -1; | 16 | m_fd = -1; |
16 | m_not = 0l; | 17 | m_not = 0l; |
17 | m_proc = 0l; | 18 | m_proc = 0l; |
18 | } | 19 | } |
19 | FileReceive::~FileReceive() { | 20 | FileReceive::~FileReceive() { |
20 | } | 21 | } |
21 | void FileReceive::receive() { | 22 | void FileReceive::receive() { |
22 | receive( currentDir() ); | 23 | receive( currentDir() ); |
23 | } | 24 | } |
24 | void FileReceive::receive( const QString& dir ) { | 25 | void FileReceive::receive( const QString& dir ) { |
25 | m_prog = -1; | 26 | m_prog = -1; |
26 | m_fd = layer()->rawIO(); | 27 | m_fd = layer()->rawIO(); |
27 | m_curDir = dir; | 28 | m_curDir = dir; |
28 | 29 | ||
29 | if (pipe( m_comm ) < 0 ) | 30 | if (pipe( m_comm ) < 0 ) |
@@ -127,36 +128,37 @@ void FileReceive::setupChild() { | |||
127 | 128 | ||
128 | if (m_comm[0] ) | 129 | if (m_comm[0] ) |
129 | close( m_comm[0] ); | 130 | close( m_comm[0] ); |
130 | /* | 131 | /* |
131 | * now set the communication | 132 | * now set the communication |
132 | * m_fd STDIN_FILENO | 133 | * m_fd STDIN_FILENO |
133 | * STDOUT_FILENO | 134 | * STDOUT_FILENO |
134 | * STDERR_FILENO | 135 | * STDERR_FILENO |
135 | */ | 136 | */ |
136 | dup2( m_fd, STDIN_FILENO ); | 137 | dup2( m_fd, STDIN_FILENO ); |
137 | dup2( m_fd, STDOUT_FILENO ); | 138 | dup2( m_fd, STDOUT_FILENO ); |
138 | dup2( m_comm[1], STDERR_FILENO ); | 139 | dup2( m_comm[1], STDERR_FILENO ); |
139 | } | 140 | } |
140 | void FileReceive::slotRead() { | 141 | void FileReceive::slotRead() { |
141 | QByteArray ar(4096); | 142 | QByteArray ar(4096); |
142 | int len = read(m_comm[0], ar.data(), 4096 ); | 143 | int len = read(m_comm[0], ar.data(), 4096 ); |
143 | for (int i = 0; i < len; i++ ) { | 144 | for (int i = 0; i < len; i++ ) { |
144 | // printf("%c", ar[i] ); | 145 | // printf("%c", ar[i] ); |
145 | } | 146 | } |
146 | ar.resize( len ); | 147 | ar.resize( len ); |
147 | QString str( ar ); | 148 | QString str( ar ); |
148 | } | 149 | } |
149 | void FileReceive::slotExec() { | 150 | void FileReceive::slotExec() { |
150 | char buf[2]; | 151 | char buf[2]; |
151 | ::read(m_term[0], buf, 1 ); | 152 | if (::read(m_term[0], buf, 1 ) == -1) |
153 | owarn << "read of m_term[0] failed" << oendl; | ||
152 | delete m_proc; | 154 | delete m_proc; |
153 | delete m_not; | 155 | delete m_not; |
154 | m_not = m_proc = 0l; | 156 | m_not = m_proc = 0l; |
155 | close( m_term[0] ); | 157 | close( m_term[0] ); |
156 | close( m_term[1] ); | 158 | close( m_term[1] ); |
157 | close( m_comm[0] ); | 159 | close( m_comm[0] ); |
158 | close( m_comm[1] ); | 160 | close( m_comm[1] ); |
159 | layer()->closeRawIO(m_fd); | 161 | layer()->closeRawIO(m_fd); |
160 | emit received(QString::null); | 162 | emit received(QString::null); |
161 | 163 | ||
162 | } | 164 | } |
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 | |||
@@ -1,30 +1,31 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <errno.h> | 3 | #include <errno.h> |
4 | #include <fcntl.h> | 4 | #include <fcntl.h> |
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | 6 | ||
7 | #include <opie2/odebug.h> | ||
7 | #include <qsocketnotifier.h> | 8 | #include <qsocketnotifier.h> |
8 | 9 | ||
9 | #include "procctl.h" | 10 | #include "procctl.h" |
10 | #include "filetransfer.h" | 11 | #include "filetransfer.h" |
11 | 12 | ||
12 | 13 | ||
13 | FileTransfer::FileTransfer( Type t, IOLayer* lay ) | 14 | FileTransfer::FileTransfer( Type t, IOLayer* lay ) |
14 | : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) { | 15 | : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) { |
15 | signal(SIGPIPE, SIG_IGN ); | 16 | signal(SIGPIPE, SIG_IGN ); |
16 | 17 | ||
17 | m_pid = 0; | 18 | m_pid = 0; |
18 | m_not = 0l; | 19 | m_not = 0l; |
19 | m_proc = 0l; | 20 | m_proc = 0l; |
20 | } | 21 | } |
21 | FileTransfer::~FileTransfer() { | 22 | FileTransfer::~FileTransfer() { |
22 | } | 23 | } |
23 | 24 | ||
24 | /** | 25 | /** |
25 | * now we will send the file. | 26 | * now we will send the file. |
26 | * | 27 | * |
27 | * we request an fd. The IOLayer should be closed | 28 | * we request an fd. The IOLayer should be closed |
28 | * then we will setup a pipe for progress communication | 29 | * then we will setup a pipe for progress communication |
29 | * then we will dup2 the m_fd in the forked process | 30 | * then we will dup2 the m_fd in the forked process |
30 | * to do direct IO from and to the fd | 31 | * to do direct IO from and to the fd |
@@ -213,36 +214,37 @@ void FileTransfer::slotProgress( const QStringList& list ) { | |||
213 | int prog = pro * 100; | 214 | int prog = pro * 100; |
214 | 215 | ||
215 | // speed | 216 | // speed |
216 | progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); | 217 | progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); |
217 | bps = progi[1].toInt(); | 218 | bps = progi[1].toInt(); |
218 | 219 | ||
219 | // time | 220 | // time |
220 | progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); | 221 | progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); |
221 | min = progi[0].toInt(); | 222 | min = progi[0].toInt(); |
222 | sec = progi[1].toInt(); | 223 | sec = progi[1].toInt(); |
223 | 224 | ||
224 | 225 | ||
225 | if ( prog > m_prog ) { | 226 | if ( prog > m_prog ) { |
226 | m_prog = prog; | 227 | m_prog = prog; |
227 | emit progress(m_file, m_prog, bps, -1, min , sec ); | 228 | emit progress(m_file, m_prog, bps, -1, min , sec ); |
228 | } | 229 | } |
229 | 230 | ||
230 | } | 231 | } |
231 | void FileTransfer::cancel() { | 232 | void FileTransfer::cancel() { |
232 | if(m_pid > 0) ::kill(m_pid,9 ); | 233 | if(m_pid > 0) ::kill(m_pid,9 ); |
233 | 234 | ||
234 | } | 235 | } |
235 | void FileTransfer::slotExec() { | 236 | void FileTransfer::slotExec() { |
236 | char buf[2]; | 237 | char buf[2]; |
237 | ::read(m_term[0], buf, 1 ); | 238 | if (::read(m_term[0], buf, 1 ) == -1) |
239 | owarn << "read of m_term[0] failed" << oendl; | ||
238 | delete m_proc; | 240 | delete m_proc; |
239 | delete m_not; | 241 | delete m_not; |
240 | m_proc = m_not = 0l; | 242 | m_proc = m_not = 0l; |
241 | close( m_term[0] ); | 243 | close( m_term[0] ); |
242 | close( m_term[1] ); | 244 | close( m_term[1] ); |
243 | close( m_comm[0] ); | 245 | close( m_comm[0] ); |
244 | close( m_comm[1] ); | 246 | close( m_comm[1] ); |
245 | layer()->closeRawIO( m_fd ); | 247 | layer()->closeRawIO( m_fd ); |
246 | emit sent(); | 248 | emit sent(); |
247 | m_pid = 0; | 249 | m_pid = 0; |
248 | } | 250 | } |
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,20 +1,22 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include <qtextstream.h> | 2 | #include <qtextstream.h> |
3 | #include <opie2/odebug.h> | ||
3 | 4 | ||
4 | #include "logger.h" | 5 | #include "logger.h" |
5 | 6 | ||
6 | 7 | ||
7 | Logger::Logger() {} | 8 | Logger::Logger() {} |
8 | 9 | ||
9 | Logger::Logger(const QString fileName) { | 10 | Logger::Logger(const QString fileName) { |
10 | m_file.setName(fileName); | 11 | m_file.setName(fileName); |
11 | m_file.open(IO_ReadWrite); | 12 | if ( !m_file.open(IO_ReadWrite) ) |
13 | owarn << "failed to open " << m_file.name() << oendl; | ||
12 | } | 14 | } |
13 | 15 | ||
14 | Logger::~Logger() { | 16 | Logger::~Logger() { |
15 | m_file.close(); | 17 | m_file.close(); |
16 | } | 18 | } |
17 | 19 | ||
18 | void Logger::append(QByteArray ar) { | 20 | void Logger::append(QByteArray ar) { |
19 | m_file.writeBlock(ar); | 21 | m_file.writeBlock(ar); |
20 | } | 22 | } |
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 | |||
@@ -803,32 +803,33 @@ void MainWindow::slotSaveLog() { | |||
803 | 803 | ||
804 | m_recordLog->setText( tr("Stop log") ); | 804 | m_recordLog->setText( tr("Stop log") ); |
805 | m_recordingLog = true; | 805 | m_recordingLog = true; |
806 | currentSession()->emulationHandler()->startLogging(m_logName); | 806 | currentSession()->emulationHandler()->startLogging(m_logName); |
807 | } | 807 | } |
808 | } | 808 | } |
809 | 809 | ||
810 | void MainWindow::slotSaveHistory() { | 810 | void MainWindow::slotSaveHistory() { |
811 | QMap<QString, QStringList> map; | 811 | QMap<QString, QStringList> map; |
812 | QStringList text; | 812 | QStringList text; |
813 | text << "text/plain"; | 813 | text << "text/plain"; |
814 | map.insert(tr("History"), text ); | 814 | map.insert(tr("History"), text ); |
815 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 815 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
816 | if (filename.isEmpty() ) return; | 816 | if (filename.isEmpty() ) return; |
817 | 817 | ||
818 | QFileInfo info(filename); | 818 | QFileInfo info(filename); |
819 | 819 | ||
820 | DocLnk nf; | 820 | DocLnk nf; |
821 | nf.setType("text/plain"); | 821 | nf.setType("text/plain"); |
822 | nf.setFile(filename); | 822 | nf.setFile(filename); |
823 | nf.setName(info.fileName()); | 823 | nf.setName(info.fileName()); |
824 | 824 | ||
825 | 825 | ||
826 | QFile file(filename); | 826 | QFile file(filename); |
827 | file.open(IO_WriteOnly ); | 827 | if ( !file.open(IO_WriteOnly ) ) return; |
828 | |||
828 | QTextStream str(&file ); | 829 | QTextStream str(&file ); |
829 | if ( currentSession() ) | 830 | if ( currentSession() ) |
830 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | 831 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); |
831 | 832 | ||
832 | file.close(); | 833 | file.close(); |
833 | nf.writeLink(); | 834 | nf.writeLink(); |
834 | } | 835 | } |
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 | |||
@@ -1,29 +1,31 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include "script.h" | 2 | #include "script.h" |
3 | 3 | ||
4 | Script::Script() { | 4 | Script::Script() { |
5 | } | 5 | } |
6 | 6 | ||
7 | Script::Script(const QString fileName) { | 7 | Script::Script(const QString fileName) { |
8 | QFile file(fileName); | 8 | QFile file(fileName); |
9 | file.open(IO_ReadOnly ); | 9 | if ( !file.open(IO_ReadOnly ) ) |
10 | return; | ||
10 | m_script = file.readAll(); | 11 | m_script = file.readAll(); |
11 | } | 12 | } |
12 | 13 | ||
13 | void Script::saveTo(const QString fileName) const { | 14 | void Script::saveTo(const QString fileName) const { |
14 | QFile file(fileName); | 15 | QFile file(fileName); |
15 | file.open(IO_WriteOnly); | 16 | if ( !file.open(IO_WriteOnly) ) |
17 | return; | ||
16 | file.writeBlock(m_script); | 18 | file.writeBlock(m_script); |
17 | file.close(); | 19 | file.close(); |
18 | } | 20 | } |
19 | 21 | ||
20 | 22 | ||
21 | void Script::append(const QByteArray &data) { | 23 | void Script::append(const QByteArray &data) { |
22 | int size = m_script.size(); | 24 | int size = m_script.size(); |
23 | m_script.resize(size + data.size()); | 25 | m_script.resize(size + data.size()); |
24 | memcpy(m_script.data() + size, data.data(), data.size()); | 26 | memcpy(m_script.data() + size, data.data(), data.size()); |
25 | } | 27 | } |
26 | 28 | ||
27 | QByteArray Script::script() const { | 29 | QByteArray Script::script() const { |
28 | return m_script; | 30 | return m_script; |
29 | } | 31 | } |