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/filereceive.cpp | |
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.
Diffstat (limited to 'noncore/apps/opie-console/filereceive.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/filereceive.cpp | 4 |
1 files changed, 3 insertions, 1 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,53 +1,54 @@ | |||
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 ) |
30 | m_comm[0] = m_comm[1] = 0; | 31 | m_comm[0] = m_comm[1] = 0; |
31 | if (pipe( m_info ) < 0 ) | 32 | if (pipe( m_info ) < 0 ) |
32 | m_info[0] = m_info[1] = 0; | 33 | m_info[0] = m_info[1] = 0; |
33 | 34 | ||
34 | m_pid = fork(); | 35 | m_pid = fork(); |
35 | switch( m_pid ) { | 36 | switch( m_pid ) { |
36 | case -1: | 37 | case -1: |
37 | //emit error | 38 | //emit error |
38 | slotExec(); | 39 | slotExec(); |
39 | break; | 40 | break; |
40 | /* child */ | 41 | /* child */ |
41 | case 0: { | 42 | case 0: { |
42 | setupChild(); | 43 | setupChild(); |
43 | char* typus = NULL; | 44 | char* typus = NULL; |
44 | switch(m_type ) { | 45 | switch(m_type ) { |
45 | case SZ: | 46 | case SZ: |
46 | break; | 47 | break; |
47 | case SX: | 48 | case SX: |
48 | typus = "-X"; | 49 | typus = "-X"; |
49 | break; | 50 | break; |
50 | case SY: | 51 | case SY: |
51 | typus = "--ymodem"; | 52 | typus = "--ymodem"; |
52 | break; | 53 | break; |
53 | } | 54 | } |
@@ -103,60 +104,61 @@ void FileReceive::receive( const QString& dir ) { | |||
103 | 104 | ||
104 | } | 105 | } |
105 | break; | 106 | break; |
106 | 107 | ||
107 | } | 108 | } |
108 | 109 | ||
109 | } | 110 | } |
110 | void FileReceive::cancel() { | 111 | void FileReceive::cancel() { |
111 | ::kill(m_pid, 9 ); | 112 | ::kill(m_pid, 9 ); |
112 | } | 113 | } |
113 | void FileReceive::setupChild() { | 114 | void FileReceive::setupChild() { |
114 | changeDir( currentDir() ); | 115 | changeDir( currentDir() ); |
115 | /* | 116 | /* |
116 | * we do not want to read from our | 117 | * we do not want to read from our |
117 | * information channel | 118 | * information channel |
118 | */ | 119 | */ |
119 | if (m_info[0] ) | 120 | if (m_info[0] ) |
120 | close(m_info[0] ); | 121 | close(m_info[0] ); |
121 | /* | 122 | /* |
122 | * FD_CLOEXEC will close the | 123 | * FD_CLOEXEC will close the |
123 | * fd on successful exec | 124 | * fd on successful exec |
124 | */ | 125 | */ |
125 | if (m_info[1] ) | 126 | if (m_info[1] ) |
126 | fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); | 127 | fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); |
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 | } |