Fix bugs found in the code by static analysis 20/160920/1
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Mon, 20 Nov 2017 16:35:53 +0000 (17:35 +0100)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Mon, 20 Nov 2017 16:35:53 +0000 (17:35 +0100)
Change-Id: I662d10db09931d6d3154dd263f6e6aaaa2fbf0b4

src/server/main/generic-socket-manager.cpp
test/test_privilege_db_app_pkg_getters.cpp
test/test_smack-labels.cpp

index 487b47e..91f2adc 100644 (file)
@@ -48,7 +48,7 @@ public:
             m_hdr.msg_control = m_cmsgbuf;
             m_hdr.msg_controllen = CMSG_SPACE(sizeof(int));
 
-            m_cmsg = CMSG_FIRSTHDR(&m_hdr);
+            cmsghdr *m_cmsg = CMSG_FIRSTHDR(&m_hdr);
             m_cmsg->cmsg_len = CMSG_LEN(sizeof(int));
             m_cmsg->cmsg_level = SOL_SOCKET;
             m_cmsg->cmsg_type = SCM_RIGHTS;
@@ -62,7 +62,6 @@ public:
 private:
     msghdr m_hdr;
     iovec m_iov;
-    cmsghdr *m_cmsg;
     unsigned char m_cmsgbuf[CMSG_SPACE(sizeof(int))];
     int m_resultCode;
     int m_fileDesc;
index cc94010..1160873 100644 (file)
@@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(T320_author_id_exists_finds_nothing)
 
 BOOST_AUTO_TEST_CASE(T325_app_name_pkg_author_exists)
 {
-    int authorId;
+    int authorId = -1;
 
     addAppSuccess(app(1), pkg(1), uid(1), tizenVer(1), author(1), NotHybrid);
     addAppSuccess(app(2), pkg(2), uid(1), tizenVer(1), author(2), NotHybrid);
index 77db447..ef95ffa 100644 (file)
@@ -39,7 +39,7 @@ struct FileFixture
     FileFixture()
     {
         fd = open(path, O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-        BOOST_REQUIRE_MESSAGE(fd > 0, "Failed to open file: " << path);
+        BOOST_REQUIRE_MESSAGE(fd >= 0, "Failed to open file: " << path);
     }
 
     ~FileFixture()
@@ -65,7 +65,7 @@ struct DirectoryFixture
         BOOST_REQUIRE_MESSAGE(ret == 0, "Failed to make directory: " << subdirectoryPath);
 
         ret = creat(execPath, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
-        BOOST_REQUIRE_MESSAGE(ret > 0, "Failed to creat file: " << execPath);
+        BOOST_REQUIRE_MESSAGE(ret >= 0, "Failed to creat file: " << execPath);
         close(ret);
 
         ret = symlink(execPath, linkPath);