Fix static analysis issues 82/279582/5
authorChanggyu Choi <changyu.choi@samsung.com>
Fri, 12 Aug 2022 02:26:29 +0000 (11:26 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Fri, 12 Aug 2022 04:58:26 +0000 (04:58 +0000)
Changes:
 - Adds exception handling.

Change-Id: I0e20206337040eba4430afc32bd1ec79ddde3c6a
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
aul/socket/client_socket.cc
src/aul_watchdog.cc

index 3f3e793..8d7abae 100644 (file)
@@ -55,8 +55,13 @@ void ClientSocket::Close() {
 
 void ClientSocket::Connect(const std::string& endpoint) {
   int flag = fcntl(fd_, F_GETFL, 0);
-  fcntl(GetFd(), F_SETFL, flag | O_NONBLOCK);
+  if (flag == -1) {
+    int ret = -errno;
+    _E("Failed to fcntl(%d, F_GETFL, 0). errno(%d)", fd_, errno);
+    THROW(ret);
+  }
 
+  fcntl(GetFd(), F_SETFL, flag | O_NONBLOCK);
   struct sockaddr_un sockaddr = { 0, };
   sockaddr.sun_family = AF_UNIX;
   snprintf(sockaddr.sun_path, sizeof(sockaddr.sun_path), "%s",
index ca6f748..27d852c 100644 (file)
@@ -37,8 +37,13 @@ class WatchdogContext {
   ~WatchdogContext() {
     Stop();
 
-    if (enabled_)
-      Disable();
+    if (enabled_) {
+      try {
+        Disable();
+      } catch (const Exception& e) {
+        _E("Exception occurs. error(%d)", e.GetErrorCode());
+      }
+    }
   }
 
   void Enable() {