Fix smack_check() function 51/29551/12
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Wed, 29 Oct 2014 10:44:56 +0000 (11:44 +0100)
committerZbigniew Jasinski <z.jasinski@samsung.com>
Mon, 20 Apr 2015 13:20:18 +0000 (06:20 -0700)
Change-Id: I0ce0e769b7eb5b50dff34eea00db86c54a80eed9

src/common/tests_common.cpp
src/common/tests_common.h

index 6808b57..3095243 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -35,25 +35,15 @@ int DB::Transaction::db_result = PC_OPERATION_SUCCESS;
 
 const char *WGT_APP_ID = "QwCqJ0ttyS";
 
-int smack_runtime_check(void)
-{
-    static int smack_present = -1;
-    if (-1 == smack_present) {
-        if (smack_smackfs_path()) {
-            smack_present = 1;
-        } else {
-            smack_present = 0;
-        }
-    }
-    return smack_present;
-}
-
-int smack_check(void)
+bool smack_check(void)
 {
 #ifndef WRT_SMACK_ENABLED
-    return 0;
+    return false;
 #else
-    return smack_runtime_check();
+    static int smack_present = -1;
+    if (-1 == smack_present)
+        smack_present = smack_smackfs_path() == nullptr ? 0 : 1;
+    return smack_present == 1;
 #endif
 }
 
index c03d37a..2fb249b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -40,8 +40,7 @@ const uid_t DB_ALARM_UID = 6001;
 const gid_t DB_ALARM_GID = 6001;
 const std::string TMP_DIR("/tmp");
 
-int smack_runtime_check(void);
-int smack_check(void);
+bool smack_check(void);
 int drop_root_privileges(uid_t appUid = APP_UID, gid_t appGid = APP_GID);
 void setLabelForSelf(const int line, const char *label);
 void add_process_group(const char* group_name);