Resolve alarms of cppcheck for base modules 82/58082/1
authorWonYoung Choi <wy80.choi@samsung.com>
Wed, 27 Jan 2016 10:03:59 +0000 (19:03 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Wed, 27 Jan 2016 10:03:59 +0000 (19:03 +0900)
cppcheck --enable=all --std="c++11" modules/

Change-Id: Id4ad0361c95fc965f1a87b65a54129c290e26abe

modules/gcontext/src/gcontext.cc
modules/gcontext/src/gcontext.h
modules/node-xwalk/src/extension_adapter.cc

index 94e2815..162cd80 100755 (executable)
@@ -35,13 +35,22 @@ namespace service {
 
 struct poll_handler {
   int fd;
-  uv_poll_t *uv_poll;
+  uv_poll_tuv_poll;
   int eventmask;
   int ref;
   std::list<GPollFD*> fd_list;
 };
 
-GContext::GContext():initialized_(false) {
+GContext::GContext() :
+    initialized_(false),
+    context_(NULL),
+    max_priority_(0),
+    fd_list_(NULL),
+    fd_list_size_(0),
+    fd_count_(0),
+    prepare_handle_(NULL),
+    check_handle_(NULL),
+    timeout_handle_(NULL) {
 }
 
 GContext::~GContext() {
@@ -51,7 +60,7 @@ void GContext::Init() {
   if (initialized_)
     return;
   initialized_ = true;
-  GMainContext *gc = g_main_context_default();
+  GMainContextgc = g_main_context_default();
 
 #if !GLIB_CHECK_VERSION(2, 35, 0)
   g_type_init();
@@ -128,7 +137,7 @@ void GContext::Uninit() {
   g_main_context_unref(context_);
 }
 
-static void poll_cb(uv_poll_t *uv_handle, int status, int events) {
+static void poll_cb(uv_poll_tuv_handle, int status, int events) {
   poll_handler* handle = static_cast<poll_handler*>(uv_handle->data);
   if (status == 0) {
     std::list<GPollFD*>::iterator itr = handle->fd_list.begin();
@@ -144,7 +153,6 @@ static void poll_cb(uv_poll_t *uv_handle, int status, int events) {
 }
 
 void GContext::onPrepare() {
-  int i;
   int timeout;
 
   g_main_context_prepare(context_, &max_priority_);
@@ -176,8 +184,8 @@ void GContext::onPrepare() {
       handle->fd_list.clear();
 
       // check already initialized poll handles
-      for (i = 0; i < fd_count_; ++i) {
-        GPollFD *pfd = fd_list_ + i;
+      for (int i = 0; i < fd_count_; ++i) {
+        GPollFDpfd = fd_list_ + i;
         if (handle->fd == pfd->fd) {
           flagsTable.get()[i] = 1;
           handle->ref++;
@@ -211,15 +219,15 @@ void GContext::onPrepare() {
 
     std::list<poll_handler*> new_poll_fds;
     /* Process current file descriptors from GContext */
-    for (i = 0; i < fd_count_; ++i) {
-      GPollFD *pfd = &fd_list_[i];
+    for (int i = 0; i < fd_count_; ++i) {
+      GPollFDpfd = &fd_list_[i];
       int exists = flagsTable.get()[i];
       if (exists)
         continue;
 
       pfd->revents = 0;
       for (itr = new_poll_fds.begin(); itr != new_poll_fds.end(); ++itr) {
-        poll_handler *handle = *itr;
+        poll_handlerhandle = *itr;
         if (handle->fd == pfd->fd) {
           int oldmask = handle->eventmask;
           handle->eventmask |= (pfd->events & G_IO_IN ? UV_READABLE: 0)
@@ -242,7 +250,7 @@ void GContext::onPrepare() {
       handle->ref = 1;
 
       /* Create uv poll handler, then append own poll handler on it */
-      uv_poll_t *pt = static_cast<uv_poll_t*>(malloc(sizeof(uv_poll_t)));
+      uv_poll_tpt = static_cast<uv_poll_t*>(malloc(sizeof(uv_poll_t)));
       memset(pt, 0, sizeof(uv_poll_t));
       pt->data = handle;
       handle->uv_poll = pt;
@@ -265,7 +273,7 @@ void GContext::onPrepare() {
 
 
 void GContext::OnPrepare(uv_prepare_t* handle) {
-  GContext *This = static_cast<GContext*>(handle->data);
+  GContextThis = static_cast<GContext*>(handle->data);
   This->onPrepare();
 }
 
@@ -293,7 +301,7 @@ void GContext::onTimeout() {
 }
 
 
-static GContext *g_context = NULL;
+static GContextg_context = NULL;
 
 static void GContextInit(const v8::FunctionCallbackInfo<v8::Value>&) {
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
index 261ebf5..b6ab746 100755 (executable)
@@ -44,17 +44,17 @@ class GContext {
   static void OnTimeout(uv_timer_s* handle);
 
   bool initialized_;
-  GMainContext *context_;
+  GMainContextcontext_;
   int max_priority_;
 
-  GPollFD *fd_list_;
+  GPollFDfd_list_;
   int fd_list_size_;
   int fd_count_;
   std::list<poll_handler*> poll_handle_list_;
 
-  uv_prepare_t *prepare_handle_;
-  uv_check_t *check_handle_;
-  uv_timer_t *timeout_handle_;
+  uv_prepare_tprepare_handle_;
+  uv_check_tcheck_handle_;
+  uv_timer_ttimeout_handle_;
 };
 
 }  // namespace service
index fcac464..b1eb493 100644 (file)
@@ -55,8 +55,7 @@ void ExtensionAdapter::UnregisterExtension(Extension* extension) {
     LOGW("xw_extension (%d) is invalid.", xw_extension);
     return;
   }
-  if (extension_map_.find(xw_extension) != extension_map_.end())
-    extension_map_.erase(xw_extension);
+  extension_map_.erase(xw_extension);
 }
 
 void ExtensionAdapter::RegisterInstance(ExtensionInstance* instance) {
@@ -75,8 +74,7 @@ void ExtensionAdapter::UnregisterInstance(ExtensionInstance* instance) {
     LOGW("xw_instance (%d) is invalid.", xw_instance);
     return;
   }
-  if (instance_map_.find(xw_instance) != instance_map_.end())
-    instance_map_.erase(xw_instance);
+  instance_map_.erase(xw_instance);
 }
 
 const void* ExtensionAdapter::GetInterface(const char* name) {