Remove compilation warrnings.
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Fri, 10 May 2013 16:39:08 +0000 (18:39 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 23 Jan 2014 13:32:20 +0000 (14:32 +0100)
[Issue#]    N/A
[Bug]       N/A
[Cause]     N/A
[Solution]  N/A

[Verification] N/A

Change-Id: Iacdf1ad61889dea08d0eeb34aaa50db9dace803c

tests/libprivilege-control-tests/test_cases.cpp

index cb7bd74..d840b24 100644 (file)
@@ -200,8 +200,8 @@ int test_have_any_accesses(const std::vector< std::vector<std::string> >& rules)
 
 RUNNER_TEST_GROUP_INIT(libprivilegecontrol)
 
-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);
@@ -210,8 +210,8 @@ int nftw_remove_labels(const char *fpath, const struct stat *sb,
        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);
@@ -220,8 +220,8 @@ int nftw_set_labels_non_app_dir(const char *fpath, const struct stat *sb,
        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;
     char* label;
@@ -247,7 +247,7 @@ 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;
     char* label;
@@ -278,7 +278,7 @@ 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;
     char* label;
@@ -561,7 +561,7 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
         result = app_install(app_labels[i]);
         RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in app_install.");
 
-        asprintf(&path, SMACK_RULES_DIR "/%s", app_labels[i]);
+        RUNNER_ASSERT(0 <= asprintf(&path, SMACK_RULES_DIR "/%s", app_labels[i]));
         fd = open(path, O_WRONLY, 0644);
         RUNNER_ASSERT_MSG(fd != -1, "Error in opening file " << path);
 
@@ -611,12 +611,12 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
 
     //TEST the operations on empty files
 
-    asprintf(&path, SMACK_RULES_DIR "/%s", app_labels[0]);
+    RUNNER_ASSERT(0 <= asprintf(&path, SMACK_RULES_DIR "/%s", app_labels[0]));
     file = fopen(path, "r");
 
     RUNNER_ASSERT_MSG(file, "fopen failed, errno:" << errno);
 
-    fgets(buf, READ_BUF_SIZE, file);
+    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 );
 
@@ -624,16 +624,16 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
     fclose(file);
 
     //TEST the operations on non empty files
-    asprintf(&path, SMACK_RULES_DIR "/%s", app_labels[2]);
+    RUNNER_ASSERT(0 <= asprintf(&path, SMACK_RULES_DIR "/%s", app_labels[2]));
     file = NULL;
     file = fopen(path, "r");
     RUNNER_ASSERT_MSG(file, "fopen failed, errno:" << errno);
 
-    fgets(buf, READ_BUF_SIZE, file);
+    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" );
 
-    fgets(buf, READ_BUF_SIZE, file);
+    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" );
 
@@ -683,7 +683,7 @@ RUNNER_CHILD_TEST(privilege_control05_set_app_privilege)
     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");
-    getgroups(groups_cnt, groups_list);
+    RUNNER_ASSERT(-1 != getgroups(groups_cnt, groups_list));
 
     for (int i = 0; i < groups_cnt; ++i) {
         if (groups_check.erase(groups_list[i]) == 0) {
@@ -848,7 +848,7 @@ RUNNER_TEST(privilege_control11_add_api_feature)
     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);
@@ -998,10 +998,6 @@ void checkOnlyAvAccess(const char* av_id, const char* app_id, const char* commen
 RUNNER_TEST(privilege_control10_app_register_av)
 {
     int result;
-    int i;
-
-    struct smack_accesses * rules = NULL;
-    char *path = NULL;
 
     // cleaning
     smack_revoke_subject(APP_TEST_AV_1);
@@ -1565,7 +1561,7 @@ static void smack_unix_sock_server(int sock)
         RUNNER_ASSERT_MSG(0, "smack_new_label_from_self() failed");
     }
     result = write(fd, smack_label, strlen(smack_label));
-    if(result != strlen(smack_label)){
+    if(result != (int)strlen(smack_label)){
         close(fd);
         close(sock);
         free(smack_label);