From 143abd95a3f1eee7f690d161d6aaf22125e5d09f Mon Sep 17 00:00:00 2001 From: "henrike@webrtc.org" Date: Wed, 8 Feb 2012 19:39:38 +0000 Subject: [PATCH] Fixes coverity warnings in system_wrappers. Review URL: https://webrtc-codereview.appspot.com/389003 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1645 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/system_wrappers/source/file_impl.cc | 4 ++-- src/system_wrappers/source/thread_posix.cc | 10 +++++++--- src/system_wrappers/source/thread_posix.h | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/system_wrappers/source/file_impl.cc b/src/system_wrappers/source/file_impl.cc index d163bf6c2..4d06c5470 100644 --- a/src/system_wrappers/source/file_impl.cc +++ b/src/system_wrappers/source/file_impl.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -118,7 +118,7 @@ int FileWrapperImpl::OpenFile(const char *fileNameUTF8, bool readOnly, bool loop, bool text) { size_t length = strlen(fileNameUTF8); - if (length > kMaxFileNameSize) + if (length > kMaxFileNameSize - 1) { return -1; } diff --git a/src/system_wrappers/source/thread_posix.cc b/src/system_wrappers/source/thread_posix.cc index 6e359f516..0bb686a40 100644 --- a/src/system_wrappers/source/thread_posix.cc +++ b/src/system_wrappers/source/thread_posix.cc @@ -64,15 +64,19 @@ ThreadPosix::ThreadPosix(ThreadRunFunction func, ThreadObj obj, _dead(true), _prio(prio), _event(EventWrapper::Create()), - _setThreadName(false) -{ + _name(), + _setThreadName(false), #if (defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)) - _pid = -1; + _pid(-1), #endif + _attr(), + _thread(NULL) +{ if (threadName != NULL) { _setThreadName = true; strncpy(_name, threadName, kThreadMaxNameLength); + _name[kThreadMaxNameLength - 1] = '\0'; } } diff --git a/src/system_wrappers/source/thread_posix.h b/src/system_wrappers/source/thread_posix.h index b2d13d5dc..fc5757daf 100644 --- a/src/system_wrappers/source/thread_posix.h +++ b/src/system_wrappers/source/thread_posix.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -57,11 +57,11 @@ private: bool _setThreadName; // handle to thread - pthread_attr_t _attr; - pthread_t _thread; #if (defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)) pid_t _pid; #endif + pthread_attr_t _attr; + pthread_t _thread; }; } // namespace webrtc