From 7e9a0e64904e3fb20890e597052abee0bf4b9d37 Mon Sep 17 00:00:00 2001 From: Bartlomiej Grzelewski Date: Mon, 20 Nov 2017 17:35:53 +0100 Subject: Fix bugs found in the code by static analysis Change-Id: I662d10db09931d6d3154dd263f6e6aaaa2fbf0b4 --- src/server/main/generic-socket-manager.cpp | 3 +-- test/test_privilege_db_app_pkg_getters.cpp | 2 +- test/test_smack-labels.cpp | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/server/main/generic-socket-manager.cpp b/src/server/main/generic-socket-manager.cpp index 487b47e4..91f2adc1 100644 --- a/src/server/main/generic-socket-manager.cpp +++ b/src/server/main/generic-socket-manager.cpp @@ -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; diff --git a/test/test_privilege_db_app_pkg_getters.cpp b/test/test_privilege_db_app_pkg_getters.cpp index cc940107..1160873d 100644 --- a/test/test_privilege_db_app_pkg_getters.cpp +++ b/test/test_privilege_db_app_pkg_getters.cpp @@ -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); diff --git a/test/test_smack-labels.cpp b/test/test_smack-labels.cpp index 77db447d..ef95ffa8 100644 --- a/test/test_smack-labels.cpp +++ b/test/test_smack-labels.cpp @@ -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); -- cgit v1.2.3