All *.c , *.h , *.cpp and *.hpp files changed by stylecheck-for-git.
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 20 Jun 2013 13:16:31 +0000 (15:16 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 23 Jan 2014 13:58:51 +0000 (14:58 +0100)
[Issue#]        SSDWSSP-322
[Bug/Feature]   Standardization of repository coding style.
[Cause]         N/A
[Solution]      N/A
[Verification]  N/A

Change-Id: Iaa411d974d68b16b57423cfe498cb96c206693b2

12 files changed:
tests/libprivilege-control-tests/test_cases.cpp
tests/libsmack-tests/libsmack-test.cpp
tests/libsmack-tests/test_cases.cpp
tests/security-server-tests/security_server_mockup.cpp
tests/security-server-tests/security_server_tests_client.h
tests/security-server-tests/security_server_tests_client_smack.cpp
tests/security-server-tests/security_server_tests_label.cpp
tests/security-server-tests/security_server_tests_mt.cpp
tests/security-server-tests/security_server_tests_password.cpp
tests/security-server-tests/security_server_tests_pid_reuser.cpp
tests/security-server-tests/security_server_tests_server.cpp
tests/security-server-tests/test.h

index 9eaca16..9e787e7 100644 (file)
 #include <sys/stat.h>
 
 #define SMACK_RULES_DIR  "/opt/etc/smack-app/accesses.d/"
-#define SMACK_LOAD2 "/smack/load2"
-#define TEST_APP_DIR "/etc/smack/test_privilege_control_DIR/app_dir"
+#define SMACK_LOAD2      "/smack/load2"
+#define TEST_APP_DIR     "/etc/smack/test_privilege_control_DIR/app_dir"
 #define TEST_NON_APP_DIR "/etc/smack/test_privilege_control_DIR/non_app_dir"
-#define APPID_DIR  "test_APP_ID_dir"
-#define APPID_SHARED_DIR  "test_APP_ID_shared_dir"
-#define CANARY_LABEL "tiny_yellow_canary"
+#define APPID_DIR        "test_APP_ID_dir"
+#define APPID_SHARED_DIR "test_APP_ID_shared_dir"
+#define CANARY_LABEL     "tiny_yellow_canary"
 
-#define APP_ID  "test_APP"
-#define APP_SET_PRIV_PATH "/etc/smack/test_privilege_control_DIR/test_set_app_privilege/test_APP"
+#define APP_ID                 "test_APP"
+#define APP_SET_PRIV_PATH      "/etc/smack/test_privilege_control_DIR/test_set_app_privilege/test_APP"
 #define APP_SET_PRIV_PATH_REAL "/etc/smack/test_privilege_control_DIR/test_set_app_privilege/test_APP_REAL"
 
-#define WGT_APP_ID "QwCqJ0ttyS"
-#define WGT_PARTNER_APP_ID "7btsV1Y0sX"
-#define WGT_PLATFORM_APP_ID "G4DE3U2vmW"
-#define WGT_APP_PATH "/opt/usr/apps/QwCqJ0ttyS/bin/QwCqJ0ttyS.TestMisiuPysiu123"
-#define WGT_PARTNER_APP_PATH "/opt/usr/apps/7btsV1Y0sX/bin/7btsV1Y0sX.MisiuPysiu123Partner"
+#define WGT_APP_ID            "QwCqJ0ttyS"
+#define WGT_PARTNER_APP_ID    "7btsV1Y0sX"
+#define WGT_PLATFORM_APP_ID   "G4DE3U2vmW"
+#define WGT_APP_PATH          "/opt/usr/apps/QwCqJ0ttyS/bin/QwCqJ0ttyS.TestMisiuPysiu123"
+#define WGT_PARTNER_APP_PATH  "/opt/usr/apps/7btsV1Y0sX/bin/7btsV1Y0sX.MisiuPysiu123Partner"
 #define WGT_PLATFORM_APP_PATH "/opt/usr/apps/G4DE3U2vmW/bin/G4DE3U2vmW.MisiuPysiu123Platform"
-#define OSP_APP_ID "uqNfgEjqc7"
-#define OSP_PARTNER_APP_ID "j4RuPsZrNt"
-#define OSP_PLATFORM_APP_ID "V5LKqDFBXm"
-#define OSP_APP_PATH "/opt/usr/apps/uqNfgEjqc7/bin/PysiuMisiu123Osp"
-#define OSP_PARTNER_APP_PATH "/opt/usr/apps/j4RuPsZrNt/bin/PysiuMisiu123OspPartner"
+#define OSP_APP_ID            "uqNfgEjqc7"
+#define OSP_PARTNER_APP_ID    "j4RuPsZrNt"
+#define OSP_PLATFORM_APP_ID   "V5LKqDFBXm"
+#define OSP_APP_PATH          "/opt/usr/apps/uqNfgEjqc7/bin/PysiuMisiu123Osp"
+#define OSP_PARTNER_APP_PATH  "/opt/usr/apps/j4RuPsZrNt/bin/PysiuMisiu123OspPartner"
 #define OSP_PLATFORM_APP_PATH "/opt/usr/apps/V5LKqDFBXm/bin/PysiuMisiu123OspPlatform"
 
 const char *PRIVS[] = { "WRT", "test_privilege_control_rules", NULL };
@@ -80,35 +80,35 @@ const char *PRIVS2_R_AND_NO_R[] = { "test_privilege_control_rules2_r", "test_pri
 const char *PRIVS_WGT[] = { "test_privilege_control_rules_wgt", NULL };
 const char *PRIVS_OSP[] = { "test_privilege_control_rules_osp", NULL };
 
-#define LIBPRIVILEGE_APP_GROUP_LIST "/usr/share/privilege-control/app_group_list"
-#define LIBPRIVILEGE_TEST_DAC_FILE "/usr/share/privilege-control/test_privilege_control_rules.dac"
+#define LIBPRIVILEGE_APP_GROUP_LIST    "/usr/share/privilege-control/app_group_list"
+#define LIBPRIVILEGE_TEST_DAC_FILE     "/usr/share/privilege-control/test_privilege_control_rules.dac"
 #define LIBPRIVILEGE_TEST_DAC_FILE_WGT "/usr/share/privilege-control/WRT_test_privilege_control_rules_wgt.dac"
 #define LIBPRIVILEGE_TEST_DAC_FILE_OSP "/usr/share/privilege-control/OSP_test_privilege_control_rules_osp.dac"
 
 #define APP_TEST_APP_1 "test-application1"
 #define APP_TEST_APP_2 "test-application_2"
 #define APP_TEST_APP_3 "test-app-3"
-#define APP_TEST_AV_1 "test-antivirus1"
-#define APP_TEST_AV_2 "test-antivirus_2"
-#define APP_TEST_AV_3 "test-av-3"
+#define APP_TEST_AV_1  "test-antivirus1"
+#define APP_TEST_AV_2  "test-antivirus_2"
+#define APP_TEST_AV_3  "test-av-3"
 
-#define SMACK_APPS_LABELS_DATABASE "/opt/dbspace/.privilege_control_all_apps_id.db"
-#define SMACK_AVS_LABELS_DATABASE "/opt/dbspace/.privilege_control_all_avs_id.db"
-#define SMACK_PUBLIC_DIRS_DATABASE "/opt/dbspace/.privilege_control_public_dirs.db"
+#define SMACK_APPS_LABELS_DATABASE          "/opt/dbspace/.privilege_control_all_apps_id.db"
+#define SMACK_AVS_LABELS_DATABASE           "/opt/dbspace/.privilege_control_all_avs_id.db"
+#define SMACK_PUBLIC_DIRS_DATABASE          "/opt/dbspace/.privilege_control_public_dirs.db"
 #define SMACK_APPS_SETTINGS_LABELS_DATABASE "/opt/dbspace/.privilege_control_app_setting.db"
-#define SMACK_SETTINGS_DIRS_DATABASE "/opt/dbspace/.privilege_control_setting_dir.db"
+#define SMACK_SETTINGS_DIRS_DATABASE        "/opt/dbspace/.privilege_control_setting_dir.db"
 
 #define APP_TEST_SETTINGS_ASP1 "test-app-settings-asp1"
 #define APP_TEST_SETTINGS_ASP2 "test-app-settings-asp2"
-#define APP_TEST_AV_ASP1 "test-app-av-asp1"
-#define APP_TEST_AV_ASP2 "test-app-av-asp2"
+#define APP_TEST_AV_ASP1       "test-app-av-asp1"
+#define APP_TEST_AV_ASP2       "test-app-av-asp2"
 
 #define SOCK_PATH "/tmp/test-smack-socket"
 
-#define APP_GID 5000
-#define APP_UID 5000
+#define APP_GID       5000
+#define APP_UID       5000
 #define APP_USER_NAME "app"
-#define APP_HOME_DIR "/opt/home/app"
+#define APP_HOME_DIR  "/opt/home/app"
 
 #define APP_FRIEND_1 "app_friend_1"
 #define APP_FRIEND_2 "app_friend_2"
@@ -118,207 +118,217 @@ const char *PRIVS_OSP[] = { "test_privilege_control_rules_osp", NULL };
 
 // Rules from test_privilege_control_rules.smack
 const std::vector< std::vector<std::string> > rules = {
-        { APP_ID, "test_book_1", "r" },
-        { APP_ID, "test_book_2", "w" },
-        { APP_ID, "test_book_3", "x" },
-        { APP_ID, "test_book_4", "rw" },
-        { APP_ID, "test_book_5", "rx" },
-        { APP_ID, "test_book_6", "wx" },
-        { APP_ID, "test_book_7", "rwx" },
-        { "test_subject_1", APP_ID, "r" },
-        { "test_subject_2", APP_ID, "w" },
-        { "test_subject_3", APP_ID, "x" },
-        { "test_subject_4", APP_ID, "rw" },
-        { "test_subject_5", APP_ID, "rx" },
-        { "test_subject_6", APP_ID, "wx" },
-        { "test_subject_7", APP_ID, "rwx" },
-        { APP_ID, APPID_SHARED_DIR, "rwxat"}};
+    { APP_ID, "test_book_1", "r" },
+    { APP_ID, "test_book_2", "w" },
+    { APP_ID, "test_book_3", "x" },
+    { APP_ID, "test_book_4", "rw" },
+    { APP_ID, "test_book_5", "rx" },
+    { APP_ID, "test_book_6", "wx" },
+    { APP_ID, "test_book_7", "rwx" },
+    { "test_subject_1", APP_ID, "r" },
+    { "test_subject_2", APP_ID, "w" },
+    { "test_subject_3", APP_ID, "x" },
+    { "test_subject_4", APP_ID, "rw" },
+    { "test_subject_5", APP_ID, "rx" },
+    { "test_subject_6", APP_ID, "wx" },
+    { "test_subject_7", APP_ID, "rwx" },
+    { APP_ID, APPID_SHARED_DIR, "rwxat"}
+};
 
 // Rules from test_privilege_control_rules2.smack
 const std::vector< std::vector<std::string> > rules2 = {
-        { APP_ID, "test_book_8", "r" },
-        { APP_ID, "test_book_9", "w" },
-        { APP_ID, "test_book_10", "x" },
-        { APP_ID, "test_book_11", "rw" },
-        { APP_ID, "test_book_12", "rx" },
-        { APP_ID, "test_book_13", "wx" },
-        { APP_ID, "test_book_14", "rwx" },
-        { APP_ID, "test_book_15", "rwxat" },
-        { "test_subject_8", APP_ID, "r" },
-        { "test_subject_9", APP_ID, "w" },
-        { "test_subject_10", APP_ID, "x" },
-        { "test_subject_11", APP_ID, "rw" },
-        { "test_subject_12", APP_ID, "rx" },
-        { "test_subject_13", APP_ID, "wx" },
-        { "test_subject_14", APP_ID, "rwx" },
-        { "test_subject_15", APP_ID, "rwxat" }};
+    { APP_ID, "test_book_8", "r" },
+    { APP_ID, "test_book_9", "w" },
+    { APP_ID, "test_book_10", "x" },
+    { APP_ID, "test_book_11", "rw" },
+    { APP_ID, "test_book_12", "rx" },
+    { APP_ID, "test_book_13", "wx" },
+    { APP_ID, "test_book_14", "rwx" },
+    { APP_ID, "test_book_15", "rwxat" },
+    { "test_subject_8", APP_ID, "r" },
+    { "test_subject_9", APP_ID, "w" },
+    { "test_subject_10", APP_ID, "x" },
+    { "test_subject_11", APP_ID, "rw" },
+    { "test_subject_12", APP_ID, "rx" },
+    { "test_subject_13", APP_ID, "wx" },
+    { "test_subject_14", APP_ID, "rwx" },
+    { "test_subject_15", APP_ID, "rwxat" }
+};
 
 // Rules from test_privilege_control_rules_no_r.smack
 const std::vector< std::vector<std::string> > rules2_no_r = {
-        { APP_ID, "test_book_9", "w" },
-        { APP_ID, "test_book_10", "x" },
-        { APP_ID, "test_book_11", "w" },
-        { APP_ID, "test_book_12", "x" },
-        { APP_ID, "test_book_13", "wx" },
-        { APP_ID, "test_book_14", "wx" },
-        { APP_ID, "test_book_15", "wxat" },
-        { "test_subject_9", APP_ID, "w" },
-        { "test_subject_10", APP_ID, "x" },
-        { "test_subject_11", APP_ID, "w" },
-        { "test_subject_12", APP_ID, "x" },
-        { "test_subject_13", APP_ID, "wx" },
-        { "test_subject_14", APP_ID, "wx" },
-        { "test_subject_15", APP_ID, "wxat" }};
+    { APP_ID, "test_book_9", "w" },
+    { APP_ID, "test_book_10", "x" },
+    { APP_ID, "test_book_11", "w" },
+    { APP_ID, "test_book_12", "x" },
+    { APP_ID, "test_book_13", "wx" },
+    { APP_ID, "test_book_14", "wx" },
+    { APP_ID, "test_book_15", "wxat" },
+    { "test_subject_9", APP_ID, "w" },
+    { "test_subject_10", APP_ID, "x" },
+    { "test_subject_11", APP_ID, "w" },
+    { "test_subject_12", APP_ID, "x" },
+    { "test_subject_13", APP_ID, "wx" },
+    { "test_subject_14", APP_ID, "wx" },
+    { "test_subject_15", APP_ID, "wxat" }
+};
 
 // Rules from test_privilege_control_rules.smack
 // minus test_privilege_control_rules_no_r.smack
 const std::vector< std::vector<std::string> > rules2_r = {
-        { APP_ID, "test_book_8", "r" },
-        { APP_ID, "test_book_11", "r" },
-        { APP_ID, "test_book_12", "r" },
-        { APP_ID, "test_book_14", "r" },
-        { APP_ID, "test_book_15", "r" },
-        { "test_subject_8", APP_ID, "r" },
-        { "test_subject_11", APP_ID, "r" },
-        { "test_subject_12", APP_ID, "r" },
-        { "test_subject_14", APP_ID, "r" },
-        { "test_subject_15", APP_ID, "r" }};
+    { APP_ID, "test_book_8", "r" },
+    { APP_ID, "test_book_11", "r" },
+    { APP_ID, "test_book_12", "r" },
+    { APP_ID, "test_book_14", "r" },
+    { APP_ID, "test_book_15", "r" },
+    { "test_subject_8", APP_ID, "r" },
+    { "test_subject_11", APP_ID, "r" },
+    { "test_subject_12", APP_ID, "r" },
+    { "test_subject_14", APP_ID, "r" },
+    { "test_subject_15", APP_ID, "r" }
+};
 
 // Rules from test_privilege_control_rules_wgt.smack for wgt
 const std::vector< std::vector<std::string> > rules_wgt = {
-        { WGT_APP_ID, "test_book_8", "r" },
-        { WGT_APP_ID, "test_book_9", "w" },
-        { WGT_APP_ID, "test_book_10", "x" },
-        { WGT_APP_ID, "test_book_11", "rw" },
-        { WGT_APP_ID, "test_book_12", "rx" },
-        { WGT_APP_ID, "test_book_13", "wx" },
-        { WGT_APP_ID, "test_book_14", "rwx" },
-        { WGT_APP_ID, "test_book_15", "rwxat" },
-        { "test_subject_8", WGT_APP_ID, "r" },
-        { "test_subject_9", WGT_APP_ID, "w" },
-        { "test_subject_10", WGT_APP_ID, "x" },
-        { "test_subject_11", WGT_APP_ID, "rw" },
-        { "test_subject_12", WGT_APP_ID, "rx" },
-        { "test_subject_13", WGT_APP_ID, "wx" },
-        { "test_subject_14", WGT_APP_ID, "rwx" },
-        { "test_subject_15", WGT_APP_ID, "rwxat" }};
+    { WGT_APP_ID, "test_book_8", "r" },
+    { WGT_APP_ID, "test_book_9", "w" },
+    { WGT_APP_ID, "test_book_10", "x" },
+    { WGT_APP_ID, "test_book_11", "rw" },
+    { WGT_APP_ID, "test_book_12", "rx" },
+    { WGT_APP_ID, "test_book_13", "wx" },
+    { WGT_APP_ID, "test_book_14", "rwx" },
+    { WGT_APP_ID, "test_book_15", "rwxat" },
+    { "test_subject_8", WGT_APP_ID, "r" },
+    { "test_subject_9", WGT_APP_ID, "w" },
+    { "test_subject_10", WGT_APP_ID, "x" },
+    { "test_subject_11", WGT_APP_ID, "rw" },
+    { "test_subject_12", WGT_APP_ID, "rx" },
+    { "test_subject_13", WGT_APP_ID, "wx" },
+    { "test_subject_14", WGT_APP_ID, "rwx" },
+    { "test_subject_15", WGT_APP_ID, "rwxat" }
+};
 
 // Rules from test_privilege_control_rules_wgt.smack for wgt_partner
 const std::vector< std::vector<std::string> > rules_wgt_partner = {
-        { WGT_PARTNER_APP_ID, "test_book_8", "r" },
-        { WGT_PARTNER_APP_ID, "test_book_9", "w" },
-        { WGT_PARTNER_APP_ID, "test_book_10", "x" },
-        { WGT_PARTNER_APP_ID, "test_book_11", "rw" },
-        { WGT_PARTNER_APP_ID, "test_book_12", "rx" },
-        { WGT_PARTNER_APP_ID, "test_book_13", "wx" },
-        { WGT_PARTNER_APP_ID, "test_book_14", "rwx" },
-        { WGT_PARTNER_APP_ID, "test_book_15", "rwxat" },
-        { "test_subject_8", WGT_PARTNER_APP_ID, "r" },
-        { "test_subject_9", WGT_PARTNER_APP_ID, "w" },
-        { "test_subject_10", WGT_PARTNER_APP_ID, "x" },
-        { "test_subject_11", WGT_PARTNER_APP_ID, "rw" },
-        { "test_subject_12", WGT_PARTNER_APP_ID, "rx" },
-        { "test_subject_13", WGT_PARTNER_APP_ID, "wx" },
-        { "test_subject_14", WGT_PARTNER_APP_ID, "rwx" },
-        { "test_subject_15", WGT_PARTNER_APP_ID, "rwxat" }};
+    { WGT_PARTNER_APP_ID, "test_book_8", "r" },
+    { WGT_PARTNER_APP_ID, "test_book_9", "w" },
+    { WGT_PARTNER_APP_ID, "test_book_10", "x" },
+    { WGT_PARTNER_APP_ID, "test_book_11", "rw" },
+    { WGT_PARTNER_APP_ID, "test_book_12", "rx" },
+    { WGT_PARTNER_APP_ID, "test_book_13", "wx" },
+    { WGT_PARTNER_APP_ID, "test_book_14", "rwx" },
+    { WGT_PARTNER_APP_ID, "test_book_15", "rwxat" },
+    { "test_subject_8", WGT_PARTNER_APP_ID, "r" },
+    { "test_subject_9", WGT_PARTNER_APP_ID, "w" },
+    { "test_subject_10", WGT_PARTNER_APP_ID, "x" },
+    { "test_subject_11", WGT_PARTNER_APP_ID, "rw" },
+    { "test_subject_12", WGT_PARTNER_APP_ID, "rx" },
+    { "test_subject_13", WGT_PARTNER_APP_ID, "wx" },
+    { "test_subject_14", WGT_PARTNER_APP_ID, "rwx" },
+    { "test_subject_15", WGT_PARTNER_APP_ID, "rwxat" }
+};
 
 // Rules from test_privilege_control_rules_wgt.smack for wgt_platform
 const std::vector< std::vector<std::string> > rules_wgt_platform = {
-        { WGT_PLATFORM_APP_ID, "test_book_8", "r" },
-        { WGT_PLATFORM_APP_ID, "test_book_9", "w" },
-        { WGT_PLATFORM_APP_ID, "test_book_10", "x" },
-        { WGT_PLATFORM_APP_ID, "test_book_11", "rw" },
-        { WGT_PLATFORM_APP_ID, "test_book_12", "rx" },
-        { WGT_PLATFORM_APP_ID, "test_book_13", "wx" },
-        { WGT_PLATFORM_APP_ID, "test_book_14", "rwx" },
-        { WGT_PLATFORM_APP_ID, "test_book_15", "rwxat" },
-        { "test_subject_8", WGT_PLATFORM_APP_ID, "r" },
-        { "test_subject_9", WGT_PLATFORM_APP_ID, "w" },
-        { "test_subject_10", WGT_PLATFORM_APP_ID, "x" },
-        { "test_subject_11", WGT_PLATFORM_APP_ID, "rw" },
-        { "test_subject_12", WGT_PLATFORM_APP_ID, "rx" },
-        { "test_subject_13", WGT_PLATFORM_APP_ID, "wx" },
-        { "test_subject_14", WGT_PLATFORM_APP_ID, "rwx" },
-        { "test_subject_15", WGT_PLATFORM_APP_ID, "rwxat" }};
+    { WGT_PLATFORM_APP_ID, "test_book_8", "r" },
+    { WGT_PLATFORM_APP_ID, "test_book_9", "w" },
+    { WGT_PLATFORM_APP_ID, "test_book_10", "x" },
+    { WGT_PLATFORM_APP_ID, "test_book_11", "rw" },
+    { WGT_PLATFORM_APP_ID, "test_book_12", "rx" },
+    { WGT_PLATFORM_APP_ID, "test_book_13", "wx" },
+    { WGT_PLATFORM_APP_ID, "test_book_14", "rwx" },
+    { WGT_PLATFORM_APP_ID, "test_book_15", "rwxat" },
+    { "test_subject_8", WGT_PLATFORM_APP_ID, "r" },
+    { "test_subject_9", WGT_PLATFORM_APP_ID, "w" },
+    { "test_subject_10", WGT_PLATFORM_APP_ID, "x" },
+    { "test_subject_11", WGT_PLATFORM_APP_ID, "rw" },
+    { "test_subject_12", WGT_PLATFORM_APP_ID, "rx" },
+    { "test_subject_13", WGT_PLATFORM_APP_ID, "wx" },
+    { "test_subject_14", WGT_PLATFORM_APP_ID, "rwx" },
+    { "test_subject_15", WGT_PLATFORM_APP_ID, "rwxat" }
+};
 
 // Rules from test_privilege_control_rules_osp.smack for osp
 const std::vector< std::vector<std::string> > rules_osp = {
-        { OSP_APP_ID, "test_book_8", "r" },
-        { OSP_APP_ID, "test_book_9", "w" },
-        { OSP_APP_ID, "test_book_10", "x" },
-        { OSP_APP_ID, "test_book_11", "rw" },
-        { OSP_APP_ID, "test_book_12", "rx" },
-        { OSP_APP_ID, "test_book_13", "wx" },
-        { OSP_APP_ID, "test_book_14", "rwx" },
-        { OSP_APP_ID, "test_book_15", "rwxat" },
-        { "test_subject_8", OSP_APP_ID, "r" },
-        { "test_subject_9", OSP_APP_ID, "w" },
-        { "test_subject_10", OSP_APP_ID, "x" },
-        { "test_subject_11", OSP_APP_ID, "rw" },
-        { "test_subject_12", OSP_APP_ID, "rx" },
-        { "test_subject_13", OSP_APP_ID, "wx" },
-        { "test_subject_14", OSP_APP_ID, "rwx" },
-        { "test_subject_15", OSP_APP_ID, "rwxat" }};
+    { OSP_APP_ID, "test_book_8", "r" },
+    { OSP_APP_ID, "test_book_9", "w" },
+    { OSP_APP_ID, "test_book_10", "x" },
+    { OSP_APP_ID, "test_book_11", "rw" },
+    { OSP_APP_ID, "test_book_12", "rx" },
+    { OSP_APP_ID, "test_book_13", "wx" },
+    { OSP_APP_ID, "test_book_14", "rwx" },
+    { OSP_APP_ID, "test_book_15", "rwxat" },
+    { "test_subject_8", OSP_APP_ID, "r" },
+    { "test_subject_9", OSP_APP_ID, "w" },
+    { "test_subject_10", OSP_APP_ID, "x" },
+    { "test_subject_11", OSP_APP_ID, "rw" },
+    { "test_subject_12", OSP_APP_ID, "rx" },
+    { "test_subject_13", OSP_APP_ID, "wx" },
+    { "test_subject_14", OSP_APP_ID, "rwx" },
+    { "test_subject_15", OSP_APP_ID, "rwxat" }
+};
 
 // Rules from test_privilege_control_rules_osp.smack for osp_partner
 const std::vector< std::vector<std::string> > rules_osp_partner = {
-        { OSP_PARTNER_APP_ID, "test_book_8", "r" },
-        { OSP_PARTNER_APP_ID, "test_book_9", "w" },
-        { OSP_PARTNER_APP_ID, "test_book_10", "x" },
-        { OSP_PARTNER_APP_ID, "test_book_11", "rw" },
-        { OSP_PARTNER_APP_ID, "test_book_12", "rx" },
-        { OSP_PARTNER_APP_ID, "test_book_13", "wx" },
-        { OSP_PARTNER_APP_ID, "test_book_14", "rwx" },
-        { OSP_PARTNER_APP_ID, "test_book_15", "rwxat" },
-        { "test_subject_8", OSP_PARTNER_APP_ID, "r" },
-        { "test_subject_9", OSP_PARTNER_APP_ID, "w" },
-        { "test_subject_10", OSP_PARTNER_APP_ID, "x" },
-        { "test_subject_11", OSP_PARTNER_APP_ID, "rw" },
-        { "test_subject_12", OSP_PARTNER_APP_ID, "rx" },
-        { "test_subject_13", OSP_PARTNER_APP_ID, "wx" },
-        { "test_subject_14", OSP_PARTNER_APP_ID, "rwx" },
-        { "test_subject_15", OSP_PARTNER_APP_ID, "rwxat" }};
+    { OSP_PARTNER_APP_ID, "test_book_8", "r" },
+    { OSP_PARTNER_APP_ID, "test_book_9", "w" },
+    { OSP_PARTNER_APP_ID, "test_book_10", "x" },
+    { OSP_PARTNER_APP_ID, "test_book_11", "rw" },
+    { OSP_PARTNER_APP_ID, "test_book_12", "rx" },
+    { OSP_PARTNER_APP_ID, "test_book_13", "wx" },
+    { OSP_PARTNER_APP_ID, "test_book_14", "rwx" },
+    { OSP_PARTNER_APP_ID, "test_book_15", "rwxat" },
+    { "test_subject_8", OSP_PARTNER_APP_ID, "r" },
+    { "test_subject_9", OSP_PARTNER_APP_ID, "w" },
+    { "test_subject_10", OSP_PARTNER_APP_ID, "x" },
+    { "test_subject_11", OSP_PARTNER_APP_ID, "rw" },
+    { "test_subject_12", OSP_PARTNER_APP_ID, "rx" },
+    { "test_subject_13", OSP_PARTNER_APP_ID, "wx" },
+    { "test_subject_14", OSP_PARTNER_APP_ID, "rwx" },
+    { "test_subject_15", OSP_PARTNER_APP_ID, "rwxat" }
+};
 
 // Rules from test_privilege_control_rules_osp.smack for osp_platform
 const std::vector< std::vector<std::string> > rules_osp_platform = {
-        { OSP_PLATFORM_APP_ID, "test_book_8", "r" },
-        { OSP_PLATFORM_APP_ID, "test_book_9", "w" },
-        { OSP_PLATFORM_APP_ID, "test_book_10", "x" },
-        { OSP_PLATFORM_APP_ID, "test_book_11", "rw" },
-        { OSP_PLATFORM_APP_ID, "test_book_12", "rx" },
-        { OSP_PLATFORM_APP_ID, "test_book_13", "wx" },
-        { OSP_PLATFORM_APP_ID, "test_book_14", "rwx" },
-        { OSP_PLATFORM_APP_ID, "test_book_15", "rwxat" },
-        { "test_subject_8", OSP_PLATFORM_APP_ID, "r" },
-        { "test_subject_9", OSP_PLATFORM_APP_ID, "w" },
-        { "test_subject_10", OSP_PLATFORM_APP_ID, "x" },
-        { "test_subject_11", OSP_PLATFORM_APP_ID, "rw" },
-        { "test_subject_12", OSP_PLATFORM_APP_ID, "rx" },
-        { "test_subject_13", OSP_PLATFORM_APP_ID, "wx" },
-        { "test_subject_14", OSP_PLATFORM_APP_ID, "rwx" },
-        { "test_subject_15", OSP_PLATFORM_APP_ID, "rwxat" }};
+    { OSP_PLATFORM_APP_ID, "test_book_8", "r" },
+    { OSP_PLATFORM_APP_ID, "test_book_9", "w" },
+    { OSP_PLATFORM_APP_ID, "test_book_10", "x" },
+    { OSP_PLATFORM_APP_ID, "test_book_11", "rw" },
+    { OSP_PLATFORM_APP_ID, "test_book_12", "rx" },
+    { OSP_PLATFORM_APP_ID, "test_book_13", "wx" },
+    { OSP_PLATFORM_APP_ID, "test_book_14", "rwx" },
+    { OSP_PLATFORM_APP_ID, "test_book_15", "rwxat" },
+    { "test_subject_8", OSP_PLATFORM_APP_ID, "r" },
+    { "test_subject_9", OSP_PLATFORM_APP_ID, "w" },
+    { "test_subject_10", OSP_PLATFORM_APP_ID, "x" },
+    { "test_subject_11", OSP_PLATFORM_APP_ID, "rw" },
+    { "test_subject_12", OSP_PLATFORM_APP_ID, "rx" },
+    { "test_subject_13", OSP_PLATFORM_APP_ID, "wx" },
+    { "test_subject_14", OSP_PLATFORM_APP_ID, "rwx" },
+    { "test_subject_15", OSP_PLATFORM_APP_ID, "rwxat" }
+};
 
 namespace {
+typedef std::unique_ptr<smack_accesses,std::function<void (smack_accesses*)> > SmackUniquePtr;
 
-typedef std::unique_ptr<smack_accesses,std::function<void(smack_accesses*)>> SmackUniquePtr;
-
-const char* OSP_BLAHBLAH = "/usr/share/privilege-control/OSP_feature.blah.blahblah.smack";
-const char* WRT_BLAHBLAH = "/usr/share/privilege-control/WGT_blahblah.smack";
-const char* OTHER_BLAHBLAH = "/usr/share/privilege-control/blahblah.smack";
-const char* OSP_BLAHBLAH_DAC = "/usr/share/privilege-control/OSP_feature.blah.blahblah.dac";
-const char* WRT_BLAHBLAH_DAC = "/usr/share/privilege-control/WGT_blahblah.dac";
-const char* OTHER_BLAHBLAH_DAC = "/usr/share/privilege-control/blahblah.dac";
-const char* BLAHBLAH_FEATURE = "http://feature/blah/blahblah";
+const char *OSP_BLAHBLAH = "/usr/share/privilege-control/OSP_feature.blah.blahblah.smack";
+const char *WRT_BLAHBLAH = "/usr/share/privilege-control/WGT_blahblah.smack";
+const char *OTHER_BLAHBLAH = "/usr/share/privilege-control/blahblah.smack";
+const char *OSP_BLAHBLAH_DAC = "/usr/share/privilege-control/OSP_feature.blah.blahblah.dac";
+const char *WRT_BLAHBLAH_DAC = "/usr/share/privilege-control/WGT_blahblah.dac";
+const char *OTHER_BLAHBLAH_DAC = "/usr/share/privilege-control/blahblah.dac";
+const char *BLAHBLAH_FEATURE = "http://feature/blah/blahblah";
 
 /**
  * Check if every rule is true.
  * @return 1 if ALL rules in SMACK, 0 if ANY rule isn't
  */
-int test_have_all_accesses(const std::vector< std::vector<std::string> >& rules){
+int test_have_all_accesses(const std::vector< std::vector<std::string> > &rules)
+{
     int result;
-    for(uint i =0; i<rules.size();++i ){
+    for (uint i = 0; i < rules.size(); ++i) {
         result = smack_have_access(rules[i][0].c_str(),rules[i][1].c_str(),rules[i][2].c_str());
-        if (result !=1)
+        if (result != 1)
             return result;
     }
     return 1;
@@ -328,41 +338,42 @@ int test_have_all_accesses(const std::vector< std::vector<std::string> >& rules)
  * Check if every rule is true.
  * @return 1 if ANY rule in SMACK, 0 if
  */
-int test_have_any_accesses(const std::vector< std::vector<std::string> >& rules){
+int test_have_any_accesses(const std::vector< std::vector<std::string> > &rules)
+{
     int result;
-    for(uint i =0; i<rules.size();++i ){
+    for (uint i = 0; i < rules.size(); ++i) {
         result = smack_have_access(rules[i][0].c_str(),rules[i][1].c_str(),rules[i][2].c_str());
-        if (result ==1)
+        if (result == 1)
             return 1;
     }
     return 0;
 }
 
-int nftw_remove_labels(const char *fpath, const struct stat * /*sb*/,
-                               int /*typeflag*/, struct FTW * /*ftwbuf*/)
+int nftw_remove_labels(const char *fpath, const struct stat* /*sb*/,
+                       int /*typeflag*/, struct FTW* /*ftwbuf*/)
 {
-       smack_lsetlabel(fpath, NULL, SMACK_LABEL_ACCESS);
-       smack_lsetlabel(fpath, NULL, SMACK_LABEL_EXEC);
-       smack_lsetlabel(fpath, NULL, SMACK_LABEL_TRANSMUTE);
+    smack_lsetlabel(fpath, NULL, SMACK_LABEL_ACCESS);
+    smack_lsetlabel(fpath, NULL, SMACK_LABEL_EXEC);
+    smack_lsetlabel(fpath, NULL, SMACK_LABEL_TRANSMUTE);
 
-       return 0;
+    return 0;
 }
 
-int nftw_set_labels_non_app_dir(const char *fpath, const struct stat * /*sb*/,
-                               int /*typeflag*/, struct FTW * /*ftwbuf*/)
+int nftw_set_labels_non_app_dir(const char *fpath, const struct stat* /*sb*/,
+                                int /*typeflag*/, struct FTW* /*ftwbuf*/)
 {
-       smack_lsetlabel(fpath, CANARY_LABEL, SMACK_LABEL_ACCESS);
-       smack_lsetlabel(fpath, CANARY_LABEL, SMACK_LABEL_EXEC);
-       smack_lsetlabel(fpath, NULL, SMACK_LABEL_TRANSMUTE);
+    smack_lsetlabel(fpath, CANARY_LABEL, SMACK_LABEL_ACCESS);
+    smack_lsetlabel(fpath, CANARY_LABEL, SMACK_LABEL_EXEC);
+    smack_lsetlabel(fpath, NULL, SMACK_LABEL_TRANSMUTE);
 
-       return 0;
+    return 0;
 }
 
-int nftw_check_labels_non_app_dir(const char *fpath, const struct stat * /*sb*/,
-                               int /*typeflag*/, struct FTW * /*ftwbuf*/)
+int nftw_check_labels_non_app_dir(const char *fpath, const struct stat* /*sb*/,
+                                  int /*typeflag*/, struct FTW* /*ftwbuf*/)
 {
     int result;
-    charlabel;
+    char *label;
 
     /* ACCESS */
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
@@ -385,10 +396,10 @@ int nftw_check_labels_non_app_dir(const char *fpath, const struct stat * /*sb*/,
 }
 
 int nftw_check_labels_app_dir(const char *fpath, const struct stat *sb,
-                               int /*typeflag*/, struct FTW * /*ftwbuf*/)
+                              int /*typeflag*/, struct FTW* /*ftwbuf*/)
 {
     int result;
-    charlabel;
+    char *label;
 
     /* ACCESS */
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
@@ -404,9 +415,9 @@ int nftw_check_labels_app_dir(const char *fpath, const struct stat *sb,
         RUNNER_ASSERT_MSG(label != NULL, "EXEC label on " << fpath << " is not set");
         result = strcmp(APPID_DIR, label);
         RUNNER_ASSERT_MSG(result == 0, "EXEC label on executable file " << fpath << " is incorrect");
-    } else if(S_ISLNK(sb->st_mode)) {
+    } else if (S_ISLNK(sb->st_mode)) {
         struct stat buf;
-        chartarget = realpath(fpath, NULL);
+        char *target = realpath(fpath, NULL);
         RUNNER_ASSERT_MSG(0 == stat(target, &buf),"Stat failed for " << fpath);
         free(target);
         if (buf.st_mode != (buf.st_mode | S_IXUSR | S_IFREG)) {
@@ -428,10 +439,10 @@ int nftw_check_labels_app_dir(const char *fpath, const struct stat *sb,
 }
 
 int nftw_check_labels_app_shared_dir(const char *fpath, const struct stat *sb,
-                               int /*typeflag*/, struct FTW * /*ftwbuf*/)
+                                     int /*typeflag*/, struct FTW* /*ftwbuf*/)
 {
     int result;
-    charlabel;
+    char *label;
 
     /* ACCESS */
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
@@ -463,28 +474,28 @@ int nftw_check_labels_app_shared_dir(const char *fpath, const struct stat *sb,
 }
 
 int check_labels_dir(const char *fpath, const struct stat *sb,
-                     const char* labels_db_path, const char* dir_db_path,
-                     const characcess)
+                     const char *labels_db_path, const char *dir_db_path,
+                     const char *access)
 {
     int result;
-    charlabel;
-    charlabel_gen;
-    charscanf_label_format;
+    char *label;
+    char *label_gen;
+    char *scanf_label_format;
     char label_temp[SMACK_LABEL_LEN + 1];
-    FILEfile_db;
+    FILE *file_db;
 
     /* ACCESS */
     result = smack_lgetlabel(fpath, &label_gen, SMACK_LABEL_ACCESS);
     RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
     RUNNER_ASSERT_MSG(label_gen != NULL, "ACCESS label on " << fpath << " is not set");
 
-     /* EXEC */
+    /* EXEC */
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_EXEC);
-    if(result != 0){
+    if (result != 0) {
         free(label_gen);
         RUNNER_ASSERT_MSG(false, "Could not get label for the path");
     }
-    if(label != NULL){
+    if (label != NULL) {
         free(label_gen);
         free(label);
         RUNNER_ASSERT_MSG(false, "EXEC label on " << fpath << " is set.");
@@ -492,24 +503,24 @@ int check_labels_dir(const char *fpath, const struct stat *sb,
 
     /* TRANSMUTE */
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_TRANSMUTE);
-    if(result != 0){
+    if (result != 0) {
         free(label_gen);
         free(label);
         RUNNER_ASSERT_MSG(false, "Could not get label for the path");
     }
     if (S_ISDIR(sb->st_mode)) {
-        if(label == NULL){
+        if (label == NULL) {
             free(label_gen);
             free(label);
             RUNNER_ASSERT_MSG(false, "TRANSMUTE label on " << fpath << " is not set");
         }
         result = strcmp("TRUE", label);
-        if(result != 0){
+        if (result != 0) {
             free(label_gen);
             free(label);
             RUNNER_ASSERT_MSG(false, "TRANSMUTE label on " << fpath << " is not set to TRUE");
         }
-    } else if(label != NULL){
+    } else if (label != NULL) {
         free(label_gen);
         free(label);
         RUNNER_ASSERT_MSG(false, "TRANSMUTE label on " << fpath << " is set");
@@ -517,20 +528,20 @@ int check_labels_dir(const char *fpath, const struct stat *sb,
 
     free(label);
 
-    if(0 > asprintf(&scanf_label_format, "%%%ds\\n", SMACK_LABEL_LEN)){
+    if (0 > asprintf(&scanf_label_format, "%%%ds\\n", SMACK_LABEL_LEN)) {
         free(label_gen);
         RUNNER_ASSERT_MSG(false, "asprintf failed");
     }
 
     file_db = fopen(labels_db_path, "r");
-    if(file_db == NULL){
+    if (file_db == NULL) {
         free(label_gen);
         free(scanf_label_format);
         RUNNER_ASSERT_MSG(false, "Can not open database for apps");
     }
-    while(fscanf(file_db, scanf_label_format, label_temp)==1){
+    while (fscanf(file_db, scanf_label_format, label_temp) == 1) {
         result = smack_have_access(label_temp, label_gen, access);
-        if(result != 1){
+        if (result != 1) {
             fclose(file_db);
             free(label_gen);
             free(scanf_label_format);
@@ -542,14 +553,14 @@ int check_labels_dir(const char *fpath, const struct stat *sb,
     fclose(file_db);
 
     file_db = fopen(dir_db_path, "r");
-    if(file_db == NULL){
+    if (file_db == NULL) {
         free(label_gen);
         free(scanf_label_format);
         RUNNER_ASSERT_MSG(false, "Can not open database for dirs");
     }
     bool is_dir = false;
-    while(fscanf(file_db, scanf_label_format, label_temp)==1){
-        if(strcmp(label_gen, label_temp) == 0){
+    while (fscanf(file_db, scanf_label_format, label_temp) == 1) {
+        if (strcmp(label_gen, label_temp) == 0) {
             is_dir = true;
             break;
         }
@@ -564,24 +575,24 @@ int check_labels_dir(const char *fpath, const struct stat *sb,
 }
 
 int nftw_check_labels_app_public_dir(const char *fpath, const struct stat *sb,
-                               int /*typeflag*/, struct FTW * /*ftwbuf*/)
+                                     int /*typeflag*/, struct FTW* /*ftwbuf*/)
 {
     return check_labels_dir(fpath, sb,
-                            SMACK_APPS_LABELS_DATABASE,
-                            SMACK_PUBLIC_DIRS_DATABASE, "rx");
+        SMACK_APPS_LABELS_DATABASE,
+        SMACK_PUBLIC_DIRS_DATABASE, "rx");
 }
 
 int nftw_check_labels_app_settings_dir(const char *fpath, const struct stat *sb,
-                               int /*typeflag*/, struct FTW * /*ftwbuf*/)
+                                       int /*typeflag*/, struct FTW* /*ftwbuf*/)
 {
     return check_labels_dir(fpath, sb,
-                            SMACK_APPS_SETTINGS_LABELS_DATABASE,
-                            SMACK_SETTINGS_DIRS_DATABASE, "rwx");
+        SMACK_APPS_SETTINGS_LABELS_DATABASE,
+        SMACK_SETTINGS_DIRS_DATABASE, "rwx");
 }
 
-int file_exists(const charpath)
+int file_exists(const char *path)
 {
-    FILEfile = fopen(path, "r");
+    FILE *file = fopen(path, "r");
     if (file) {
         fclose(file);
         return 0;
@@ -589,14 +600,14 @@ int file_exists(const char* path)
     return -1;
 }
 
-void osp_blahblah_check(int line_no, const std::vector<std::string>rules)
+void osp_blahblah_check(int line_no, const std::vector<std::string> &rules)
 {
     std::ifstream smack_file(OSP_BLAHBLAH);
     RUNNER_ASSERT_MSG(smack_file, "Line: " << line_no << " Failed to create " << OSP_BLAHBLAH);
 
     auto it = rules.begin();
     std::string line;
-    while(std::getline(smack_file,line)) {
+    while (std::getline(smack_file,line)) {
         RUNNER_ASSERT_MSG(it != rules.end(), "Line: " << line_no << "Additional line in file: " << line);
         RUNNER_ASSERT_MSG(*it == line, "Line: " << line_no << " " << *it << "!=" << line);
         it++;
@@ -607,30 +618,30 @@ void osp_blahblah_check(int line_no, const std::vector<std::string>& rules)
     smack_file.close();
 }
 
-void osp_blahblah_dac_check(int line_no, const std::vector<unsigned>gids)
+void osp_blahblah_dac_check(int line_no, const std::vector<unsigned> &gids)
 {
-       std::ifstream dac_file(OSP_BLAHBLAH_DAC);
-       RUNNER_ASSERT_MSG(dac_file, "Line: " << line_no << " Failed to create " << OSP_BLAHBLAH_DAC);
-
-       auto it = gids.begin();
-       std::string line;
-       while(std::getline(dac_file,line)) {
-               std::istringstream is(line);
-               unsigned gid;
-               is >> gid;
-               RUNNER_ASSERT_MSG(it != gids.end(), "Line: " << line_no << "Additional line in file: " << gid);
-               RUNNER_ASSERT_MSG(*it == gid, "Line: " << line_no << " " << *it << "!=" << gid);
-               it++;
-       }
-
-       RUNNER_ASSERT_MSG(it == gids.end(), "Line: " << line_no << " Missing line in file: " << *it);
-
-       dac_file.close();
+    std::ifstream dac_file(OSP_BLAHBLAH_DAC);
+    RUNNER_ASSERT_MSG(dac_file, "Line: " << line_no << " Failed to create " << OSP_BLAHBLAH_DAC);
+
+    auto it = gids.begin();
+    std::string line;
+    while (std::getline(dac_file,line)) {
+        std::istringstream is(line);
+        unsigned gid;
+        is >> gid;
+        RUNNER_ASSERT_MSG(it != gids.end(), "Line: " << line_no << "Additional line in file: " << gid);
+        RUNNER_ASSERT_MSG(*it == gid, "Line: " << line_no << " " << *it << "!=" << gid);
+        it++;
+    }
+
+    RUNNER_ASSERT_MSG(it == gids.end(), "Line: " << line_no << " Missing line in file: " << *it);
+
+    dac_file.close();
 }
 
 void remove_smack_files()
 {
-       // TODO array
+    // TODO array
     unlink(OSP_BLAHBLAH);
     unlink(WRT_BLAHBLAH);
     unlink(OTHER_BLAHBLAH);
@@ -700,7 +711,7 @@ int cleaning_smack_database_files (void)
 
 void add_lables_to_db()
 {
-    FILEfile_db;
+    FILE *file_db;
 
     file_db = fopen(SMACK_AVS_LABELS_DATABASE, "a");
     RUNNER_ASSERT_MSG(file_db != NULL, "Error database file "
@@ -806,26 +817,25 @@ RUNNER_TEST(privilege_control04_add_permissions)
 {
     int result = app_add_permissions(APP_ID, PRIVS);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            " Error adding app permissions. Result: " << result);
+        " Error adding app permissions. Result: " << result);
 
     // Check if the accesses are realy applied..
     result = test_have_all_accesses(rules);
-    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions not added.");
 
     //// File exists?
     FILE *pFile = fopen(SMACK_RULES_DIR APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file NOT created!. Errno: " << errno);
+        "SMACK file NOT created!. Errno: " << errno);
 
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     int smack_file_length = ftell(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length>0,
-            "SMACK file empty, but privileges list was not empty.. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length > 0,
+        "SMACK file empty, but privileges list was not empty.. Errno: " << errno);
 
     if (pFile != NULL)
         fclose(pFile);
-
 }
 
 /**
@@ -839,143 +849,142 @@ RUNNER_CHILD_TEST(privilege_control06_revoke_permissions)
     // Revoke permissions
     result = app_revoke_permissions(APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
     result = app_revoke_permissions(WGT_APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-       "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
     result = app_revoke_permissions(WGT_PARTNER_APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-       "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
     result = app_revoke_permissions(WGT_PLATFORM_APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-       "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
     result = app_revoke_permissions(OSP_APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-       "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
     result = app_revoke_permissions(OSP_PARTNER_APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-       "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
     result = app_revoke_permissions(OSP_PLATFORM_APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-       "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
     // Are all the permissions revoked?
     result = test_have_any_accesses(rules);
-    RUNNER_ASSERT_MSG(result!=1, "Not all permisions revoked.");
+    RUNNER_ASSERT_MSG(result != 1, "Not all permisions revoked.");
     result = test_have_any_accesses(rules_wgt);
-    RUNNER_ASSERT_MSG(result==0, "Not all permisions revoked.");
+    RUNNER_ASSERT_MSG(result == 0, "Not all permisions revoked.");
     result = test_have_any_accesses(rules_wgt_partner);
-    RUNNER_ASSERT_MSG(result==0, "Not all permisions revoked.");
+    RUNNER_ASSERT_MSG(result == 0, "Not all permisions revoked.");
     result = test_have_any_accesses(rules_wgt_platform);
-    RUNNER_ASSERT_MSG(result==0, "Not all permisions revoked.");
+    RUNNER_ASSERT_MSG(result == 0, "Not all permisions revoked.");
 
     result = test_have_any_accesses(rules);
-    RUNNER_ASSERT_MSG(result!=1, "Not all permisions revoked.");
+    RUNNER_ASSERT_MSG(result != 1, "Not all permisions revoked.");
     result = test_have_any_accesses(rules_osp);
-    RUNNER_ASSERT_MSG(result==0, "Not all permisions revoked.");
+    RUNNER_ASSERT_MSG(result == 0, "Not all permisions revoked.");
     result = test_have_any_accesses(rules_osp_partner);
-    RUNNER_ASSERT_MSG(result==0, "Not all permisions revoked.");
+    RUNNER_ASSERT_MSG(result == 0, "Not all permisions revoked.");
     result = test_have_any_accesses(rules_osp_platform);
-    RUNNER_ASSERT_MSG(result==0, "Not all permisions revoked.");
+    RUNNER_ASSERT_MSG(result == 0, "Not all permisions revoked.");
 
     FILE *pFile = fopen(SMACK_RULES_DIR APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file removed!. Errno: " << errno);
+        "SMACK file removed!. Errno: " << errno);
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     int smack_file_length = ftell(pFile);
     if (pFile != NULL)
         fclose(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length==0,
-            "SMACK file not empty.. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length == 0,
+        "SMACK file not empty.. Errno: " << errno);
 
     pFile = fopen(SMACK_RULES_DIR WGT_APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file removed!. Errno: " << errno);
+        "SMACK file removed!. Errno: " << errno);
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     smack_file_length = ftell(pFile);
     if (pFile != NULL)
         fclose(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length==0,
-            "SMACK file not empty.. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length == 0,
+        "SMACK file not empty.. Errno: " << errno);
 
     pFile = fopen(SMACK_RULES_DIR WGT_PARTNER_APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file removed!. Errno: " << errno);
+        "SMACK file removed!. Errno: " << errno);
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     smack_file_length = ftell(pFile);
     if (pFile != NULL)
         fclose(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length==0,
-            "SMACK file not empty.. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length == 0,
+        "SMACK file not empty.. Errno: " << errno);
 
     pFile = fopen(SMACK_RULES_DIR WGT_PLATFORM_APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file removed!. Errno: " << errno);
+        "SMACK file removed!. Errno: " << errno);
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     smack_file_length = ftell(pFile);
     if (pFile != NULL)
         fclose(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length==0,
-            "SMACK file not empty.. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length == 0,
+        "SMACK file not empty.. Errno: " << errno);
 
     pFile = fopen(SMACK_RULES_DIR OSP_APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file removed!. Errno: " << errno);
+        "SMACK file removed!. Errno: " << errno);
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     smack_file_length = ftell(pFile);
     if (pFile != NULL)
         fclose(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length==0,
-            "SMACK file not empty.. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length == 0,
+        "SMACK file not empty.. Errno: " << errno);
 
     pFile = fopen(SMACK_RULES_DIR OSP_PARTNER_APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file removed!. Errno: " << errno);
+        "SMACK file removed!. Errno: " << errno);
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     smack_file_length = ftell(pFile);
     if (pFile != NULL)
         fclose(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length==0,
-            "SMACK file not empty.. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length == 0,
+        "SMACK file not empty.. Errno: " << errno);
 
     pFile = fopen(SMACK_RULES_DIR OSP_PLATFORM_APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file removed!. Errno: " << errno);
+        "SMACK file removed!. Errno: " << errno);
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     smack_file_length = ftell(pFile);
     if (pFile != NULL)
         fclose(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length==0,
-            "SMACK file not empty.. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length == 0,
+        "SMACK file not empty.. Errno: " << errno);
 }
 
-static void read_gids(std::set<unsigned> &set, const charfile_path)
+static void read_gids(std::set<unsigned> &set, const char *file_path)
 {
-       FILE *f = fopen(file_path, "r");
-       RUNNER_ASSERT_MSG(f != NULL, "Unable to open file " << file_path);
-       unsigned gid;
-       while (fscanf(f, "%u\n", &gid) == 1) {
-               set.insert(gid);
-       }
+    FILE *f = fopen(file_path, "r");
+    RUNNER_ASSERT_MSG(f != NULL, "Unable to open file " << file_path);
+    unsigned gid;
+    while (fscanf(f, "%u\n", &gid) == 1) {
+        set.insert(gid);
+    }
 }
 
 RUNNER_TEST(privilege_control05_add_shared_dir_readers)
 {
-
-#define  TEST_OBJ "TEST_OBJECT"
+#define  TEST_OBJ            "TEST_OBJECT"
 #define  TEST_OBJ_SOME_OTHER "TEST_OBJA"
-#define test_string_01 "TEST_raz TEST_OBJECT r-x-- -----"
-#define test_string_21 "TEST_trzy TEST_OBJA -wx--\n"
-#define test_string_22 "TEST_trzy TEST_OBJECT r-x-- -----\n"
+#define test_string_01       "TEST_raz TEST_OBJECT r-x-- -----"
+#define test_string_21       "TEST_trzy TEST_OBJA -wx--\n"
+#define test_string_22       "TEST_trzy TEST_OBJECT r-x-- -----\n"
 
     int result;
     int i;
@@ -987,7 +996,7 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
     const int READ_BUF_SIZE = 1000;
     char buf[READ_BUF_SIZE];
     FILE *file = NULL;
-    struct smack_accesses * rules = NULL;
+    struct smack_accesses *rules = NULL;
 
     //test what happens when the label is not correct SMACK label
     result = smack_accesses_new(&rules);
@@ -1006,7 +1015,6 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in smack_accesses_new. Error: " << result);
 
     for (i = 0; i < 3; i++) {
-
         (void)app_uninstall(app_labels[i]);
         result = app_install(app_labels[i]);
         RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in app_install.");
@@ -1016,14 +1024,14 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
         RUNNER_ASSERT_MSG(fd != -1, "Error in opening file " << path);
 
         if (i == 1) {
-                result = smack_accesses_add(rules,app_labels[i],TEST_OBJ,"wt");
-                RUNNER_ASSERT_MSG(result == 0, "smack_accesses_add failed");
+            result = smack_accesses_add(rules,app_labels[i],TEST_OBJ,"wt");
+            RUNNER_ASSERT_MSG(result == 0, "smack_accesses_add failed");
         }
         if (i == 2) {
-                smack_accesses_free(rules);
-                result = smack_accesses_new(&rules);
-                result = smack_accesses_add(rules,app_labels[i],TEST_OBJ_SOME_OTHER,"wx");
-                RUNNER_ASSERT_MSG(result == 0, "smack_accesses_add failed");
+            smack_accesses_free(rules);
+            result = smack_accesses_new(&rules);
+            result = smack_accesses_add(rules,app_labels[i],TEST_OBJ_SOME_OTHER,"wx");
+            RUNNER_ASSERT_MSG(result == 0, "smack_accesses_add failed");
         }
         result = smack_accesses_apply(rules);
         RUNNER_ASSERT_MSG(fd != -1, "smack_accesses_apply failed");
@@ -1033,7 +1041,6 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
 
         free(path);
         close(fd);
-
     }
 
     smack_accesses_free(rules);
@@ -1068,7 +1075,7 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
 
     RUNNER_ASSERT(NULL != fgets(buf, READ_BUF_SIZE, file));
     result = strcmp(buf, test_string_01);
-    RUNNER_ASSERT_MSG( result!=0, "add_shared_dir_readers ERROR, file not formatted" << path );
+    RUNNER_ASSERT_MSG( result != 0, "add_shared_dir_readers ERROR, file not formatted" << path );
 
     free(path);
     fclose(file);
@@ -1081,11 +1088,11 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
 
     RUNNER_ASSERT(NULL != fgets(buf, READ_BUF_SIZE, file));
     result = strcmp(buf, test_string_21);
-    RUNNER_ASSERT_MSG( result==0, "add_shared_dir_readers ERROR, file not formatted" );
+    RUNNER_ASSERT_MSG( result == 0, "add_shared_dir_readers ERROR, file not formatted" );
 
     RUNNER_ASSERT(NULL != fgets(buf, READ_BUF_SIZE, file));
     result = strcmp(buf, test_string_22);
-    RUNNER_ASSERT_MSG( result==0, "add_shared_dir_readers ERROR, file not formatted" );
+    RUNNER_ASSERT_MSG( result == 0, "add_shared_dir_readers ERROR, file not formatted" );
 
     free(path);
     fclose(file);
@@ -1096,35 +1103,36 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
  * Set APP privileges.
  */
 
-void check_groups(const char* dac_file) {
-       std::set<unsigned> groups_check;
-       read_gids(groups_check, LIBPRIVILEGE_APP_GROUP_LIST);
-       read_gids(groups_check, dac_file);
-
-       int groups_cnt = getgroups(0, NULL);
-       RUNNER_ASSERT_MSG(groups_cnt > 0, "Wrong number of supplementary groupsCnt");
-       gid_t *groups_list = (gid_t *) calloc(groups_cnt, sizeof(gid_t));
-       RUNNER_ASSERT_MSG(groups_list != NULL, "Memory allocation failed");
-       RUNNER_ASSERT(-1 != getgroups(groups_cnt, groups_list));
-
-       for (int i = 0; i < groups_cnt; ++i) {
-               //getgroups() can return multiple number of the same group
-               //they are returned in sequence, so we will given number when last
-               //element of this number is reached
-               if( (i < groups_cnt - 1) && (groups_list[i+1] == groups_list[i]))
-                       continue;
-               if (groups_check.erase(groups_list[i]) == 0) {
-                       // getgroups() may also return process' main group
-                       if (groups_list[i] != getgid())
-                               RUNNER_ASSERT_MSG(false, "Application belongs to unknown group (GID=" << groups_list[i] << ")");
-               }
-       }
-       free(groups_list);
-       std::string groups_left;
-       for (std::set<unsigned>::iterator it = groups_check.begin(); it != groups_check.end(); it++) {
-               groups_left.append(std::to_string(*it)).append(" ");
-       }
-       RUNNER_ASSERT_MSG(groups_check.empty(), "Application doesn't belong to some required groups: " << groups_left);
+void check_groups(const char *dac_file)
+{
+    std::set<unsigned> groups_check;
+    read_gids(groups_check, LIBPRIVILEGE_APP_GROUP_LIST);
+    read_gids(groups_check, dac_file);
+
+    int groups_cnt = getgroups(0, NULL);
+    RUNNER_ASSERT_MSG(groups_cnt > 0, "Wrong number of supplementary groupsCnt");
+    gid_t *groups_list = (gid_t*) calloc(groups_cnt, sizeof(gid_t));
+    RUNNER_ASSERT_MSG(groups_list != NULL, "Memory allocation failed");
+    RUNNER_ASSERT(-1 != getgroups(groups_cnt, groups_list));
+
+    for (int i = 0; i < groups_cnt; ++i) {
+        //getgroups() can return multiple number of the same group
+        //they are returned in sequence, so we will given number when last
+        //element of this number is reached
+        if ((i < groups_cnt - 1) && (groups_list[i + 1] == groups_list[i]))
+            continue;
+        if (groups_check.erase(groups_list[i]) == 0) {
+            // getgroups() may also return process' main group
+            if (groups_list[i] != getgid())
+                RUNNER_ASSERT_MSG(false, "Application belongs to unknown group (GID=" << groups_list[i] << ")");
+        }
+    }
+    free(groups_list);
+    std::string groups_left;
+    for (std::set<unsigned>::iterator it = groups_check.begin(); it != groups_check.end(); it++) {
+        groups_left.append(std::to_string(*it)).append(" ");
+    }
+    RUNNER_ASSERT_MSG(groups_check.empty(), "Application doesn't belong to some required groups: " << groups_left);
 }
 
 RUNNER_CHILD_TEST(privilege_control05_set_app_privilege)
@@ -1146,7 +1154,7 @@ RUNNER_CHILD_TEST(privilege_control05_set_app_privilege)
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in set_app_privilege. Error: " << result);
 
     // Check if SMACK label really set
-    char * label;
+    char *label;
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
@@ -1178,13 +1186,13 @@ RUNNER_CHILD_TEST(privilege_control05_set_app_privilege_wgt)
         " Error enabling app permissions. Result: " << result);
 
     result = test_have_all_accesses(rules_wgt);
-    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions not added.");
 
     result = set_app_privilege(WGT_APP_ID, "wgt", WGT_APP_PATH);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in set_app_privilege. Error: " << result);
 
     // Check if SMACK label really set
-    char * label;
+    char *label;
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
@@ -1193,8 +1201,6 @@ RUNNER_CHILD_TEST(privilege_control05_set_app_privilege_wgt)
 
 
     check_groups(LIBPRIVILEGE_TEST_DAC_FILE_WGT);
-
-
 }
 
 /**
@@ -1209,13 +1215,13 @@ RUNNER_CHILD_TEST(privilege_control05_set_app_privilege_wgt_partner)
         " Error enabling app permissions. Result: " << result);
 
     result = test_have_all_accesses(rules_wgt_partner);
-    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions not added.");
 
     result = set_app_privilege(WGT_PARTNER_APP_ID, "wgt_partner", WGT_PARTNER_APP_PATH);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in set_app_privilege. Error: " << result);
 
     // Check if SMACK label really set
-    char * label;
+    char *label;
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
@@ -1237,13 +1243,13 @@ RUNNER_CHILD_TEST(privilege_control05_set_app_privilege_wgt_platform)
         " Error enabling app permissions. Result: " << result);
 
     result = test_have_all_accesses(rules_wgt_platform);
-    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions not added.");
 
     result = set_app_privilege(WGT_PLATFORM_APP_ID, "wgt_platform", WGT_PLATFORM_APP_PATH);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in set_app_privilege. Error: " << result);
 
     // Check if SMACK label really set
-    char * label;
+    char *label;
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
@@ -1265,13 +1271,13 @@ RUNNER_CHILD_TEST(privilege_control05_set_app_privilege_osp)
         " Error enabling app permissions. Result: " << result);
 
     result = test_have_all_accesses(rules_osp);
-    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions not added.");
 
     result = set_app_privilege(OSP_APP_ID, NULL, OSP_APP_PATH);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in set_app_privilege. Error: " << result);
 
     // Check if SMACK label really set
-    char * label;
+    char *label;
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
@@ -1293,13 +1299,13 @@ RUNNER_CHILD_TEST(privilege_control05_set_app_privilege_osp_partner)
         " Error enabling app permissions. Result: " << result);
 
     result = test_have_all_accesses(rules_osp_partner);
-    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions not added.");
 
     result = set_app_privilege(OSP_PARTNER_APP_ID, NULL, OSP_PARTNER_APP_PATH);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in set_app_privilege. Error: " << result);
 
     // Check if SMACK label really set
-    char * label;
+    char *label;
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
@@ -1321,13 +1327,13 @@ RUNNER_CHILD_TEST(privilege_control05_set_app_privilege_osp_platform)
         " Error enabling app permissions. Result: " << result);
 
     result = test_have_all_accesses(rules_osp_platform);
-    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions not added.");
 
     result = set_app_privilege(OSP_PLATFORM_APP_ID, NULL, OSP_PLATFORM_APP_PATH);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in set_app_privilege. Error: " << result);
 
     // Check if SMACK label really set
-    char * label;
+    char *label;
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
@@ -1411,38 +1417,38 @@ RUNNER_TEST(privilege_control11_add_api_feature)
     result = add_api_feature(APP_TYPE_OSP, NULL, NULL, NULL, 0);
     RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
 
-    result = add_api_feature(APP_TYPE_OSP,"" , NULL, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP,"", NULL, NULL, 0);
     RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
 
 
     // already existing features
-    result = add_api_feature(APP_TYPE_OSP,"http://tizen.org/privilege/messaging.read" , NULL, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP,"http://tizen.org/privilege/messaging.read", NULL, NULL, 0);
     RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
 
-    result = add_api_feature(APP_TYPE_WGT,"http://tizen.org/privilege/messaging.sms" , NULL, NULL, 0);
+    result = add_api_feature(APP_TYPE_WGT,"http://tizen.org/privilege/messaging.sms", NULL, NULL, 0);
     RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
 
-    result = add_api_feature(APP_TYPE_OTHER,"http://tizen.org/privilege/messaging" , NULL, NULL, 0);
+    result = add_api_feature(APP_TYPE_OTHER,"http://tizen.org/privilege/messaging", NULL, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
 
-    result = add_api_feature(APP_TYPE_OTHER,"http://tizen.org/messaging" , NULL, NULL, 0);
+    result = add_api_feature(APP_TYPE_OTHER,"http://tizen.org/messaging", NULL, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
 
-    result = add_api_feature(APP_TYPE_OTHER,"http://messaging" , NULL, NULL, 0);
+    result = add_api_feature(APP_TYPE_OTHER,"http://messaging", NULL, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
 
-    result = add_api_feature(APP_TYPE_OTHER,"messaging.read" , NULL, NULL, 0);
+    result = add_api_feature(APP_TYPE_OTHER,"messaging.read", NULL, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
 
 
     // empty features
-    result = add_api_feature(APP_TYPE_OSP,"blahblah" , NULL, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP,"blahblah", NULL, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
 
-    result = add_api_feature(APP_TYPE_WGT,"blahblah" , NULL, NULL, 0);
+    result = add_api_feature(APP_TYPE_WGT,"blahblah", NULL, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
 
-    result = add_api_feature(APP_TYPE_OTHER,"blahblah" , NULL, NULL, 0);
+    result = add_api_feature(APP_TYPE_OTHER,"blahblah", NULL, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
 
 
@@ -1458,18 +1464,18 @@ RUNNER_TEST(privilege_control11_add_api_feature)
 
 
     // empty rules
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , { NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, { NULL }, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     result = file_exists(OSP_BLAHBLAH);
     RUNNER_ASSERT(result == -1);
 
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){ "", NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { "", NULL }, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     result = file_exists(OSP_BLAHBLAH);
     RUNNER_ASSERT(result == 0);
     remove_smack_files();
 
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){ " \t\n", "\t \n", "\n\t  ", NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { " \t\n", "\t \n", "\n\t  ", NULL }, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     result = file_exists(OSP_BLAHBLAH);
     RUNNER_ASSERT(result == 0);
@@ -1477,74 +1483,77 @@ RUNNER_TEST(privilege_control11_add_api_feature)
 
 
     // malformed rules
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){ "malformed", NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { "malformed", NULL }, NULL, 0);
     RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
     result = file_exists(OSP_BLAHBLAH);
     RUNNER_ASSERT(result == -1);
 
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){ "malformed malformed", NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { "malformed malformed", NULL }, NULL, 0);
     RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
     result = file_exists(OSP_BLAHBLAH);
     RUNNER_ASSERT(result == -1);
 
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){ "-malformed malformed rwxat", NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { "-malformed malformed rwxat", NULL }, NULL, 0);
     RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
     result = file_exists(OSP_BLAHBLAH);
     RUNNER_ASSERT(result == -1);
 
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){ "~/\"\\ malformed rwxat", NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { "~/\"\\ malformed rwxat", NULL }, NULL, 0);
     RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
     result = file_exists(OSP_BLAHBLAH);
     RUNNER_ASSERT(result == -1);
 
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){ "subject object rwxat something else", NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { "subject object rwxat something else", NULL }, NULL, 0);
     RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
     result = file_exists(OSP_BLAHBLAH);
     RUNNER_ASSERT(result == -1);
 
 
     // correct rules
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){ "malformed malformed maaaaaalformed", NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { "malformed malformed maaaaaalformed", NULL }, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     osp_blahblah_check(__LINE__, { "malformed malformed r--a- -----" });
     remove_smack_files();
 
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){ "subject object foo", NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) { "subject object foo", NULL }, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     osp_blahblah_check(__LINE__, { "subject object ----- -----" });
     remove_smack_files();
 
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){
-        "subject    object\t rwxat",
-        " \t \n",
-        "subject2\tobject2 txarw",
-        "",
-        NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) {
+            "subject    object\t rwxat",
+            " \t \n",
+            "subject2\tobject2 txarw",
+            "",
+            NULL
+        }, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     osp_blahblah_check(__LINE__, { "subject object rwxat -----", "subject2 object2 rwxat -----"});
     remove_smack_files();
 
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){
-        "Sub::jE,ct object a-RwX",
-        NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) {
+            "Sub::jE,ct object a-RwX",
+            NULL
+        }, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     osp_blahblah_check(__LINE__, { "Sub::jE,ct object rwxa- -----"});
     remove_smack_files();
 
     // TODO For now identical/complementary rules are not merged.
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){
-        "subject object rwxat",
-        " \t \n",
-        "subject object txarw",
-        "",
-        NULL }, NULL, 0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) {
+            "subject object rwxat",
+            " \t \n",
+            "subject object txarw",
+            "",
+            NULL
+        }, NULL, 0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     osp_blahblah_check(__LINE__, { "subject object rwxat -----", "subject object rwxat -----"});
     remove_smack_files();
 
 
     // empty group ids
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){"a a a",NULL},(const gid_t[]){0,1,2},0);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) {"a a a",NULL},(const gid_t[]) {0,1,2},0);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     osp_blahblah_check(__LINE__, { "a a ---a- -----"});
     result = file_exists(OSP_BLAHBLAH_DAC);
@@ -1553,20 +1562,20 @@ RUNNER_TEST(privilege_control11_add_api_feature)
 
 
     // valid group ids
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){"a a a",NULL},(const gid_t[]){0,1,2},3);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) {"a a a",NULL},(const gid_t[]) {0,1,2},3);
     printf("%d \n", result);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     osp_blahblah_check(__LINE__, { "a a ---a- -----"});
     osp_blahblah_dac_check(__LINE__, {0,1,2});
     remove_smack_files();
 
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){"a a a",NULL},(const gid_t[]){0,1,2},1);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) {"a a a",NULL},(const gid_t[]) {0,1,2},1);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     osp_blahblah_check(__LINE__, { "a a ---a- -----"});
     osp_blahblah_dac_check(__LINE__, {0});
     remove_smack_files();
 
-    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE , (const char*[]){"a a a",NULL},(const gid_t[]){1,1,1},3);
+    result = add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE, (const char*[]) {"a a a",NULL},(const gid_t[]) {1,1,1},3);
     RUNNER_ASSERT(result == PC_OPERATION_SUCCESS);
     osp_blahblah_check(__LINE__, { "a a ---a- -----"});
     osp_blahblah_dac_check(__LINE__, {1,1,1});
@@ -1587,7 +1596,7 @@ RUNNER_TEST(privilege_control01_app_install)
     app_uninstall(APP_ID);
 
     result = app_install(APP_ID);
-    RUNNER_ASSERT_MSG(result == 0, "app_install returned " << result <<". Errno: " << strerror(errno));
+    RUNNER_ASSERT_MSG(result == 0, "app_install returned " << result << ". Errno: " << strerror(errno));
 
     // checking if file really exists
     fd = open(SMACK_RULES_DIR APP_ID, O_RDONLY);
@@ -1597,7 +1606,7 @@ RUNNER_TEST(privilege_control01_app_install)
 
     // try install second time app with the same ID - it should pass.
     result = app_install(APP_ID);
-    RUNNER_ASSERT_MSG(result == 0, "app_install returned " << result <<". Errno: " << strerror(errno));
+    RUNNER_ASSERT_MSG(result == 0, "app_install returned " << result << ". Errno: " << strerror(errno));
 }
 
 /*
@@ -1610,7 +1619,7 @@ RUNNER_TEST(privilege_control07_app_uninstall)
     int fd = -1;
 
     result = app_uninstall(APP_ID);
-    RUNNER_ASSERT_MSG(result == 0, "app_uninstall returned " << result <<". Errno: " << strerror(errno));
+    RUNNER_ASSERT_MSG(result == 0, "app_uninstall returned " << result << ". Errno: " << strerror(errno));
 
     // checking if file really exists
     fd = open(SMACK_RULES_DIR APP_ID, O_RDONLY);
@@ -1619,7 +1628,8 @@ RUNNER_TEST(privilege_control07_app_uninstall)
     free(path);
 }
 
-void checkOnlyAvAccess(const char* av_id, const char* app_id, const char* comment){
+void checkOnlyAvAccess(const char *av_id, const char *app_id, const char *comment)
+{
     int result;
     result = smack_have_access(av_id, app_id, "rwx");
     RUNNER_ASSERT_MSG(result == 1,
@@ -1652,14 +1662,14 @@ RUNNER_TEST(privilege_control10_app_register_av)
 
     // Adding two apps before antivir
     result = app_install(APP_TEST_APP_1);
-    RUNNER_ASSERT_MSG(result == 0, "app_install returned " << result <<". Errno: " << strerror(errno));
+    RUNNER_ASSERT_MSG(result == 0, "app_install returned " << result << ". Errno: " << strerror(errno));
 
     result = app_install(APP_TEST_APP_2);
-    RUNNER_ASSERT_MSG(result == 0, "app_install returned " << result <<". Errno: " << strerror(errno));
+    RUNNER_ASSERT_MSG(result == 0, "app_install returned " << result << ". Errno: " << strerror(errno));
 
     // Adding antivir
     result = app_register_av(APP_TEST_AV_1);
-    RUNNER_ASSERT_MSG(result == 0, "app_register_av returned " << result <<". Errno: " << strerror(errno));
+    RUNNER_ASSERT_MSG(result == 0, "app_register_av returned " << result << ". Errno: " << strerror(errno));
 
     // Checking added apps accesses
     checkOnlyAvAccess(APP_TEST_AV_1, APP_TEST_APP_1, "app_register_av(APP_TEST_AV_1)");
@@ -1667,7 +1677,7 @@ RUNNER_TEST(privilege_control10_app_register_av)
 
     // Adding third app
     result = app_install(APP_TEST_APP_3);
-    RUNNER_ASSERT_MSG(result == 0, "app_install returned " << result <<". Errno: " << strerror(errno));
+    RUNNER_ASSERT_MSG(result == 0, "app_install returned " << result << ". Errno: " << strerror(errno));
 
     // Checking app accesses
     checkOnlyAvAccess(APP_TEST_AV_1, APP_TEST_APP_1, "app_install(APP_TEST_APP_3)");
@@ -1676,7 +1686,7 @@ RUNNER_TEST(privilege_control10_app_register_av)
 
     // Adding second antivir
     result = app_register_av(APP_TEST_AV_2);
-    RUNNER_ASSERT_MSG(result == 0, "app_register_av returned " << result <<". Errno: " << strerror(errno));
+    RUNNER_ASSERT_MSG(result == 0, "app_register_av returned " << result << ". Errno: " << strerror(errno));
 
     // Checking app accesses
     checkOnlyAvAccess(APP_TEST_AV_1, APP_TEST_APP_1, "app_register_av(APP_TEST_AV_2)");
@@ -1709,26 +1719,26 @@ RUNNER_TEST(privilege_control11_app_enable_permissions)
 
     result = app_revoke_permissions(APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
     result = app_enable_permissions(APP_ID, APP_TYPE_OTHER, PRIVS2, 1);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            " Error enabling app permissions. Result: " << result);
+        " Error enabling app permissions. Result: " << result);
 
     // Check if the accesses are realy applied..
     result = test_have_all_accesses(rules2);
-    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions not added.");
 
     //// File exists?
     pFile = fopen(SMACK_RULES_DIR APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file NOT created!. Errno: " << errno);
+        "SMACK file NOT created!. Errno: " << errno);
 
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     smack_file_length = ftell(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length>0,
-            "SMACK file empty with persistant mode 1. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length > 0,
+        "SMACK file empty with persistant mode 1. Errno: " << errno);
 
     if (pFile != NULL)
         fclose(pFile);
@@ -1736,7 +1746,7 @@ RUNNER_TEST(privilege_control11_app_enable_permissions)
     // Clean up
     result = app_revoke_permissions(APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
 /**
  * Test - Enabling all permissions with persistant mode disabled
@@ -1744,22 +1754,22 @@ RUNNER_TEST(privilege_control11_app_enable_permissions)
 
     result = app_enable_permissions(APP_ID, APP_TYPE_OTHER, PRIVS2, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            " Error enabling app permissions. Result: " << result);
+        " Error enabling app permissions. Result: " << result);
 
     // Check if the accesses are realy applied..
     result = test_have_all_accesses(rules2);
-    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions not added.");
 
     //// File exists?
     pFile = fopen(SMACK_RULES_DIR APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file NOT created!. Errno: " << errno);
+        "SMACK file NOT created!. Errno: " << errno);
 
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     smack_file_length = ftell(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length==0,
-            "SMACK file not empty with persistant mode 0. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length == 0,
+        "SMACK file not empty with persistant mode 0. Errno: " << errno);
 
     if (pFile != NULL)
         fclose(pFile);
@@ -1767,7 +1777,7 @@ RUNNER_TEST(privilege_control11_app_enable_permissions)
     // Clean up
     result = app_revoke_permissions(APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
 /**
  * Test - Enabling all permissions in two complementary files
@@ -1775,22 +1785,22 @@ RUNNER_TEST(privilege_control11_app_enable_permissions)
 
     result = app_enable_permissions(APP_ID, APP_TYPE_OTHER, PRIVS2_R_AND_NO_R, 1);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            " Error enabling app permissions. Result: " << result);
+        " Error enabling app permissions. Result: " << result);
 
     // Check if the accesses are realy applied..
     result = test_have_all_accesses(rules2);
-    RUNNER_ASSERT_MSG(result==1, "Permissions not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions not added.");
 
     //// File exists?
     pFile = fopen(SMACK_RULES_DIR APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file NOT created!. Errno: " << errno);
+        "SMACK file NOT created!. Errno: " << errno);
 
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     smack_file_length = ftell(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length>0,
-            "SMACK file empty with persistant mode 1. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length > 0,
+        "SMACK file empty with persistant mode 1. Errno: " << errno);
 
     if (pFile != NULL)
         fclose(pFile);
@@ -1798,7 +1808,7 @@ RUNNER_TEST(privilege_control11_app_enable_permissions)
     // Clean up
     result = app_revoke_permissions(APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
 /**
  * Test - Enabling some permissions and then enabling complementary permissions
@@ -1807,22 +1817,22 @@ RUNNER_TEST(privilege_control11_app_enable_permissions)
     // Enable permission for rules 2 no r
     result = app_enable_permissions(APP_ID, APP_TYPE_OTHER, PRIVS2_NO_R, 1);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            " Error enabling app permissions without r. Result: " << result);
+        " Error enabling app permissions without r. Result: " << result);
 
     // Check if the accesses are realy applied..
     result = test_have_all_accesses(rules2_no_r);
-    RUNNER_ASSERT_MSG(result==1, "Permissions without r not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions without r not added.");
 
     //// File exists?
     pFile = fopen(SMACK_RULES_DIR APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file NOT created!. Errno: " << errno);
+        "SMACK file NOT created!. Errno: " << errno);
 
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     smack_file_length = ftell(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length>0,
-            "SMACK file empty with persistant mode 1. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length > 0,
+        "SMACK file empty with persistant mode 1. Errno: " << errno);
 
     if (pFile != NULL)
         fclose(pFile);
@@ -1830,16 +1840,16 @@ RUNNER_TEST(privilege_control11_app_enable_permissions)
     // Enable permission for rules 2
     result = app_enable_permissions(APP_ID, APP_TYPE_OTHER, PRIVS2, 1);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            " Error enabling app all permissions. Result: " << result);
+        " Error enabling app all permissions. Result: " << result);
 
     // Check if the accesses are realy applied..
     result = test_have_all_accesses(rules2);
-    RUNNER_ASSERT_MSG(result==1, "Permissions all not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions all not added.");
 
     // Clean up
     result = app_revoke_permissions(APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
 /**
  * Test - Enabling some permissions and then enabling all permissions
@@ -1848,22 +1858,22 @@ RUNNER_TEST(privilege_control11_app_enable_permissions)
     // Enable permission for rules 2 no r
     result = app_enable_permissions(APP_ID, APP_TYPE_OTHER, PRIVS2_NO_R, 1);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            " Error enabling app permissions without r. Result: " << result);
+        " Error enabling app permissions without r. Result: " << result);
 
     // Check if the accesses are realy applied..
     result = test_have_all_accesses(rules2_no_r);
-    RUNNER_ASSERT_MSG(result==1, "Permissions without r not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions without r not added.");
 
     //// File exists?
     pFile = fopen(SMACK_RULES_DIR APP_ID, "rb");
     RUNNER_ASSERT_MSG(pFile != NULL,
-            "SMACK file NOT created!. Errno: " << errno);
+        "SMACK file NOT created!. Errno: " << errno);
 
     //// Is it empty?
     fseek(pFile, 0L, SEEK_END);
     smack_file_length = ftell(pFile);
-    RUNNER_ASSERT_MSG(smack_file_length>0,
-            "SMACK file empty with persistant mode 1. Errno: " << errno);
+    RUNNER_ASSERT_MSG(smack_file_length > 0,
+        "SMACK file empty with persistant mode 1. Errno: " << errno);
 
     if (pFile != NULL)
         fclose(pFile);
@@ -1871,16 +1881,16 @@ RUNNER_TEST(privilege_control11_app_enable_permissions)
     // Enable permission for rules 2
     result = app_enable_permissions(APP_ID, APP_TYPE_OTHER, PRIVS2_R, 1);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            " Error enabling app permissions with only r. Result: " << result);
+        " Error enabling app permissions with only r. Result: " << result);
 
     // Check if the accesses are realy applied..
     result = test_have_all_accesses(rules2);
-    RUNNER_ASSERT_MSG(result==1, "Permissions with only r not added.");
+    RUNNER_ASSERT_MSG(result == 1, "Permissions with only r not added.");
 
     // Clean up
     result = app_revoke_permissions(APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 }
 
 /*
@@ -1987,7 +1997,6 @@ RUNNER_TEST(privilege_control11_app_enable_permissions)
 
 RUNNER_TEST(privilege_control13_app_reset_permissions)
 {
-
     int result;
 
 /**
@@ -1997,22 +2006,21 @@ RUNNER_TEST(privilege_control13_app_reset_permissions)
     // Prepare permissions to reset
     result = app_enable_permissions(APP_ID, APP_TYPE_OTHER, PRIVS2, 1);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            " Error adding app permissions. Result: " << result);
+        " Error adding app permissions. Result: " << result);
 
     // Reset permissions
     result = app_reset_permissions(APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error reseting app permissions. Result: " << result);
+        "Error reseting app permissions. Result: " << result);
 
     // Are all second permissions not disabled?
     result = test_have_all_accesses(rules2);
-    RUNNER_ASSERT_MSG(result==1, "Not all permissions added.");
+    RUNNER_ASSERT_MSG(result == 1, "Not all permissions added.");
 
     // Disable permissions
     result = app_revoke_permissions(APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error disabling app permissions. Result: " << result);
-
+        "Error disabling app permissions. Result: " << result);
 }
 
 /**
@@ -2029,10 +2037,10 @@ RUNNER_TEST(privilege_control14_app_add_friend)
 
     result = app_revoke_permissions(APP_FRIEND_1);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
     result = app_revoke_permissions(APP_FRIEND_2);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
     app_uninstall(APP_FRIEND_1);
     app_uninstall(APP_FRIEND_2);
@@ -2061,10 +2069,10 @@ RUNNER_TEST(privilege_control14_app_add_friend)
     // Clean up
     result = app_revoke_permissions(APP_FRIEND_1);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
     result = app_revoke_permissions(APP_FRIEND_2);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
     app_uninstall(APP_FRIEND_1);
     app_uninstall(APP_FRIEND_2);
@@ -2091,10 +2099,10 @@ RUNNER_TEST(privilege_control14_app_add_friend)
     // Clean up
     result = app_revoke_permissions(APP_FRIEND_1);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
     result = app_revoke_permissions(APP_FRIEND_2);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
     app_uninstall(APP_FRIEND_1);
     app_uninstall(APP_FRIEND_2);
@@ -2105,10 +2113,10 @@ RUNNER_TEST(privilege_control14_app_add_friend)
     unsigned int i;
     unsigned int j;
 
-    struct smack_accesses * rulesFriend = NULL;
+    struct smack_accesses *rulesFriend = NULL;
 
     std::vector<std::string> accessesFriend =
-        { "r", "w", "x", "rw", "rx", "wx", "rwx", "rwxat" };
+    { "r", "w", "x", "rw", "rx", "wx", "rwx", "rwxat" };
 
     // Installing friends to be
     result = app_install(APP_FRIEND_1);
@@ -2118,11 +2126,10 @@ RUNNER_TEST(privilege_control14_app_add_friend)
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
         " Error installing second app. Result: " << result);
 
-    for(i = 0; i<accessesFriend.size(); ++i)
+    for (i = 0; i < accessesFriend.size(); ++i)
     {
-        for(j = 0; j<accessesFriend.size(); ++j)
+        for (j = 0; j < accessesFriend.size(); ++j)
         {
-
             // Adding rules before making friends
             result = smack_accesses_new(&rulesFriend);
             RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
@@ -2156,25 +2163,24 @@ RUNNER_TEST(privilege_control14_app_add_friend)
 
             // Deleting all rules between friends
             smack_accesses_add_modify(rulesFriend,
-                 APP_FRIEND_1, APP_FRIEND_2,"","rwxat");
+                APP_FRIEND_1, APP_FRIEND_2,"","rwxat");
             smack_accesses_add_modify(rulesFriend,
-                 APP_FRIEND_2, APP_FRIEND_1,"","rwxat");
+                APP_FRIEND_2, APP_FRIEND_1,"","rwxat");
 
             result = smack_accesses_apply(rulesFriend);
 
             smack_accesses_free(rulesFriend);
             rulesFriend = NULL;
         }
-
     }
 
     // Clean up
     result = app_revoke_permissions(APP_FRIEND_1);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
     result = app_revoke_permissions(APP_FRIEND_2);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
-            "Error revoking app permissions. Result: " << result);
+        "Error revoking app permissions. Result: " << result);
 
     app_uninstall(APP_FRIEND_1);
     app_uninstall(APP_FRIEND_2);
@@ -2194,7 +2200,7 @@ static void smack_set_random_label_based_on_pid_on_self(void)
 static void smack_unix_sock_server(int sock)
 {
     int fd, result;
-    charsmack_label;
+    char *smack_label;
 
     alarm(2);
     fd = accept(sock, NULL, NULL);
@@ -2202,14 +2208,14 @@ static void smack_unix_sock_server(int sock)
     if (fd < 0)
         return;
     result = smack_new_label_from_self(&smack_label);
-    if(result != 0){
+    if (result != 0) {
         close(fd);
         close(sock);
         free(smack_label);
         RUNNER_ASSERT_MSG(0, "smack_new_label_from_self() failed");
     }
     result = write(fd, smack_label, strlen(smack_label));
-    if(result != (int)strlen(smack_label)){
+    if (result != (int)strlen(smack_label)) {
         close(fd);
         close(sock);
         free(smack_label);
@@ -2237,13 +2243,13 @@ RUNNER_TEST(privilege_control15_app_id_from_socket)
         sock = socket(AF_UNIX, SOCK_STREAM, 0);
         RUNNER_ASSERT_MSG(sock >= 0, "socket failed: " << strerror(errno));
         result = bind(sock,
-            (struct sockaddr *) &sockaddr, sizeof(struct sockaddr_un));
-        if(result != 0){
+            (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un));
+        if (result != 0) {
             close(sock);
             RUNNER_ASSERT_MSG(0, "bind failed: " << strerror(errno));
         }
         result = listen(sock, 1);
-        if(result != 0){
+        if (result != 0) {
             close(sock);
             RUNNER_ASSERT_MSG(0, "listen failed: " << strerror(errno));
         }
@@ -2269,14 +2275,14 @@ RUNNER_TEST(privilege_control15_app_id_from_socket)
             int sock;
             int result;
             char smack_label1[SMACK_LABEL_LEN + 1];
-            charsmack_label2;
+            char *smack_label2;
 
             sock = socket(AF_UNIX, SOCK_STREAM, 0);
             RUNNER_ASSERT_MSG(sock >= 0,
                 "socket failed: " << strerror(errno));
             result = connect(sock,
-                (struct sockaddr *) &sockaddr, sizeof(struct sockaddr_un));
-            if(result != 0){
+                (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un));
+            if (result != 0) {
                 close(sock);
                 RUNNER_ASSERT_MSG(0, "connect failed: " << strerror(errno));
             }
@@ -2284,18 +2290,18 @@ RUNNER_TEST(privilege_control15_app_id_from_socket)
             alarm(2);
             result = read(sock, smack_label1, SMACK_LABEL_LEN);
             alarm(0);
-            if(result < 0){
+            if (result < 0) {
                 close(sock);
                 RUNNER_ASSERT_MSG(0, "read failed: " << strerror(errno));
             }
             smack_label1[result] = '\0';
             smack_label2 = app_id_from_socket(sock);
-            if(smack_label2 == NULL){
+            if (smack_label2 == NULL) {
                 close(sock);
                 RUNNER_ASSERT_MSG(0, "app_id_from_socket failed");
             }
             result = strcmp(smack_label1, smack_label2);
-            if(result != 0){
+            if (result != 0) {
                 close(sock);
                 RUNNER_ASSERT_MSG(0, "smack labels differ: '" << smack_label1
                     << "' != '" << smack_label2 << "-" << random() << "'");
@@ -2314,7 +2320,7 @@ RUNNER_TEST(privilege_control16_app_setup_path){
     const char *label1 = "qwert123456za";
     const char *label2 = "trewq654123az";
 
-    std::unique_ptr<char, std::function<void(void*)>> labelPtr(NULL,free);
+    std::unique_ptr<char, std::function<void(void*)> > labelPtr(NULL,free);
 
     mkdir(path1,0);
     mkdir(path2,0);
@@ -2348,87 +2354,85 @@ RUNNER_TEST(privilege_control16_app_setup_path){
 
 RUNNER_TEST(privilege_control17_appsettings_privilege)
 {
-#define APP_1 "app_1"
+#define APP_1     "app_1"
 #define APP_1_DIR "/tmp/app_1"
 
-#define APP_2 "app_2"
+#define APP_2     "app_2"
 #define APP_2_DIR "/tmp/app_2"
 
 #define APP_TEST "app_test"
 
-#define PRIV_APPSETTING (const char*[]){"http://tizen.org/privilege/appsetting", NULL}
-
-       int ret;
-       char* app1_dir_label;
-       char* app2_dir_label;
-       //prepare test
-
+#define PRIV_APPSETTING (const char*[]) {"http://tizen.org/privilege/appsetting", NULL}
 
-       (void)app_uninstall(APP_TEST);
-       (void)app_uninstall(APP_1);
-       (void)app_uninstall(APP_2);
+    int ret;
+    char *app1_dir_label;
+    char *app2_dir_label;
+    //prepare test
 
-       //install some app 1
-       ret = app_install(APP_1);
-       RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "Error in app_install." << ret);
 
-       mkdir(APP_1_DIR, S_IRWXU|S_IRGRP|S_IXGRP);
+    (void)app_uninstall(APP_TEST);
+    (void)app_uninstall(APP_1);
+    (void)app_uninstall(APP_2);
 
-       //register settings folder for app 1
-       ret = app_setup_path(APP_1, APP_1_DIR , APP_PATH_SETTINGS_RW );
-       RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "Error in app_setup_path: " << ret);
+    //install some app 1
+    ret = app_install(APP_1);
+    RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "Error in app_install." << ret);
 
-       //install "app_test" and give it appsettings privilege
-       ret = app_install(APP_TEST);
-       RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "Error in app_install.");
+    mkdir(APP_1_DIR, S_IRWXU | S_IRGRP | S_IXGRP);
 
+    //register settings folder for app 1
+    ret = app_setup_path(APP_1, APP_1_DIR, APP_PATH_SETTINGS_RW );
+    RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "Error in app_setup_path: " << ret);
 
-       ret = app_enable_permissions(APP_TEST, APP_TYPE_OSP, PRIV_APPSETTING, true);
+    //install "app_test" and give it appsettings privilege
+    ret = app_install(APP_TEST);
+    RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "Error in app_install.");
 
-       RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS,
-               " Error enabling app permissions. Result: " << ret);
 
-       //check if "app_test" has an RX access to the app "app_1"
-       ret = smack_have_access(APP_TEST, APP_1, "rx");
-       RUNNER_ASSERT_MSG(ret,"access denies");
+    ret = app_enable_permissions(APP_TEST, APP_TYPE_OSP, PRIV_APPSETTING, true);
 
+    RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS,
+        " Error enabling app permissions. Result: " << ret);
 
-       //check if "app_test" has an RWX access to a folder registered by "app_1"
-       ret = smack_getlabel(APP_1_DIR, &app1_dir_label, SMACK_LABEL_ACCESS );
-       RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS,"smack_getlabel failed");
-       ret = smack_have_access(APP_TEST, app1_dir_label, "rwx");
-       RUNNER_ASSERT_MSG(ret,"access denies");
+    //check if "app_test" has an RX access to the app "app_1"
+    ret = smack_have_access(APP_TEST, APP_1, "rx");
+    RUNNER_ASSERT_MSG(ret,"access denies");
 
 
-       //intstall another app: "app_2"
-       ret = app_install(APP_2);
-       RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "Error in app_install.");
+    //check if "app_test" has an RWX access to a folder registered by "app_1"
+    ret = smack_getlabel(APP_1_DIR, &app1_dir_label, SMACK_LABEL_ACCESS );
+    RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS,"smack_getlabel failed");
+    ret = smack_have_access(APP_TEST, app1_dir_label, "rwx");
+    RUNNER_ASSERT_MSG(ret,"access denies");
 
-       mkdir(APP_2_DIR, S_IRWXU|S_IRGRP|S_IXGRP);
-       //register settings folder for that "app_2"
-       ret = app_setup_path(APP_2, APP_2_DIR , APP_PATH_SETTINGS_RW );
-       RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "Error in app_setup_path: " << ret);
 
-       //check if "app_test" has an RX access to the app "app_2"
-       ret = smack_have_access(APP_TEST, APP_2, "rx");
-       RUNNER_ASSERT_MSG(ret,"access denies");
+    //intstall another app: "app_2"
+    ret = app_install(APP_2);
+    RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "Error in app_install.");
 
-       //check if "app_test" has an RWX access to a folder registered by "app_2"
-       ret = smack_getlabel(APP_2_DIR, &app2_dir_label, SMACK_LABEL_ACCESS );
-       RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS,"smack_getlabel failed");
-       ret = smack_have_access(APP_TEST, app2_dir_label, "rwx");
-       RUNNER_ASSERT_MSG(ret,"access denies");
+    mkdir(APP_2_DIR, S_IRWXU | S_IRGRP | S_IXGRP);
+    //register settings folder for that "app_2"
+    ret = app_setup_path(APP_2, APP_2_DIR, APP_PATH_SETTINGS_RW );
+    RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "Error in app_setup_path: " << ret);
 
-       free (app1_dir_label);
-       free (app2_dir_label);
-       rmdir(APP_1_DIR);
-       rmdir(APP_2_DIR);
+    //check if "app_test" has an RX access to the app "app_2"
+    ret = smack_have_access(APP_TEST, APP_2, "rx");
+    RUNNER_ASSERT_MSG(ret,"access denies");
 
-       (void)app_uninstall(APP_TEST);
-       (void)app_uninstall(APP_1);
-       (void)app_uninstall(APP_2);
+    //check if "app_test" has an RWX access to a folder registered by "app_2"
+    ret = smack_getlabel(APP_2_DIR, &app2_dir_label, SMACK_LABEL_ACCESS );
+    RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS,"smack_getlabel failed");
+    ret = smack_have_access(APP_TEST, app2_dir_label, "rwx");
+    RUNNER_ASSERT_MSG(ret,"access denies");
 
+    free (app1_dir_label);
+    free (app2_dir_label);
+    rmdir(APP_1_DIR);
+    rmdir(APP_2_DIR);
 
+    (void)app_uninstall(APP_TEST);
+    (void)app_uninstall(APP_1);
+    (void)app_uninstall(APP_2);
 }
 
 RUNNER_TEST(privilege_control18_app_setup_path_public)
index e41aa29..93c853d 100644 (file)
@@ -21,7 +21,8 @@
  */
 #include <dpl/test/test_runner.h>
 
-int main (int argc, char *argv[]) {
+int main (int argc, char *argv[])
+{
     int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
     return status;
 }
index d8eb58e..cdaaf6d 100644 (file)
@@ -36,8 +36,8 @@
 #include <sys/un.h>
 #include <sys/wait.h>
 
-#define TEST_SUBJECT "test_subject"
-#define TEST_OBJECT "test_oject"
+#define TEST_SUBJECT  "test_subject"
+#define TEST_OBJECT   "test_oject"
 #define TEST_OBJECT_2 "test_oject_2"
 
 #define SOCK_PATH "/tmp/test-smack-socket"
@@ -55,28 +55,28 @@ int files_compare(int fd1, int fd2)
     struct stat fs1, fs2;
 
     //handlers for mmap()
-    void * h1 = MAP_FAILED;
-    void * h2 = MAP_FAILED;
+    void *h1 = MAP_FAILED;
+    void *h2 = MAP_FAILED;
 
     //getting files information
-    if(fstat(fd1, &fs1) == -1) {
+    if (fstat(fd1, &fs1) == -1) {
         perror("fstat");
         return -1;
     }
-    if(fstat(fd2, &fs2) == -1) {
+    if (fstat(fd2, &fs2) == -1) {
         perror("fstat");
         return -1;
     }
 
-    if(fs1.st_size != fs2.st_size)  //if files are identical size will be the same
+    if (fs1.st_size != fs2.st_size) //if files are identical size will be the same
         return -1;
 
     //mapping files to process memory
-    if((h1 = mmap(0, fs1.st_size, PROT_READ, MAP_SHARED, fd1, 0 )) == MAP_FAILED) {
+    if ((h1 = mmap(0, fs1.st_size, PROT_READ, MAP_SHARED, fd1, 0 )) == MAP_FAILED) {
         result = -1;
         goto end;
     }
-    if((h2 = mmap(0, fs2.st_size, PROT_READ, MAP_SHARED, fd2, 0 )) == MAP_FAILED) {
+    if ((h2 = mmap(0, fs2.st_size, PROT_READ, MAP_SHARED, fd2, 0 )) == MAP_FAILED) {
         result = -1;
         goto end;
     }
@@ -85,9 +85,9 @@ int files_compare(int fd1, int fd2)
 
     //cleaning after mmap()
 end:
-    if(h2 != MAP_FAILED)
+    if (h2 != MAP_FAILED)
         munmap(h2, fs2.st_size);
-    if(h1 != MAP_FAILED)
+    if (h1 != MAP_FAILED)
         munmap(h1, fs1.st_size);
 
     return result;
@@ -98,8 +98,9 @@ RUNNER_TEST_GROUP_INIT(libsmack)
 /**
  * Helper method to reset privileges at the begginning of tests.
  */
-void clean_up(){
-    struct smack_accesses * rules = NULL;
+void clean_up()
+{
+    struct smack_accesses *rules = NULL;
     int result = smack_accesses_new(&rules);
     RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
 
@@ -119,26 +120,27 @@ void clean_up(){
 /**
  * Checking if subject has any access to object
  */
-bool checkNoAccesses(const char *subject, const char *object){
+bool checkNoAccesses(const char *subject, const char *object)
+{
     int result;
     result = smack_have_access(subject, object,"r");
-    if(result==1){
+    if (result == 1) {
         return false;
     }
     result = smack_have_access(subject, object,"w");
-    if(result==1){
+    if (result == 1) {
         return false;
     }
     result = smack_have_access(subject, object,"x");
-    if(result==1){
+    if (result == 1) {
         return false;
     }
     result = smack_have_access(subject, object,"a");
-    if(result==1){
+    if (result == 1) {
         return false;
     }
     result = smack_have_access(subject, object,"t");
-    if(result==1){
+    if (result == 1) {
         return false;
     }
     return true;
@@ -146,7 +148,7 @@ bool checkNoAccesses(const char *subject, const char *object){
 
 int removeAccessesAll()
 {
-    struct smack_accesses * rules = NULL;
+    struct smack_accesses *rules = NULL;
     int result = smack_accesses_new(&rules);
     RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
 
@@ -174,7 +176,7 @@ RUNNER_TEST(smack_accesses_add_modify_test_1){
 
     clean_up();
 
-    struct smack_accesses * rules = NULL;
+    struct smack_accesses *rules = NULL;
     result = smack_accesses_new(&rules);
 
     // THE TEST
@@ -196,7 +198,7 @@ RUNNER_TEST(smack_accesses_add_modify_test_1){
  */
 RUNNER_TEST(smack_accesses_add_modify_test_2){
     int result;
-    struct smack_accesses * rules = NULL;
+    struct smack_accesses *rules = NULL;
     result = smack_accesses_new(&rules);
     RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
 
@@ -224,7 +226,7 @@ RUNNER_TEST(smack_accesses_add_modify_test_2){
  */
 RUNNER_TEST(smack_accesses_add_modify_test_3){
     int result;
-    struct smack_accesses * rules = NULL;
+    struct smack_accesses *rules = NULL;
     result = smack_accesses_new(&rules);
     RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
 
@@ -258,7 +260,7 @@ RUNNER_TEST(smack_accesses_add_modify_test_3){
  */
 RUNNER_TEST(smack_accesses_add_modify_test_4){
     int result;
-    struct smack_accesses * rules = NULL;
+    struct smack_accesses *rules = NULL;
     result = smack_accesses_new(&rules);
     RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
 
@@ -289,7 +291,7 @@ RUNNER_TEST(smack_accesses_add_modify_test_4){
  */
 RUNNER_TEST(smack_accesses_add_modify_test_5){
     int result;
-    struct smack_accesses * rules = NULL;
+    struct smack_accesses *rules = NULL;
     result = smack_accesses_new(&rules);
     RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
 
@@ -319,7 +321,7 @@ RUNNER_TEST(smack_accesses_add_modify_test_5){
  */
 RUNNER_TEST(smack_accesses_add_modify_test_6){
     int result;
-    struct smack_accesses * rules = NULL;
+    struct smack_accesses *rules = NULL;
     result = smack_accesses_new(&rules);
     RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
 
@@ -351,14 +353,14 @@ RUNNER_TEST(smack_accesses_add_modify_test_7){
     unsigned int i;
     int result;
 
-    struct smack_accesses * rules = NULL;
+    struct smack_accesses *rules = NULL;
 
-    for(i = 0; i<accessesBasic.size(); ++i){
+    for (i = 0; i < accessesBasic.size(); ++i) {
         result = smack_accesses_new(&rules);
-            RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
+        RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
 
         result = smack_accesses_add_modify(rules,TEST_SUBJECT, TEST_OBJECT,accessesBasic[i].c_str(),accessesBasic[i].c_str());
-            RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
+        RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
         RUNNER_ASSERT_MSG(smack_accesses_apply(rules) == 0, "Unable to apply rules");
 
         RUNNER_ASSERT_MSG(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT),
@@ -377,16 +379,15 @@ RUNNER_TEST(smack_revoke_subject_test_1){
     unsigned int i;
     int result;
 
-    struct smack_accesses * rules = NULL;
-
-    for(i = 0; i<accessesBasic.size(); ++i){
+    struct smack_accesses *rules = NULL;
 
+    for (i = 0; i < accessesBasic.size(); ++i) {
         // Creating and adding rules with TEST_OBJECT and TEST_OBJECT_2
         result = smack_accesses_new(&rules);
-            RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
+        RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
         result = smack_accesses_add_modify(rules,TEST_SUBJECT, TEST_OBJECT,accessesBasic[i].c_str(),"");
         result = smack_accesses_add_modify(rules,TEST_SUBJECT, TEST_OBJECT_2,accessesBasic[i].c_str(),"");
-            RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
+        RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
         RUNNER_ASSERT_MSG(smack_accesses_apply(rules) == 0, "Unable to apply rules");
         result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,accessesBasic[i].c_str());
         RUNNER_ASSERT_MSG(result == 1, "Modification didn't work. Rule " << accessesBasic[i].c_str() << " does not exist.");
@@ -423,17 +424,16 @@ RUNNER_TEST(smack_accesses_clear_test_1){
     unsigned int i;
     int result;
 
-    struct smack_accesses * rules = NULL;
-
-    for(i = 0; i<accessesBasic.size(); ++i){
+    struct smack_accesses *rules = NULL;
 
+    for (i = 0; i < accessesBasic.size(); ++i) {
         // Creating and adding rules with TEST_OBJECT and TEST_OBJECT_2
         result = smack_accesses_new(&rules);
-            RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
+        RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
         result = smack_accesses_add(rules,TEST_SUBJECT, TEST_OBJECT,accessesBasic[i].c_str());
-            RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
+        RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
         result = smack_accesses_add(rules,TEST_SUBJECT, TEST_OBJECT_2,accessesBasic[i].c_str());
-            RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
+        RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
         RUNNER_ASSERT_MSG(smack_accesses_apply(rules) == 0, "Unable to apply rules");
 
         result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,accessesBasic[i].c_str());
@@ -445,9 +445,9 @@ RUNNER_TEST(smack_accesses_clear_test_1){
 
         // Creating and clearing rules with TEST_OBJECT
         result = smack_accesses_new(&rules);
-            RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
+        RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
         result = smack_accesses_add(rules,TEST_SUBJECT, TEST_OBJECT,accessesBasic[i].c_str());
-            RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
+        RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
         result = smack_accesses_clear(rules);
         RUNNER_ASSERT_MSG(result == 0, "Clearing rules didn't work.");
 
@@ -460,10 +460,10 @@ RUNNER_TEST(smack_accesses_clear_test_1){
 
         // Creating and clearing rules with TEST_OBJECT_2
         result = smack_accesses_new(&rules);
-            RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
+        RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
 
         result = smack_accesses_add(rules,TEST_SUBJECT, TEST_OBJECT_2,accessesBasic[i].c_str());
-            RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
+        RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance");
         result = smack_accesses_clear(rules);
         RUNNER_ASSERT_MSG(result == 0, "Clearing rules didn't work.");
 
@@ -480,15 +480,15 @@ RUNNER_TEST(smack01_storing_and_restoring_rules)
 {
     /*
      * author: Pawel Polawski
-     * test: smack_accesses_new, smack_accesses_add, smack_accesses_add_modify, smack_accesses_add_from_file, 
+     * test: smack_accesses_new, smack_accesses_add, smack_accesses_add_modify, smack_accesses_add_from_file,
      *       smack_accesses_free, smack_accesses_save
      * description: This test case will create structure holding SMACK rules and add new one to it. Next rules will be
      *              stored and restored from file.
      * expect: Rules created and stored in file should be identical to predefined template.
      */
 
-    struct smack_accesses * rules = NULL;       //rules prepared in this test case
-    struct smack_accesses * import_test = NULL; //rules imported from file
+    struct smack_accesses *rules = NULL;        //rules prepared in this test case
+    struct smack_accesses *import_test = NULL;  //rules imported from file
 
     int result;             //result of each operation to be tested by RUNNER_ASSERT
     int fd, tmp, sample;    //file descripptors for save / restore rules tests
@@ -561,7 +561,7 @@ RUNNER_TEST(smack02_aplying_rules_into_kernel)
 
     //CAP_MAC_ADMIN needed for process to be able to change rules in kernel (apllying, removing)
 
-    struct smack_accesses * rules = NULL;       //rules prepared in this test case
+    struct smack_accesses *rules = NULL;        //rules prepared in this test case
     int result;                                 //for storing functions results
 
     result = smack_accesses_new(&rules);        //rules struct init
@@ -618,16 +618,16 @@ RUNNER_TEST(smack02_aplying_rules_into_kernel)
 }
 
 //pairs of rules for test with mixed cases, different length and mixed order
-char * rules_tab[] = {
-                        "reader1",  "-",                "-----",
-                        "reader2",  "--------",         "-----",
-                        "reader3",  "RwXaT",            "rwxat",
-                        "reader4",  "RrrXXXXTTT",       "r-x-t",
-                        "reader5",  "-r-w-a-t",         "rw-at",
-                        "reader6",  "",                 "-----",
-                        "reader7",  "xa--Rt---W",       "rwxat",
-                        "reader8",  "#Ax[T].!~W@1}",    "-wxat"
-                     };
+char *rules_tab[] = {
+    "reader1",  "-",                "-----",
+    "reader2",  "--------",         "-----",
+    "reader3",  "RwXaT",            "rwxat",
+    "reader4",  "RrrXXXXTTT",       "r-x-t",
+    "reader5",  "-r-w-a-t",         "rw-at",
+    "reader6",  "",                 "-----",
+    "reader7",  "xa--Rt---W",       "rwxat",
+    "reader8",  "#Ax[T].!~W@1}",    "-wxat"
+};
 
 RUNNER_TEST(smack03_mixed_rule_string_add)
 {
@@ -642,7 +642,7 @@ RUNNER_TEST(smack03_mixed_rule_string_add)
     //In thist test case mixed string are used as rules applied to kernel, next they are
     //readed and compared with correct form of rules
 
-    struct smack_accesses * rules = NULL;       //rules prepared in this test case
+    struct smack_accesses *rules = NULL;        //rules prepared in this test case
     int result;                                 //for storing functions results
     int i;
 
@@ -650,7 +650,7 @@ RUNNER_TEST(smack03_mixed_rule_string_add)
     RUNNER_ASSERT_MSG(result == 0, "Unable to create smack_accesses instance");
 
     //adding test rules with mixed string
-    for(i = 0; i < (3 * 8) ; i += 3) {
+    for (i = 0; i < (3 * 8); i += 3) {
         result = smack_accesses_add(rules, rules_tab[i], "book", rules_tab[i + 1]); //using mixed rules from table
         RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules");
     }
@@ -665,14 +665,13 @@ RUNNER_TEST(smack03_mixed_rule_string_add)
     RUNNER_ASSERT_MSG(result == 0, "Unable to apply rules into kernel");
 
     //checking accesses using normal rules
-    for(i = 0; i < (3 * 8) ; i += 3) {
+    for (i = 0; i < (3 * 8); i += 3) {
         result = smack_have_access(rules_tab[i], "book", rules_tab[i + 2]); //using normal rules from table
         RUNNER_ASSERT_MSG(result == 1, "Error while checking Smack access");
     }
 
     //free resources
     smack_accesses_free(rules);
-
 }
 
 RUNNER_TEST(smack04_mixed_rule_string_have_access)
@@ -691,7 +690,7 @@ RUNNER_TEST(smack04_mixed_rule_string_have_access)
 
     //rules were added in previous RUNNER_TEST section
     //checking accesses using mixed rules
-    for(i = 0; i < (3 * 8) ; i += 3) {
+    for (i = 0; i < (3 * 8); i += 3) {
         result = smack_have_access(rules_tab[i], "book", rules_tab[i + 1]); //using mixed rules from table
         RUNNER_ASSERT_MSG(result == 1, "Error while checking Smack access");
     }
@@ -717,14 +716,14 @@ RUNNER_TEST(smack05_self_label)
 
     //In this test case process will manipulate it own label
 
-    char * label = NULL;
+    char *label = NULL;
     int result;
     int fd;
 
     const int B_SIZE = 8;
     char buff[B_SIZE];
 
-    char * def_rule = "_";
+    char *def_rule = "_";
 
     //int smack_new_label_from_self(char **label);
     result = smack_new_label_from_self(&label);
@@ -770,13 +769,13 @@ RUNNER_TEST(smack05_self_label)
 
 //RUNNER_TEST(smackXX_parent_child_label)
 //{
-    //In this test case parent process and child labels will be tested
-    //Parent will fork and check child's label. First fork will be with default "_" parent label,
-    //second one witch changed label.
+//In this test case parent process and child labels will be tested
+//Parent will fork and check child's label. First fork will be with default "_" parent label,
+//second one witch changed label.
 //}
 
 //bellow function is from libsmack.c witch changed name
-char * xattr(enum smack_label_type type)
+char *xattr(enum smack_label_type type)
 {
     switch (type) {
         case SMACK_LABEL_ACCESS:
@@ -792,8 +791,8 @@ char * xattr(enum smack_label_type type)
         case SMACK_LABEL_IPOUT:
             return "security.SMACK64IPOUT";
         default:
-         /*  Should not reach this point */
-        return NULL;
+            /*  Should not reach this point */
+            return NULL;
     }
 }
 
@@ -827,12 +826,12 @@ RUNNER_TEST(smack06_get_set_label)
     //    return "security.SMACK64IPOUT";
 
     int result;
-    char * label = NULL;
+    char *label = NULL;
 
     const int B_SIZE = 8;
     char buff[B_SIZE];
 
-    char * file_path = "/etc/smack/test_smack_rules";
+    char *file_path = "/etc/smack/test_smack_rules";
 
 
     //preparing environment by restoring default "_" label
@@ -879,8 +878,8 @@ RUNNER_TEST(smack06_get_set_label)
 
 //RUNNER_TEST(smackXX_get_label_exec)
 //{
-    //In this test case EXEC label will be tested
-    //by setting this type of label, reading it and testing executed binary exit status
+//In this test case EXEC label will be tested
+//by setting this type of label, reading it and testing executed binary exit status
 //}
 
 RUNNER_TEST(smack07_l_get_set_label)
@@ -894,12 +893,12 @@ RUNNER_TEST(smack07_l_get_set_label)
      */
 
     int result;
-    char * label = NULL;
+    char *label = NULL;
 
     const int B_SIZE = 8;
     char buff[B_SIZE];
 
-    char * file_path = "/etc/smack/test_smack_rules_lnk";
+    char *file_path = "/etc/smack/test_smack_rules_lnk";
 
 
     //preparing environment by restoring default "_" label
@@ -976,13 +975,13 @@ RUNNER_TEST(smack08_f_get_set_label)
      */
 
     int result;
-    char * label = NULL;
+    char *label = NULL;
 
     const int B_SIZE = 8;
     char buff[B_SIZE];
 
     int fd;
-    char * file_path = "/etc/smack/test_smack_rules";
+    char *file_path = "/etc/smack/test_smack_rules";
 
     fd = open(file_path, O_RDWR, 0644);             //reference preinstalled rules
     RUNNER_ASSERT_MSG(fd >= 0, "Unable to open /etc/smack/test_smack_rules");
@@ -1037,9 +1036,9 @@ RUNNER_TEST(smack10_adding_removing_rules)
     unsigned int i;
     int result;
 
-    struct smack_accesses * rulesBasic = NULL;
+    struct smack_accesses *rulesBasic = NULL;
 
-    for(i = 0; i<accessesBasic.size(); ++i)
+    for (i = 0; i < accessesBasic.size(); ++i)
     {
         // Creating rules
         result = smack_accesses_new(&rulesBasic);
@@ -1053,10 +1052,10 @@ RUNNER_TEST(smack10_adding_removing_rules)
         result = smack_accesses_apply(rulesBasic);
         RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result);
 
-       // Checking if accesses were created
+        // Checking if accesses were created
         result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str());
         RUNNER_ASSERT_MSG(result == 1,
-               " Error while checking smack access. Result: " << result);
+            " Error while checking smack access. Result: " << result);
 
         smack_accesses_free(rulesBasic);
         rulesBasic = NULL;
@@ -1065,7 +1064,7 @@ RUNNER_TEST(smack10_adding_removing_rules)
         clean_up();
     }
 
-    for(i = 0; i<3; ++i)
+    for (i = 0; i < 3; ++i)
     {
         // --- Creating rules (r or w or x)
         result = smack_accesses_new(&rulesBasic);
@@ -1078,33 +1077,33 @@ RUNNER_TEST(smack10_adding_removing_rules)
         // Applying rules
         result = smack_accesses_apply(rulesBasic);
         RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result);
-       // Checking if accesses were created
+        // Checking if accesses were created
         result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str());
         RUNNER_ASSERT_MSG(result == 1,
-               " Error while checking smack access. Result: " << result);
+            " Error while checking smack access. Result: " << result);
 
         // Checking if wrong accesses were not created
-        result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i+3].c_str());
+        result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i + 3].c_str());
         RUNNER_ASSERT_MSG(result == 0,
-               " Error while checking smack access. Result: " << result);
+            " Error while checking smack access. Result: " << result);
 
         // --- Modifying accesses (r for wx or w for rx or x for rw)
-        result = smack_accesses_add_modify(rulesBasic,TEST_SUBJECT, TEST_OBJECT,accessesBasic[i+3].c_str(),accessesBasic[i].c_str());
+        result = smack_accesses_add_modify(rulesBasic,TEST_SUBJECT, TEST_OBJECT,accessesBasic[i + 3].c_str(),accessesBasic[i].c_str());
         RUNNER_ASSERT_MSG(result == 0, "Unable to add modify rulesBasic. Result: " << result);
 
         // Applying rules
         result = smack_accesses_apply(rulesBasic);
         RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result);
 
-       // Checking if accesses were created
-        result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i+3].c_str());
+        // Checking if accesses were created
+        result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i + 3].c_str());
         RUNNER_ASSERT_MSG(result == 1,
-               " Error while checking smack access. Result: " << result);
+            " Error while checking smack access. Result: " << result);
 
         // Checking if wrong accesses were not created
         result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str());
         RUNNER_ASSERT_MSG(result == 0,
-               " Error while checking smack access. Result: " << result);
+            " Error while checking smack access. Result: " << result);
 
         smack_accesses_free(rulesBasic);
         rulesBasic = NULL;
@@ -1117,19 +1116,19 @@ RUNNER_TEST(smack10_adding_removing_rules)
         result = smack_accesses_add(rulesBasic, TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str());
         RUNNER_ASSERT_MSG(result == 0, "Unable to add rulesBasic. Result: " << result);
 
-       // Checking if accesses were created
-        result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i+3].c_str());
+        // Checking if accesses were created
+        result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i + 3].c_str());
         RUNNER_ASSERT_MSG(result == 1,
-               " Error while checking smack access. Result: " << result);
+            " Error while checking smack access. Result: " << result);
 
         // Applying rules
         result = smack_accesses_apply(rulesBasic);
         RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result);
 
-       // Checking if accesses were created
+        // Checking if accesses were created
         result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str());
         RUNNER_ASSERT_MSG(result == 1,
-               " Error while checking smack access. Result: " << result);
+            " Error while checking smack access. Result: " << result);
 
         // --- Modifying accesses (adding rwx and removing r or w or x)
         result = smack_accesses_add_modify(rulesBasic,TEST_SUBJECT, TEST_OBJECT,"rwx",accessesBasic[i].c_str());
@@ -1139,32 +1138,32 @@ RUNNER_TEST(smack10_adding_removing_rules)
         result = smack_accesses_apply(rulesBasic);
         RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result);
 
-       // Checking if accesses were created
-        result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i+3].c_str());
+        // Checking if accesses were created
+        result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i + 3].c_str());
         RUNNER_ASSERT_MSG(result == 1,
-               " Error while checking smack access. Result: " << result);
+            " Error while checking smack access. Result: " << result);
 
         // Checking if wrong accesses were not created
         result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str());
         RUNNER_ASSERT_MSG(result == 0,
-               " Error while checking smack access. Result: " << result);
+            " Error while checking smack access. Result: " << result);
 
         // --- Adding crossing accesses (rx or rw or wx)
-        result = smack_accesses_add_modify(rulesBasic,TEST_SUBJECT, TEST_OBJECT,accessesBasic[3+((i+1)%3)].c_str(),"");
+        result = smack_accesses_add_modify(rulesBasic,TEST_SUBJECT, TEST_OBJECT,accessesBasic[3 + ((i + 1) % 3)].c_str(),"");
         RUNNER_ASSERT_MSG(result == 0, "Unable to add modify rulesBasic. Result: " << result);
 
         // Applying rules
         result = smack_accesses_apply(rulesBasic);
         RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result);
 
-       // Checking if accesses were created
-        result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[3+((i+1)%3)].c_str());
+        // Checking if accesses were created
+        result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[3 + ((i + 1) % 3)].c_str());
         RUNNER_ASSERT_MSG(result == 1,
-               " Error while checking smack access. Result: " << result);
+            " Error while checking smack access. Result: " << result);
 
         result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, "rwx");
         RUNNER_ASSERT_MSG(result == 1,
-               " Error while checking smack access. Result: " << result);
+            " Error while checking smack access. Result: " << result);
 
         // Deleting all rules
         result = smack_accesses_add_modify(rulesBasic,TEST_SUBJECT, TEST_OBJECT,"","rwx");
@@ -1186,7 +1185,7 @@ RUNNER_TEST(smack11_saving_loading_rules)
     int result;
     int fd;
 
-    struct smack_accesses * rulesBasic = NULL;
+    struct smack_accesses *rulesBasic = NULL;
 
     // Pre-cleanup
     removeAccessesAll();
@@ -1246,7 +1245,7 @@ RUNNER_TEST(smack11_saving_loading_rules)
     result = smack_accesses_new(&rulesBasic);
     RUNNER_ASSERT_MSG(result == 0, "Error while creating new accesses. Result: " << result);
 
-     // Loading file with partial wrong rules - test_smack_rules2
+    // Loading file with partial wrong rules - test_smack_rules2
     fd = open("/etc/smack/test_smack_rules2", O_RDONLY, 0644);
     RUNNER_ASSERT_MSG(fd >= 0, "Unable to open /etc/smack/test_smack_rules2");
 
@@ -1354,7 +1353,6 @@ RUNNER_TEST(smack11_saving_loading_rules)
     removeAccessesAll();
 
     smack_accesses_free(rulesBasic);
-
 }
 
 //int smack_new_label_from_socket(int fd, char **label);
@@ -1364,7 +1362,7 @@ static void smack_set_another_label_for_self(void)
 {
     static int number = time(NULL);
     int result;
-    charsmack_label;
+    char *smack_label;
 
     number++;
     result = asprintf(&smack_label, "s%ld", number);
@@ -1377,7 +1375,7 @@ static void smack_set_another_label_for_self(void)
 static void smack_unix_sock_server(int sock)
 {
     int fd, result;
-    charsmack_label;
+    char *smack_label;
 
     alarm(2);
     fd = accept(sock, NULL, NULL);
@@ -1394,7 +1392,6 @@ static void smack_unix_sock_server(int sock)
 
 RUNNER_TEST(smack09_new_label_from_socket)
 {
-
     int pid;
     struct sockaddr_un sockaddr = {AF_UNIX, SOCK_PATH};
     unlink(SOCK_PATH);
@@ -1407,7 +1404,7 @@ RUNNER_TEST(smack09_new_label_from_socket)
 
         sock = socket(AF_UNIX, SOCK_STREAM, 0);
         RUNNER_ASSERT_MSG(sock >= 0, "socket failed: " << strerror(errno));
-        result = bind(sock, (struct sockaddr *) &sockaddr, sizeof(struct sockaddr_un));
+        result = bind(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un));
         RUNNER_ASSERT_MSG(result == 0, "bind failed: " << strerror(errno));
         result = listen(sock, 1);
         RUNNER_ASSERT_MSG(result == 0, "listen failed: " << strerror(errno));
@@ -1417,9 +1414,9 @@ RUNNER_TEST(smack09_new_label_from_socket)
         RUNNER_ASSERT_MSG(pid >= 0, "Fork failed");
         /*  Test if socket label was unaffected by fork() */
         smack_unix_sock_server(sock);
-        if(!pid) {
-               usleep (100);
-               smack_set_another_label_for_self();
+        if (!pid) {
+            usleep (100);
+            smack_set_another_label_for_self();
             smack_unix_sock_server(sock);
         }
         close(sock);
@@ -1429,14 +1426,13 @@ RUNNER_TEST(smack09_new_label_from_socket)
     } else { /* parent process, client */
         sleep(1); /* Give server some time to setup listening socket */
         for (int i = 0; i < 4; ++i) {
-
             int sock, result;
             char smack_label1[SMACK_LABEL_LEN + 1];
-            charsmack_label2;
+            char *smack_label2;
 
             sock = socket(AF_UNIX, SOCK_STREAM, 0);
             RUNNER_ASSERT_MSG(sock >= 0, "socket failed: " << strerror(errno));
-            result = connect(sock, (struct sockaddr *) &sockaddr, sizeof(struct sockaddr_un));
+            result = connect(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un));
             RUNNER_ASSERT_MSG(result == 0, "connect failed: " << strerror(errno));
             alarm(2);
             result = read(sock, smack_label1, SMACK_LABEL_LEN);
@@ -1446,7 +1442,7 @@ RUNNER_TEST(smack09_new_label_from_socket)
             result = smack_new_label_from_socket(sock, &smack_label2);
             RUNNER_ASSERT_MSG(result == 0, "smack_label_from_socket failed");
             result = strcmp(smack_label1, smack_label2);
-            if(i < 3)
+            if (i < 3)
                 RUNNER_ASSERT_MSG(result == 0, "smack labels differ: '" << smack_label1 << "' != '" << smack_label2 << "' i == " << i);
             else
                 RUNNER_ASSERT_MSG(result != 0, "smack labels do not differ: '" << smack_label1 << "' != '" << smack_label2 << "' i == " << i);
index 15636c1..4fc9811 100644 (file)
@@ -37,7 +37,7 @@ int create_new_socket()
     }
 
     /* Create Unix domain socket */
-    if((localsockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0 )
+    if ((localsockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
     {
         localsockfd = -1;
         LogDebug("Socket creation failed");
@@ -45,8 +45,8 @@ int create_new_socket()
     }
 
     /* Make socket as non blocking */
-    if((flags = fcntl(localsockfd, F_GETFL, 0)) < 0 ||
-      fcntl(localsockfd, F_SETFL, flags) < 0)
+    if ((flags = fcntl(localsockfd, F_GETFL, 0)) < 0 ||
+        fcntl(localsockfd, F_SETFL, flags) < 0)
     {
         close(localsockfd);
         localsockfd = -1;
@@ -57,10 +57,10 @@ int create_new_socket()
     bzero (&serveraddr, sizeof(serveraddr));
     serveraddr.sun_family = AF_UNIX;
     strncpy(serveraddr.sun_path, SECURITY_SERVER_TEST_SOCK_PATH,
-      strlen(SECURITY_SERVER_TEST_SOCK_PATH) + 1);
+        strlen(SECURITY_SERVER_TEST_SOCK_PATH) + 1);
 
     /* Bind the socket */
-    if((bind(localsockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr))) < 0)
+    if ((bind(localsockfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr))) < 0)
     {
         LogDebug("Cannot bind");
         close(localsockfd);
@@ -74,7 +74,7 @@ int create_new_socket()
     /* Flawfinder hits this chmod function as level 5 CRITICAL as race condition flaw *
      *   * Flawfinder recommends to user fchmod insted of chmod
      *       * But, fchmod doesn't work on socket file so there is no other choice at this point */
-    if(chmod(SECURITY_SERVER_TEST_SOCK_PATH, sock_mode) < 0)        /* Flawfinder: ignore */
+    if (chmod(SECURITY_SERVER_TEST_SOCK_PATH, sock_mode) < 0)        /* Flawfinder: ignore */
     {
         LogDebug("chmod() error");
         close(localsockfd);
@@ -91,7 +91,7 @@ int connect_to_testserver()
     int client_len = 0, localsockfd;
 
     /* Create a socket */
-    if((localsockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+    if ((localsockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
     {
         LogDebug("Error on socket. Errno: " << errno);
         return -1;
@@ -102,7 +102,7 @@ int connect_to_testserver()
     strncpy(clientaddr.sun_path, SECURITY_SERVER_TEST_SOCK_PATH, strlen(SECURITY_SERVER_TEST_SOCK_PATH));
     clientaddr.sun_path[strlen(SECURITY_SERVER_TEST_SOCK_PATH)] = 0;
     client_len = sizeof(clientaddr);
-    if(connect(localsockfd, (struct sockaddr*)&clientaddr, client_len) < 0)
+    if (connect(localsockfd, (struct sockaddr*)&clientaddr, client_len) < 0)
     {
         LogDebug("Error on connect. Errno: " << errno);
         close(localsockfd);
index 377d243..0579f3c 100644 (file)
@@ -63,13 +63,13 @@ char tmpchar[100];
 int privilege_control_old(int argc, char *argv[])
 {
     int option = 0; /* 0: no, 1: uID, 2: gid, 3: permission */
-    int uid_flag = 0, gid_flag= 0, perm_flag = 0, i = 1, number, uid = 0, j;
+    int uid_flag = 0, gid_flag = 0, perm_flag = 0, i = 1, number, uid = 0, j;
 
-    while(i < argc)
+    while (i < argc)
     {
-        if(strcmp(argv[i], "-u") == 0)
+        if (strcmp(argv[i], "-u") == 0)
         {
-            if(uid_flag != 0)
+            if (uid_flag != 0)
             {
                 printf("%s\n", "-u option already used");
                 exit(1);
@@ -79,7 +79,7 @@ int privilege_control_old(int argc, char *argv[])
         }
         else if (strcmp(argv[i], "-g") == 0)
         {
-            if(gid_flag != 0)
+            if (gid_flag != 0)
             {
                 printf("%s\n", "-g option already used");
                 exit(1);
@@ -89,7 +89,7 @@ int privilege_control_old(int argc, char *argv[])
         }
         else if (strcmp(argv[i], "-p") == 0)
         {
-            if(perm_flag != 0)
+            if (perm_flag != 0)
             {
                 printf("%s\n", "-p option already used");
                 exit(1);
@@ -101,15 +101,15 @@ int privilege_control_old(int argc, char *argv[])
         {
             errno = 0;
             number = strtoul(argv[i], 0, 10);
-            if(errno != 0)
+            if (errno != 0)
             {
                 printf("%s\n", "Invalid option");
                 exit(1);
             }
-            switch(option)
+            switch (option)
             {
                 case 1:
-                    if(uid != 0)
+                    if (uid != 0)
                     {
                         printf("%s\n", "You cannot assign more than 1 uID");
                         exit(1);
@@ -117,22 +117,22 @@ int privilege_control_old(int argc, char *argv[])
                     uid = number;
                     break;
                 case 2:
-                    for(j=0;i<g_group_num;j++)
+                    for (j = 0; i < g_group_num; j++)
                     {
-                        if(number == g_groups[j])
+                        if (number == g_groups[j])
                             break;
                     }
-                    g_groups = (gid_t *)realloc(g_groups, sizeof(gid_t) * (++g_group_num));
-                    g_groups[g_group_num -1] = number;
+                    g_groups = (gid_t*)realloc(g_groups, sizeof(gid_t) * (++g_group_num));
+                    g_groups[g_group_num - 1] = number;
                     break;
                 case 3:
-                    for(j=0;i<g_perm_num;j++)
+                    for (j = 0; i < g_perm_num; j++)
                     {
-                        if(number == g_permissions[j])
+                        if (number == g_permissions[j])
                             break;
                     }
-                    g_permissions = (int *)realloc(g_permissions, sizeof(int) * (++g_perm_num));
-                    g_permissions[g_perm_num -1] = number;
+                    g_permissions = (int*)realloc(g_permissions, sizeof(int) * (++g_perm_num));
+                    g_permissions[g_perm_num - 1] = number;
                     break;
                 default:
                     printf("%s\n", "Invalid option");
@@ -142,12 +142,12 @@ int privilege_control_old(int argc, char *argv[])
         }
         i++;
     }
-    if(g_group_num == 0 || g_perm_num == 0)
+    if (g_group_num == 0 || g_perm_num == 0)
     {
         printf("%s\n", "You must assign groups and permissions");
         exit(1);
     }
-    if(setgroups(g_group_num, g_groups) != 0)
+    if (setgroups(g_group_num, g_groups) != 0)
     {
         printf("%s\n", "Error on setgroups{}");
         exit(1);
@@ -161,8 +161,8 @@ int privilege_control_old(int argc, char *argv[])
 int privilege_control_new(int argc, char *argv[])
 {
     if (argc == 7 && !strcmp(argv[1], "-s") &&
-                     !strcmp(argv[3], "-o") &&
-                     !strcmp(argv[5], "-a"))
+        !strcmp(argv[3], "-o") &&
+        !strcmp(argv[5], "-a"))
     {
         int ret;
         subject_label = argv[2];
@@ -188,7 +188,6 @@ int privilege_control_new(int argc, char *argv[])
 
 int privilege_control(int argc, char *argv[])
 {
-
     if (argc == 7 && !strcmp(argv[1], "-s"))
     {
         return privilege_control_new(argc, argv);
@@ -205,7 +204,7 @@ int connect_to_testserver()
     int client_len = 0, localsockfd, ret;
 
     /* Create a socket */
-    if((localsockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+    if ((localsockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
     {
         LogDebug("Error on socket()");
         return -1;
@@ -216,7 +215,7 @@ int connect_to_testserver()
     strncpy(clientaddr.sun_path, SECURITY_SERVER_TEST_SOCK_PATH, strlen(SECURITY_SERVER_TEST_SOCK_PATH));
     clientaddr.sun_path[strlen(SECURITY_SERVER_TEST_SOCK_PATH)] = 0;
     client_len = sizeof(clientaddr);
-    if(connect(localsockfd, (struct sockaddr*)&clientaddr, client_len) < 0)
+    if (connect(localsockfd, (struct sockaddr*)&clientaddr, client_len) < 0)
     {
         LogDebug("Error on connect");
         close(localsockfd);
@@ -232,7 +231,7 @@ int send_request(int sock_fd, unsigned char *cookie, int perm)
     memcpy(buf + 4, cookie, 20);
     memcpy(buf + 24, &perm, sizeof(int));
     size = write(sock_fd, buf, 28);
-    if(size < 28)
+    if (size < 28)
     {
         printf("Cannot send\n");
         close(sock_fd);
@@ -254,14 +253,14 @@ int send_request_new_cookie(int sock_fd,
     int size, ret;
     olen = strlen(subject_label);
     alen = strlen(access_rights);
-    size = 24+2*sizeof(int)+olen+alen;
+    size = 24 + 2 * sizeof(int) + olen + alen;
     memcpy(buf + 4, cookie, 20);
     memcpy(buf + 24, &olen, sizeof(int));
     memcpy(buf + 28, &alen, sizeof(int));
     memcpy(buf + 32, subject_label, olen);
     memcpy(buf + 32 + olen, access_rights, alen);
     ret = write(sock_fd, buf, size);
-    if(ret < size)
+    if (ret < size)
     {
         printf("Cannot send\n");
         close(sock_fd);
@@ -279,13 +278,13 @@ int send_request_new_direct(int sock_fd,
     int size, ret;
     olen = strlen(object_label);
     alen = strlen(access_rights);
-    size = 24+2*sizeof(int)+olen+alen;
+    size = 24 + 2 * sizeof(int) + olen + alen;
     memcpy(buf + 4, &olen, sizeof(int));
     memcpy(buf + 8, &alen, sizeof(int));
     memcpy(buf + 12, object_label, olen);
     memcpy(buf + 12 + olen, access_rights, alen);
     ret = write(sock_fd, buf, size);
-    if(ret < size)
+    if (ret < size)
     {
         printf("Cannot send\n");
         close(sock_fd);
@@ -298,7 +297,7 @@ int recv_result(int sock_fd)
 {
     int buf, size;
     size = read(sock_fd, &buf, sizeof(int));
-    if(size < sizeof(int))
+    if (size < sizeof(int))
     {
         printf("Cannot recv\n");
         close(sock_fd);
index fe44092..7f69e49 100644 (file)
 
 #include <security-server.h>
 
-#define ENVIRONMENT                                                  \
-do {                                                                 \
-    const char *subject_label = "mylabel";                           \
-    RUNNER_ASSERT_MSG(-1 != system("touch /opt/home/root/pid_cycle"),\
-        "Cannot prepare environment for test.");                     \
-    RUNNER_ASSERT_MSG(0 == smack_set_label_for_self(subject_label),  \
-        "Cannot prepare environment for test.");                     \
-    RUNNER_ASSERT_MSG(-1 != setgid(1),                               \
-        "Cannot prepare environment for test.");                     \
-    RUNNER_ASSERT_MSG(-1 != setuid(1),                               \
-        "Cannot prepare environment for test");                      \
-}while(0)
+#define ENVIRONMENT                                                       \
+    do {                                                                  \
+        const char *subject_label = "mylabel";                            \
+        RUNNER_ASSERT_MSG(-1 != system("touch /opt/home/root/pid_cycle"), \
+            "Cannot prepare environment for test.");                      \
+        RUNNER_ASSERT_MSG(0 == smack_set_label_for_self(subject_label),   \
+            "Cannot prepare environment for test.");                      \
+        RUNNER_ASSERT_MSG(-1 != setgid(1),                                \
+            "Cannot prepare environment for test.");                      \
+        RUNNER_ASSERT_MSG(-1 != setuid(1),                                \
+            "Cannot prepare environment for test");                       \
+    } while (0)
 
 /**
  * Dropping root privileges
@@ -40,18 +40,18 @@ do {                                                                 \
  */
 int drop_root_privileges()
 {
-       if (getuid() == 0) {
-               /* process is running as root, drop privileges */
-               if (setgid(5000) != 0)
-                       return 1;
-               if (setuid(5000) != 0)
-                       return 1;
-       }
-       int uid = getuid();
-       if (uid == 5000)
-               return 0;
-
-       return 1;
+    if (getuid() == 0) {
+        /* process is running as root, drop privileges */
+        if (setgid(5000) != 0)
+            return 1;
+        if (setuid(5000) != 0)
+            return 1;
+    }
+    int uid = getuid();
+    if (uid == 5000)
+        return 0;
+
+    return 1;
 }
 
 RUNNER_TEST_GROUP_INIT(SECURITY_SERVER_TESTS_CLIENT_SMACK)
@@ -145,9 +145,9 @@ RUNNER_CHILD_TEST(tc05_check_privilege_by_cookie)
     RUNNER_ASSERT(0 == smack_accesses_new(&handle));
 
     RUNNER_ASSERT(0 == smack_accesses_add(handle,
-                                          subject_label,
-                                          object_label,
-                                          access_rights));
+            subject_label,
+            object_label,
+            access_rights));
 
     RUNNER_ASSERT(0 == smack_accesses_apply(handle));
 
@@ -171,7 +171,6 @@ RUNNER_CHILD_TEST(tc05_check_privilege_by_cookie)
             cookie,
             object_label,
             access_rights_ext));
-
 }
 
 /*
@@ -183,7 +182,6 @@ RUNNER_CHILD_TEST(tc05_check_privilege_by_cookie)
  */
 RUNNER_TEST(tc06_check_privilege_by_sockfd)
 {
-
     const char *object_label = "tc06objectlabel";
     const char *access_rights = "r";
     const char *access_rights_ext = "rw";
@@ -195,9 +193,9 @@ RUNNER_TEST(tc06_check_privilege_by_sockfd)
     smack_accesses *handle;
     RUNNER_ASSERT(0 == smack_accesses_new(&handle));
     RUNNER_ASSERT(0 == smack_accesses_add(handle,
-                                          subject_label,
-                                          object_label,
-                                          access_rights));
+            subject_label,
+            object_label,
+            access_rights));
     RUNNER_ASSERT(0 == smack_accesses_apply(handle));
     smack_accesses_free(handle);
 
@@ -218,7 +216,7 @@ RUNNER_TEST(tc06_check_privilege_by_sockfd)
 
         label = security_server_get_smacklabel_sockfd(sockfd);
         RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
-        RUNNER_ASSERT_MSG(strcmp(label,"")==0, "label is \""<< label<<"\"");
+        RUNNER_ASSERT_MSG(strcmp(label,"") == 0, "label is \"" << label << "\"");
         free(label);
 
         RUNNER_ASSERT_MSG(drop_root_privileges() == 0, "uid = " << getuid());
@@ -231,7 +229,7 @@ RUNNER_TEST(tc06_check_privilege_by_sockfd)
 
         label = security_server_get_smacklabel_sockfd(sockfd);
         RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
-        RUNNER_ASSERT_MSG(strcmp(label,"")==0, "label is \""<< label<<"\"");
+        RUNNER_ASSERT_MSG(strcmp(label,"") == 0, "label is \"" << label << "\"");
         free(label);
 
 
@@ -239,7 +237,7 @@ RUNNER_TEST(tc06_check_privilege_by_sockfd)
         struct sockaddr_un client_addr;
         socklen_t client_len = sizeof(client_addr);
         int csockfd;
-        while(0 <= (csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len))) {
+        while (0 <= (csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len))) {
             LogDebug("child, loop");
             close(csockfd);
         }
@@ -247,7 +245,7 @@ RUNNER_TEST(tc06_check_privilege_by_sockfd)
 
         label = security_server_get_smacklabel_sockfd(sockfd);
         RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
-        RUNNER_ASSERT_MSG(strcmp(label,subject_label)==0, "label is \""<< label<<"\"" << "subject_label is \""<< subject_label<<"\"" );
+        RUNNER_ASSERT_MSG(strcmp(label,subject_label) == 0, "label is \"" << label << "\"" << "subject_label is \"" << subject_label << "\"" );
         free(label);
 
         LogDebug("Exit!");
@@ -260,7 +258,7 @@ RUNNER_TEST(tc06_check_privilege_by_sockfd)
 
         label = security_server_get_smacklabel_sockfd(sockfd);
         RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
-        RUNNER_ASSERT_MSG(strcmp(label,subject_label)==0, "label is \""<< label<<"\"" << "subject_label is \""<< subject_label<<"\"" );
+        RUNNER_ASSERT_MSG(strcmp(label,subject_label) == 0, "label is \"" << label << "\"" << "subject_label is \"" << subject_label << "\"" );
         free(label);
 
         LogDebug("Parent: sockfd: " << sockfd);
@@ -299,7 +297,6 @@ RUNNER_TEST(tc06_check_privilege_by_sockfd)
  */
 RUNNER_TEST(tc07_check_privilege_by_sockfd)
 {
-
     const char *object_label = "tc07objectlabel";
     const char *access_rights = "r";
     const char *access_rights_ext = "rw";
@@ -312,9 +309,9 @@ RUNNER_TEST(tc07_check_privilege_by_sockfd)
     smack_accesses *handle;
     RUNNER_ASSERT(0 == smack_accesses_new(&handle));
     RUNNER_ASSERT(0 == smack_accesses_add(handle,
-                                          subject_label,
-                                          object_label,
-                                          access_rights));
+            subject_label,
+            object_label,
+            access_rights));
     RUNNER_ASSERT(0 == smack_accesses_apply(handle));
     smack_accesses_free(handle);
 
@@ -343,7 +340,7 @@ RUNNER_TEST(tc07_check_privilege_by_sockfd)
         struct sockaddr_un client_addr;
         socklen_t client_len = sizeof(client_addr);
         int csockfd;
-        while(0 <= (csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len))) {
+        while (0 <= (csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len))) {
             LogDebug("child, loop");
             close(csockfd);
         }
index 1aeccf0..f5ca3b1 100644 (file)
@@ -26,15 +26,15 @@ RUNNER_TEST(tc_security_server_get_smacklabel_cookie) {
 
     pid_t mypid;
 
-    char * label_smack = NULL;
-    char * label_ss = NULL;
-    char * cookie = NULL;
+    char *label_smack = NULL;
+    char *label_ss = NULL;
+    char *cookie = NULL;
 
     int COOKIESIZE = security_server_get_cookie_size();
     RUNNER_ASSERT_MSG(20 == COOKIESIZE, "Wrong cookie size from security-server");
     LOGD("%s %d", "Cookie size:", COOKIESIZE);
 
-    cookie = (char *) calloc(COOKIESIZE, 1);
+    cookie = (char*) calloc(COOKIESIZE, 1);
     RUNNER_ASSERT_MSG(NULL != cookie, "Memory allocation error");
 
     mypid = getpid();
@@ -63,7 +63,7 @@ RUNNER_TEST(tc_security_server_get_smacklabel_cookie) {
     }
 
     LOGD("%s", "Received cookie:");
-    printhex((unsigned char *) cookie, COOKIESIZE);
+    printhex((unsigned char*) cookie, COOKIESIZE);
 
     label_ss = security_server_get_smacklabel_cookie(cookie);
     if (NULL == label_ss) {
@@ -104,7 +104,7 @@ RUNNER_TEST(tc_security_server_get_smacklabel_cookie) {
     //is changed using security-server API function based on the same cookie
 }
 
-int main(int argc, char * argv[])
+int main(int argc, char *argv[])
 {
     int status =
         DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
index 1717e71..c1da88b 100644 (file)
  * @file       security_server_tests_mt.cpp
  * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
  * @version    1.0
- * @ brief        This test creates multiple processes that connect to security
- *                        server and perform random operations using its API. The purpose
- *                        of this test is to check if security-server crashes when under
- *                        heavy load. Test succeeds if all processes finish.
+ * @brief      This test creates multiple processes that connect to security
+ *             server and perform random operations using its API. The purpose
+ *             of this test is to check if security-server crashes when under
+ *             heavy load. Test succeeds if all processes finish.
  */
 
 #include <dpl/log/log.h>
 #include <chrono>
 
 namespace {
-const size_t PROC_TOTAL = 1000;        // total number of processes to spawn
-const size_t PROC_MAX = 10;            // max number of processes working at the same time
-const size_t LOOPS = 50;       // number of loop repeats
+const size_t PROC_TOTAL = 1000; // total number of processes to spawn
+const size_t PROC_MAX = 10;     // max number of processes working at the same time
+const size_t LOOPS = 50;        // number of loop repeats
 
 std::default_random_engine generator(std::chrono::system_clock::now().time_since_epoch().count());
 
 // common function data
 struct Data {
-       char* cookie;   // not owned
+    char *cookie;   // not owned
 
-       Data(char* c): cookie(c) {}
+    Data(char *c) : cookie(c) {}
 };
 
 
 // test functions
-void request_cookie(const Data&) {
-       char cookie[20];
-       security_server_request_cookie(cookie, 20);
+void request_cookie(const Data&)
+{
+    char cookie[20];
+    security_server_request_cookie(cookie, 20);
 }
 
-void check_privilege(const Data& d) {
-       int ret = security_server_get_gid("audio");
-       security_server_check_privilege(d.cookie, ret);
+void check_privilege(const Data &d)
+{
+    int ret = security_server_get_gid("audio");
+    security_server_check_privilege(d.cookie, ret);
 }
 
-void check_privilege_by_cookie(const Data& d) {
-       security_server_check_privilege_by_cookie(d.cookie, "label", "rwxat");
+void check_privilege_by_cookie(const Data &d)
+{
+    security_server_check_privilege_by_cookie(d.cookie, "label", "rwxat");
 }
 
-void get_cookie_pid(const Data& d) {
-       security_server_get_cookie_pid(d.cookie);
+void get_cookie_pid(const Data &d)
+{
+    security_server_get_cookie_pid(d.cookie);
 }
 
-void get_smack_label(const Data& d) {
-       char* label = security_server_get_smacklabel_cookie(d.cookie);
-       free(label);
+void get_smack_label(const Data &d)
+{
+    char *label = security_server_get_smacklabel_cookie(d.cookie);
+    free(label);
 }
 
-void random_sleep(const Data&) {
-       std::uniform_int_distribution<size_t> distribution(0,100);
-       usleep(distribution(generator));
+void random_sleep(const Data&)
+{
+    std::uniform_int_distribution<size_t> distribution(0,100);
+    usleep(distribution(generator));
 }
 
 
 // list of test functions
 std::vector<std::function<void(const Data&)> > functions = {
-               random_sleep,
-               request_cookie,
-               check_privilege,
-               check_privilege_by_cookie,
-               get_cookie_pid,
-               get_smack_label
+    random_sleep,
+    request_cookie,
+    check_privilege,
+    check_privilege_by_cookie,
+    get_cookie_pid,
+    get_smack_label
 };
-
 } // namespace
 
 // randomly calls test functions
-void security_server_magic() {
-       char cookie[20];
-       security_server_request_cookie(cookie, 20);
-       Data d(cookie);
-
-       // random loop number
-       std::uniform_int_distribution<size_t> l_dist(0,LOOPS);
-       size_t loops = l_dist(generator);
-
-       // random function call
-       std::uniform_int_distribution<size_t> distribution(0,functions.size()-1);
-       auto rnd = std::bind(distribution, generator);
-       for (size_t i=0; i < loops;++i) {
-               functions[rnd()](d);
-       }
+void security_server_magic()
+{
+    char cookie[20];
+    security_server_request_cookie(cookie, 20);
+    Data d(cookie);
+
+    // random loop number
+    std::uniform_int_distribution<size_t> l_dist(0,LOOPS);
+    size_t loops = l_dist(generator);
+
+    // random function call
+    std::uniform_int_distribution<size_t> distribution(0,functions.size() - 1);
+    auto rnd = std::bind(distribution, generator);
+    for (size_t i = 0; i < loops; ++i) {
+        functions[rnd()](d);
+    }
 }
 
 int main()
 {
-       size_t current = 0;
-       size_t spawned = 0;
-       for (;;) {
-               if (current >= PROC_MAX || spawned >= PROC_TOTAL) {
-                       int status;
-                       int ret = wait(&status);
-
-                       // all processes spawned, no more children to wait for
-                       if (spawned >= PROC_TOTAL && ret <= 0)
-                               break;
-
-                       current--;
-               }
-
-               // spawn predefined number of processes
-               if (spawned < PROC_TOTAL) {
-                       pid_t pid = fork();
-                       if (pid == 0) {
-                               LogDebug("START " << spawned);
-                               security_server_magic();
-                               LogError("STOP " << spawned);
-                               exit(0);
-                       }
-                       else {
-                               //LogWarning("PID " << pid);
-                               spawned++;
-                               current++;
-                       }
-               }
-       }
-       LogInfo("Finished");
+    size_t current = 0;
+    size_t spawned = 0;
+    for (;;) {
+        if (current >= PROC_MAX || spawned >= PROC_TOTAL) {
+            int status;
+            int ret = wait(&status);
+
+            // all processes spawned, no more children to wait for
+            if (spawned >= PROC_TOTAL && ret <= 0)
+                break;
+
+            current--;
+        }
+
+        // spawn predefined number of processes
+        if (spawned < PROC_TOTAL) {
+            pid_t pid = fork();
+            if (pid == 0) {
+                LogDebug("START " << spawned);
+                security_server_magic();
+                LogError("STOP " << spawned);
+                exit(0);
+            }
+            else {
+                //LogWarning("PID " << pid);
+                spawned++;
+                current++;
+            }
+        }
+    }
+    LogInfo("Finished");
     return 0;
 }
index d024a18..f3b2100 100644 (file)
@@ -35,7 +35,7 @@ RUNNER_TEST(tc01_clear_environment)
     int ret;
     unsigned int attempt, max_attempt, expire_sec;
 
-    if(getuid() == 0)
+    if (getuid() == 0)
     {
         system("rm /opt/data/security-server/*");
         sync();
@@ -330,13 +330,13 @@ RUNNER_TEST(tc23_security_server_set_pwd_history)
 
 int dir_filter(const struct dirent *entry)
 {
-        if ((strcmp(entry->d_name, ".") == 0) ||
-               (strcmp(entry->d_name, "..") == 0) ||
-               (strcmp(entry->d_name, "attempts") ==0) ||
-               (strcmp(entry->d_name, "history") ==0) )
-               return (0);
-       else
-               return (1);
+    if ((strcmp(entry->d_name, ".") == 0) ||
+        (strcmp(entry->d_name, "..") == 0) ||
+        (strcmp(entry->d_name, "attempts") == 0) ||
+        (strcmp(entry->d_name, "history") == 0))
+        return (0);
+    else
+        return (1);
 }
 
 void clean_password_dir(void)
@@ -392,7 +392,7 @@ RUNNER_TEST(tc24_security_server_check_history)
         sleep(1);
 
         sprintf(buf1, "history%d", i);
-       sprintf(buf2, "history%d", i + 1);
+        sprintf(buf2, "history%d", i + 1);
 
         ret = security_server_set_pwd(buf1, buf2, 0, 0);
         RUNNER_ASSERT(ret == SECURITY_SERVER_API_SUCCESS);
index e22a87a..b9f9714 100644 (file)
@@ -44,19 +44,19 @@ void convert_prev_cookie(const char *cmdline, const char *prev, unsigned char *n
     char tmphexnum[3] = {0};
     cnt = security_server_get_cookie_size();
     cnt = cnt * 2;
-    if(strlen(prev) != cnt)
+    if (strlen(prev) != cnt)
     {
         printf("%s\n", "Cookie length is wrong");
         exit(1);
     }
 
-    for(i=0, cnt=0 ; i<strlen(prev) ; i=i+2)
+    for (i = 0, cnt = 0; i < strlen(prev); i = i + 2)
     {
-        strncpy(tmphexnum, prev+i, 2);
+        strncpy(tmphexnum, prev + i, 2);
         tmphexnum[2] = 0;
         errno = 0;
         now[cnt] = strtoul(tmphexnum, 0, 16);
-        if(errno != 0)
+        if (errno != 0)
         {
             printf("%s\n", "cannot convert hex cookie to binary");
             exit(1);
@@ -70,12 +70,11 @@ void check_status()
     struct stat statbuf;
     int ret;
     ret = stat("/opt/home/root/pid_cycle", &statbuf);
-    if(ret != 0)
+    if (ret != 0)
     {
         printf("Interrupt encountered. exiting...\n");
         exit(0);
     }
-
 }
 
 void cycle_pid(int pid)
@@ -83,12 +82,12 @@ void cycle_pid(int pid)
     int cur_pid = getpid();
     int dotval;
 
-    while(cur_pid != pid)
+    while (cur_pid != pid)
     {
-        if(fork() != 0)
+        if (fork() != 0)
         {
             dotval = cur_pid % 1000;
-            if(dotval == 0)
+            if (dotval == 0)
                 LOGD(".");
             exit(0);
         }
@@ -105,7 +104,7 @@ RUNNER_TEST(tc_security_server_request_cookie)
     LOGD("Cycling PID to %d\n", target_pid);
     cycle_pid(target_pid);
     unlink("/opt/home/root/pid_cycle");
-    RUNNER_ASSERT(security_server_request_cookie((char *)new_cookie, 20) == SECURITY_SERVER_API_SUCCESS);
+    RUNNER_ASSERT(security_server_request_cookie((char*)new_cookie, 20) == SECURITY_SERVER_API_SUCCESS);
     LOGD("\nTarget PID: %d, Target UID: %d\n", target_pid, target_uid);
     LOGD("Previous cookie:\n");
     printhex(prev_cookie, 20);
@@ -118,11 +117,11 @@ int main(int argc, char *argv[])
 {
     /* FIXME: proper parameters needed (these below are fake)
      *        or better idea for this test case...*/
-    char *argvv[] = {argv[0], "12345", "5000" , "abcdefabcdefabcdefabcdefabcdefabcdefabcd"};
+    char *argvv[] = {argv[0], "12345", "5000", "abcdefabcdefabcdefabcdefabcdefabcdefabcd"};
     int argcc = 4;
 
     target_uid = getuid();
-    if(target_uid != 0)
+    if (target_uid != 0)
     {
         printf("Error: %s must be executed by root\n", argv[0]);
         exit(1);
@@ -135,7 +134,7 @@ int main(int argc, char *argv[])
 
     errno = 0;
     target_uid = strtoul(argvv[1], 0, 10);
-    if(errno != 0)
+    if (errno != 0)
     {
         printf("%s\n", "cannot convert string uid to integer");
         exit(1);
@@ -145,7 +144,7 @@ int main(int argc, char *argv[])
 
     errno = 0;
     target_pid = strtoul(argvv[2], 0, 10);
-    if(errno != 0)
+    if (errno != 0)
     {
         printf("%s\n", "cannot convert string pid to integer");
         exit(1);
index 2e840b5..1b6a71d 100644 (file)
 #include <privilege-control.h>
 #include "test.h"
 
-#define SECURITY_SERVER_SOCK_PATH    "/tmp/.security_server.sock"
-#define COOKIE_SIZE 20
-#define OBJ_NAME_SIZE 30
-#define OLABEL_SIZE 1024
-#define ARIGHTS_SIZE 32
+#define SECURITY_SERVER_SOCK_PATH "/tmp/.security_server.sock"
+#define COOKIE_SIZE               20
+#define OBJ_NAME_SIZE             30
+#define OLABEL_SIZE               1024
+#define ARIGHTS_SIZE              32
 
 
 /* Message */
@@ -60,18 +60,18 @@ struct sockaddr_un clientaddr;
  */
 int drop_root_privileges()
 {
-       if (getuid() == 0) {
-               /* process is running as root, drop privileges */
-               if (setgid(5000) != 0)
-                       return 1;
-               if (setuid(5000) != 0)
-                       return 1;
-       }
-       int uid = getuid();
-       if (uid == 5000)
-               return 0;
-
-       return 1;
+    if (getuid() == 0) {
+        /* process is running as root, drop privileges */
+        if (setgid(5000) != 0)
+            return 1;
+        if (setuid(5000) != 0)
+            return 1;
+    }
+    int uid = getuid();
+    if (uid == 5000)
+        return 0;
+
+    return 1;
 }
 
 /* Create a Unix domain socket and bind */
@@ -87,15 +87,15 @@ int create_new_socket()
     }
 
     /* Create Unix domain socket */
-    if((localsockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
+    if ((localsockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
     {
         LOGE("%s : %s\n", "socket()", strerror(errno));
         goto error;
     }
 
     /* Make socket as non blocking */
-    if((flags = fcntl(localsockfd, F_GETFL, 0)) < 0 ||
-            fcntl(localsockfd, F_SETFL, flags | O_NONBLOCK) < 0)
+    if ((flags = fcntl(localsockfd, F_GETFL, 0)) < 0 ||
+        fcntl(localsockfd, F_SETFL, flags | O_NONBLOCK) < 0)
     {
         LOGE("%s : %s\n", "fcntl()", strerror(errno));
         goto error;
@@ -104,10 +104,10 @@ int create_new_socket()
     bzero (&serveraddr, sizeof(serveraddr));
     serveraddr.sun_family = AF_UNIX;
     strncpy(serveraddr.sun_path, SECURITY_SERVER_TEST_SOCK_PATH,
-            strlen(SECURITY_SERVER_TEST_SOCK_PATH) + 1);
+        strlen(SECURITY_SERVER_TEST_SOCK_PATH) + 1);
 
     /* Bind the socket */
-    if((bind(localsockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr))) < 0)
+    if ((bind(localsockfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr))) < 0)
     {
         LOGE("%s : %s\n", "bind()", strerror(errno));
         goto error;
@@ -118,7 +118,7 @@ int create_new_socket()
     /* Flawfinder hits this chmod function as level 5 CRITICAL as race condition flaw *
     * Flawfinder recommends to user fchmod insted of chmod
     * But, fchmod doesn't work on socket file so there is no other choice at this point */
-    if(chmod(SECURITY_SERVER_TEST_SOCK_PATH, sock_mode) < 0)        /* Flawfinder: ignore */
+    if (chmod(SECURITY_SERVER_TEST_SOCK_PATH, sock_mode) < 0)        /* Flawfinder: ignore */
     {
         LOGE("%s : %s\n", "chmod()", strerror(errno));
         goto error;
@@ -140,14 +140,14 @@ int check_socket_poll(int sockfd, int event, int timeout)
     poll_fd[0].fd = sockfd;
     poll_fd[0].events = event;
     retval = poll(poll_fd, 1, timeout);
-    if(retval < 0)
+    if (retval < 0)
     {
         LOGE("%s : %s\n", "poll()", strerror(errno));
         return -1;
     }
 
     /* Timed out */
-    if(retval == 0)
+    if (retval == 0)
     {
         LOGE("%s", "poll() timeout");
         return 0;
@@ -155,7 +155,7 @@ int check_socket_poll(int sockfd, int event, int timeout)
     return 1;
 }
 
-int send_gid_request(int sock_fd, const charobject)
+int send_gid_request(int sock_fd, const char *object)
 {
     basic_header hdr;
     int retval, send_len = 0;
@@ -167,8 +167,8 @@ int send_gid_request(int sock_fd, const char* object)
 
     send_len = sizeof(hdr) + strlen(object);
 
-    buf = (unsigned char *) malloc(send_len);
-    if(buf == NULL)
+    buf = (unsigned char*) malloc(send_len);
+    if (buf == NULL)
     {
         LOGE("%s\n", "out of memory");
         return -1;
@@ -179,31 +179,31 @@ int send_gid_request(int sock_fd, const char* object)
 
     /* Check poll */
     retval = check_socket_poll(sock_fd, POLLOUT, 1000);
-    if(retval == -1)
+    if (retval == -1)
     {
         LOGE("%s\n", "poll() error");
-        if(buf != NULL)
+        if (buf != NULL)
             free(buf);
         return -1;
     }
-    if(retval == 0)
+    if (retval == 0)
     {
         LOGE("%s\n", "poll() timeout");
-        if(buf != NULL)
+        if (buf != NULL)
             free(buf);
         return -1;
     }
 
     retval = write(sock_fd, buf, send_len);
-    if(retval < send_len)
+    if (retval < send_len)
     {
         /* Write error */
         LOGE("Error on write(): %d. errno=%d, sockfd=%d\n", retval, errno, sock_fd);
-        if(buf != NULL)
+        if (buf != NULL)
             free(buf);
         return -1;
     }
-    if(buf != NULL)
+    if (buf != NULL)
         free(buf);
 
     return 0;
@@ -217,15 +217,15 @@ int connect_to_server(int *fd)
 
     /* Create a socket */
     localsockfd = socket(AF_UNIX, SOCK_STREAM, 0);
-    if(localsockfd < 0)
+    if (localsockfd < 0)
     {
         LOGE("%s : %s\n", "socket()", strerror(errno));
         return -1;
     }
 
     /* Make socket as non blocking */
-    if((flags = fcntl(localsockfd, F_GETFL, 0)) < 0 ||
-            fcntl(localsockfd, F_SETFL, flags | O_NONBLOCK) < 0)
+    if ((flags = fcntl(localsockfd, F_GETFL, 0)) < 0 ||
+        fcntl(localsockfd, F_SETFL, flags | O_NONBLOCK) < 0)
     {
         close(localsockfd);
         LOGE("%s : %s\n", "fcntl()", strerror(errno));
@@ -239,20 +239,20 @@ int connect_to_server(int *fd)
     client_len = sizeof(clientaddr);
 
     ret = connect(localsockfd, (struct sockaddr*)&clientaddr, client_len);
-    ifret < 0)
+    if (ret < 0)
     {
-        if(errno == EINPROGRESS)
+        if (errno == EINPROGRESS)
         {
             LOGD("%s\n", "Connection is in progress");
             check_socket_poll(localsockfd, POLLOUT, 1000);
-            if(ret == -1)
+            if (ret == -1)
             {
                 LOGE("%s\n", "poll() error");
                 close(localsockfd);
                 return -1;
             }
             ret = connect(localsockfd, (struct sockaddr*)&clientaddr, client_len);
-            if(ret < 0)
+            if (ret < 0)
             {
                 LOGE("%s\n", "connection failed");
                 close(localsockfd);
@@ -278,7 +278,7 @@ int fake_get_gid(const char *object)
     response_header hdr;
 
     retval = connect_to_server(&sockfd);
-    if(retval != 0)
+    if (retval != 0)
     {
         /* Error on socket */
         LOGE("Connection failed: %d\n", retval);
@@ -287,7 +287,7 @@ int fake_get_gid(const char *object)
 
     /* make request packet and send to server*/
     retval = send_gid_request(sockfd, object);
-    if(retval != 0)
+    if (retval != 0)
     {
         /* Error on socket */
         LOGE("Send request failed: %d\n", retval);
@@ -296,7 +296,7 @@ int fake_get_gid(const char *object)
     LOGD("%s", "Just closing the socket and exit\n");
 
 error:
-    if(sockfd > 0)
+    if (sockfd > 0)
         close(sockfd);
 
     return 0;
@@ -307,7 +307,7 @@ RUNNER_TEST_GROUP_INIT(SECURITY_SERVER_TESTS_SERVER);
 RUNNER_TEST(tc_getting_default_cookie)
 {
     printhex(cookie, COOKIE_SIZE);
-    RUNNER_ASSERT(security_server_request_cookie((char *)cookie, 20) == SECURITY_SERVER_API_SUCCESS);
+    RUNNER_ASSERT(security_server_request_cookie((char*)cookie, 20) == SECURITY_SERVER_API_SUCCESS);
 }
 
 RUNNER_TEST(tc_security_server_get_gid_normal_case_trying_to_get_gid_of_tel_gprs)
@@ -346,10 +346,10 @@ RUNNER_TEST(tc_security_server_get_object_name_invalid_gid)
 
 RUNNER_TEST(tc_ask_for_privilege_with_default_cookie_normal_case_to_check_audio_privilege)
 {
-       printhex(cookie, COOKIE_SIZE);
-       RUNNER_ASSERT(security_server_request_cookie((char *)cookie, COOKIE_SIZE) == SECURITY_SERVER_API_SUCCESS);
+    printhex(cookie, COOKIE_SIZE);
+    RUNNER_ASSERT(security_server_request_cookie((char*)cookie, COOKIE_SIZE) == SECURITY_SERVER_API_SUCCESS);
     ret = security_server_get_gid("audio");
-    ret = security_server_check_privilege((char *) cookie, ret);
+    ret = security_server_check_privilege((char*) cookie, ret);
     RUNNER_ASSERT(ret == SECURITY_SERVER_API_SUCCESS);
 }
 
@@ -357,16 +357,15 @@ RUNNER_TEST(tc_ask_for_privilege_with_default_cookie_case_with_wrong_cookie)
 {
     ret = security_server_get_gid("audio");
     srand(time(NULL));
-    for(i=0; i<COOKIE_SIZE; i++)
+    for (i = 0; i < COOKIE_SIZE; i++)
         wrong_cookie[i] = rand() % 255;
-    ret = security_server_check_privilege((const char *) wrong_cookie, ret);
+    ret = security_server_check_privilege((const char*) wrong_cookie, ret);
     RUNNER_ASSERT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED);
 }
 
 
 RUNNER_TEST(tc_fake_security_server_get_gid)
 {
-
     /* Close socket just after sending request msg.
      * This is done with fake security_server_get_gid()*/
 
@@ -376,12 +375,12 @@ RUNNER_TEST(tc_fake_security_server_get_gid)
 
 RUNNER_TEST(tc_get_pid_of_a_given_cookie_default_cookie_case)
 {
-    RUNNER_ASSERT(security_server_get_cookie_pid((const char *) cookie) == getpid());
+    RUNNER_ASSERT(security_server_get_cookie_pid((const char*) cookie) == getpid());
 }
 
 RUNNER_TEST(tc_get_pid_of_non_existing_cookie)
 {
-    RUNNER_ASSERT(security_server_get_cookie_pid((const char *) wrong_cookie)== SECURITY_SERVER_API_ERROR_NO_SUCH_COOKIE);
+    RUNNER_ASSERT(security_server_get_cookie_pid((const char*) wrong_cookie) == SECURITY_SERVER_API_ERROR_NO_SUCH_COOKIE);
 }
 
 RUNNER_TEST(tc_get_pid_of_null_cookie)
@@ -398,8 +397,8 @@ RUNNER_CHILD_TEST(tc01a_security_server_app_give_access)
 
     RUNNER_ASSERT(0 == smack_accesses_new(&tmp));
 
-    std::unique_ptr<smack_accesses,std::function<void(smack_accesses*)>>
-        smack(tmp, smack_accesses_free);
+    std::unique_ptr<smack_accesses,std::function<void(smack_accesses*)> >
+    smack(tmp, smack_accesses_free);
 
     RUNNER_ASSERT(0 == smack_accesses_add(smack.get(), subject, object, "-----"));
     RUNNER_ASSERT(0 == smack_accesses_add(smack.get(), object, server_api, "rw"));
@@ -443,8 +442,8 @@ RUNNER_CHILD_TEST(tc01c_security_server_app_give_access_no_access)
 
     RUNNER_ASSERT(0 == smack_accesses_new(&tmp));
 
-    std::unique_ptr<smack_accesses,std::function<void(smack_accesses*)>>
-        smack(tmp, smack_accesses_free);
+    std::unique_ptr<smack_accesses,std::function<void(smack_accesses*)> >
+    smack(tmp, smack_accesses_free);
 
     RUNNER_ASSERT(0 == smack_accesses_add(smack.get(), subject, object, "-----"));
     RUNNER_ASSERT(0 == smack_accesses_apply(smack.get()));
@@ -479,7 +478,7 @@ int main(int argc, char *argv[])
     server_sockfd = -1;
 
     ret = getuid();
-    if(ret != 0)
+    if (ret != 0)
     {
         printf("Error: %s must be executed by root\n", argv[0]);
         exit(1);
@@ -488,9 +487,9 @@ int main(int argc, char *argv[])
     int status =
         DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
 
-    if(server_sockfd > 0)
+    if (server_sockfd > 0)
         close(server_sockfd);
-    if(client_sockfd > 0)
+    if (client_sockfd > 0)
         close(client_sockfd);
 
     return status;
index fb0945f..7af3658 100644 (file)
@@ -31,10 +31,10 @@ void printhex(unsigned char *data, int size)
     int i;
     std::ostringstream msg;
     msg << std::hex << std::setfill('0') << std::uppercase;
-    for(i=0;i<size;i++)
+    for (i = 0; i < size; i++)
     {
         msg << std::setw(2) << static_cast<int>(data[i]) << " ";
-        if(((i+1) % 16) == 0 && i != 0)
+        if (((i + 1) % 16) == 0 && i != 0)
             msg << std::endl;
     }
     msg << std::endl;