author | erik <erik> | 2007-01-31 22:06:07 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-31 22:06:07 (UTC) |
commit | 9395cf2a65184e493714c699bb23b02ea31feef5 (patch) (unidiff) | |
tree | ea07c026298820559c13ad32e612d51048cee0a9 /noncore/multimedia/opieplayer2/threadutil.cpp | |
parent | 958e042c5a4d4e38fd1baae50b78a2febfd306ab (diff) | |
download | opie-9395cf2a65184e493714c699bb23b02ea31feef5.zip opie-9395cf2a65184e493714c699bb23b02ea31feef5.tar.gz opie-9395cf2a65184e493714c699bb23b02ea31feef5.tar.bz2 |
I expanded my audit to include any app I could get to compile in i386.
In that expansion a whole new crop of unchecked returns has sprung up.
This commit fixes those weeds or should I say potential bugs.
Diffstat (limited to 'noncore/multimedia/opieplayer2/threadutil.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/threadutil.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/threadutil.cpp b/noncore/multimedia/opieplayer2/threadutil.cpp index b5cac61..5fc8a0b 100644 --- a/noncore/multimedia/opieplayer2/threadutil.cpp +++ b/noncore/multimedia/opieplayer2/threadutil.cpp | |||
@@ -188,102 +188,107 @@ void Thread::start() | |||
188 | AutoLock lock( d->guard ); | 188 | AutoLock lock( d->guard ); |
189 | 189 | ||
190 | if ( d->isRunning ) { | 190 | if ( d->isRunning ) { |
191 | odebug << "ThreadUtil::Thread::start() called for running thread." << oendl; | 191 | odebug << "ThreadUtil::Thread::start() called for running thread." << oendl; |
192 | return; | 192 | return; |
193 | } | 193 | } |
194 | 194 | ||
195 | pthread_attr_t attributes; | 195 | pthread_attr_t attributes; |
196 | pthread_attr_init( &attributes ); | 196 | pthread_attr_init( &attributes ); |
197 | pthread_attr_setscope( &attributes, PTHREAD_SCOPE_SYSTEM ); | 197 | pthread_attr_setscope( &attributes, PTHREAD_SCOPE_SYSTEM ); |
198 | int err = pthread_create( &d->self, &attributes, start_thread, ( void* )d ); | 198 | int err = pthread_create( &d->self, &attributes, start_thread, ( void* )d ); |
199 | if ( err != 0 ) { | 199 | if ( err != 0 ) { |
200 | odebug << "ThreadUtil::Thread::start() : can't create thread: " << strerror( err ) << "" << oendl; | 200 | odebug << "ThreadUtil::Thread::start() : can't create thread: " << strerror( err ) << "" << oendl; |
201 | pthread_attr_destroy( &attributes ); | 201 | pthread_attr_destroy( &attributes ); |
202 | return; | 202 | return; |
203 | } | 203 | } |
204 | pthread_attr_destroy( &attributes ); | 204 | pthread_attr_destroy( &attributes ); |
205 | } | 205 | } |
206 | 206 | ||
207 | void Thread::terminate() | 207 | void Thread::terminate() |
208 | { | 208 | { |
209 | AutoLock lock( d->guard ); | 209 | AutoLock lock( d->guard ); |
210 | if ( !d->isRunning ) | 210 | if ( !d->isRunning ) |
211 | return; | 211 | return; |
212 | 212 | ||
213 | pthread_cancel( d->self ); | 213 | pthread_cancel( d->self ); |
214 | } | 214 | } |
215 | 215 | ||
216 | bool Thread::wait() | 216 | bool Thread::wait() |
217 | { | 217 | { |
218 | AutoLock lock( d->guard ); | 218 | AutoLock lock( d->guard ); |
219 | if ( !d->isRunning ) | 219 | if ( !d->isRunning ) |
220 | return true; | 220 | return true; |
221 | 221 | ||
222 | return d->finishCondition.wait( d->guard ); | 222 | return d->finishCondition.wait( d->guard ); |
223 | } | 223 | } |
224 | 224 | ||
225 | bool Thread::isRunning() const | 225 | bool Thread::isRunning() const |
226 | { | 226 | { |
227 | AutoLock lock( d->guard ); | 227 | AutoLock lock( d->guard ); |
228 | return d->isRunning; | 228 | return d->isRunning; |
229 | } | 229 | } |
230 | 230 | ||
231 | void Thread::exit() | 231 | void Thread::exit() |
232 | { | 232 | { |
233 | pthread_exit( 0 ); | 233 | pthread_exit( 0 ); |
234 | } | 234 | } |
235 | 235 | ||
236 | OnewayNotifier::OnewayNotifier() | 236 | OnewayNotifier::OnewayNotifier() : |
237 | m_readFd(-1), | ||
238 | m_writeFd(-1) | ||
237 | { | 239 | { |
238 | int fds[ 2 ]; | 240 | int fds[ 2 ] = { -1, -1 }; |
239 | pipe( fds ); | 241 | if (pipe( fds ) == 0) { |
240 | m_readFd = fds[ 0 ]; | 242 | m_readFd = fds[ 0 ]; |
241 | m_writeFd = fds[ 1 ]; | 243 | m_writeFd = fds[ 1 ]; |
244 | } else { | ||
245 | owarn << "Call to pipe() failed" << oendl; | ||
246 | } | ||
242 | 247 | ||
243 | m_notifier = new QSocketNotifier( m_readFd, QSocketNotifier::Read ); | 248 | m_notifier = new QSocketNotifier( m_readFd, QSocketNotifier::Read ); |
244 | connect( m_notifier, SIGNAL( activated(int) ), | 249 | connect( m_notifier, SIGNAL( activated(int) ), |
245 | this, SLOT( wakeUp() ) ); | 250 | this, SLOT( wakeUp() ) ); |
246 | } | 251 | } |
247 | 252 | ||
248 | OnewayNotifier::~OnewayNotifier() | 253 | OnewayNotifier::~OnewayNotifier() |
249 | { | 254 | { |
250 | delete m_notifier; | 255 | delete m_notifier; |
251 | 256 | ||
252 | ::close( m_readFd ); | 257 | ::close( m_readFd ); |
253 | ::close( m_writeFd ); | 258 | ::close( m_writeFd ); |
254 | } | 259 | } |
255 | 260 | ||
256 | void OnewayNotifier::notify() | 261 | void OnewayNotifier::notify() |
257 | { | 262 | { |
258 | const char c = 42; | 263 | const char c = 42; |
259 | ::write( m_writeFd, &c, 1 ); | 264 | ::write( m_writeFd, &c, 1 ); |
260 | } | 265 | } |
261 | 266 | ||
262 | void OnewayNotifier::wakeUp() | 267 | void OnewayNotifier::wakeUp() |
263 | { | 268 | { |
264 | char c = 0; | 269 | char c = 0; |
265 | 270 | ||
266 | if ( ::read( m_readFd, &c, 1 ) != 1 ) | 271 | if ( ::read( m_readFd, &c, 1 ) != 1 ) |
267 | return; | 272 | return; |
268 | 273 | ||
269 | emit awake(); | 274 | emit awake(); |
270 | } | 275 | } |
271 | 276 | ||
272 | ChannelMessage::ChannelMessage( int type, int data, const char* msg ) | 277 | ChannelMessage::ChannelMessage( int type, int data, const char* msg ) |
273 | : m_type( type ), m_data( data ), m_msg( msg ), | 278 | : m_type( type ), m_data( data ), m_msg( msg ), |
274 | m_isCall( false ), m_replied( false ), m_inEventHandler( false ) | 279 | m_isCall( false ), m_replied( false ), m_inEventHandler( false ) |
275 | {} | 280 | {} |
276 | 281 | ||
277 | ChannelMessage::~ChannelMessage() | 282 | ChannelMessage::~ChannelMessage() |
278 | { | 283 | { |
279 | if ( m_guard.isLocked() ) | 284 | if ( m_guard.isLocked() ) |
280 | m_guard.unlock(); | 285 | m_guard.unlock(); |
281 | } | 286 | } |
282 | 287 | ||
283 | void ChannelMessage::reply() | 288 | void ChannelMessage::reply() |
284 | { | 289 | { |
285 | if ( !m_isCall ) | 290 | if ( !m_isCall ) |
286 | { | 291 | { |
287 | odebug << "ChannelMessage::reply() - can't reply oneway message!" << oendl; | 292 | odebug << "ChannelMessage::reply() - can't reply oneway message!" << oendl; |
288 | return; | 293 | return; |
289 | } | 294 | } |