Remove error log for reading classid from cgroup
[platform/core/connectivity/stc-manager.git] / src / helper / helper-net-cls.c
old mode 100644 (file)
new mode 100755 (executable)
index 238b7de..3f460f7
@@ -72,17 +72,19 @@ static int __place_classid_to_cgroup(const char *cgroup, const char *subdir,
        return cgroup_write_node_uint32(buf, CLASSID_FILE_NAME, result_classid);
 }
 
-static uint32_t __get_classid_from_cgroup(const char *cgroup,
-                                         const char *subdir)
+static stc_error_e __get_classid_from_cgroup(const char *cgroup,
+                                         const char *subdir, uint32_t *classid)
 {
        char buf[MAX_PATH_LENGTH];
-       uint32_t classid = STC_UNKNOWN_CLASSID;
        snprintf(buf, sizeof(buf), "%s/%s", cgroup, subdir);
 
-       int ret = cgroup_read_node_uint32(buf, CLASSID_FILE_NAME, &classid);
-       if (ret < 0)
-               STC_LOGE("Can't read classid from cgroup %s", buf); //LCOV_EXCL_LINE
-       return classid;
+       int ret = cgroup_read_node_uint32(buf, CLASSID_FILE_NAME, classid);
+       if (ret < 0) {
+               *classid = STC_UNKNOWN_CLASSID;
+               return STC_ERROR_NO_DATA;
+       }
+
+       return STC_ERROR_NONE;
 }
 
 stc_error_e init_current_classid(void)
@@ -102,10 +104,10 @@ stc_error_e init_current_classid(void)
        return STC_ERROR_NONE;
 }
 
-uint32_t get_classid_by_app_id(const char *app_id, int create)
+API uint32_t get_classid_by_app_id(const char *app_id, int create)
 {
-       int ret = 0;
        bool exists;
+       int ret = STC_ERROR_NONE;
        uint32_t classid = STC_UNKNOWN_CLASSID;
        const char *path_to_net_cgroup_dir = NULL;
 
@@ -114,7 +116,7 @@ uint32_t get_classid_by_app_id(const char *app_id, int create)
                return STC_UNKNOWN_CLASSID; //LCOV_EXCL_LINE
        }
 
-       if (!strcmp(app_id, STC_BACKGROUND_APP_ID))
+       if (!strcmp(app_id, STC_TOTAL_BACKGROUND))
                return STC_BACKGROUND_APP_CLASSID;
 
        if (!strcmp(app_id, STC_TOTAL_DATACALL))
@@ -144,8 +146,11 @@ uint32_t get_classid_by_app_id(const char *app_id, int create)
 
        /* just read */
        if (!create)
-               classid = __get_classid_from_cgroup(path_to_net_cgroup_dir, //LCOV_EXCL_LINE
-                                                   app_id);
+               ret = __get_classid_from_cgroup(path_to_net_cgroup_dir, //LCOV_EXCL_LINE
+                                                       app_id, &classid);
+
+       if (ret != STC_ERROR_NONE)
+               return STC_UNKNOWN_CLASSID;
 
        if (classid != STC_UNKNOWN_CLASSID)
                return classid;
@@ -156,8 +161,8 @@ uint32_t get_classid_by_app_id(const char *app_id, int create)
                goto handle_error;
 
        if (exists)
-               classid = __get_classid_from_cgroup(path_to_net_cgroup_dir,
-                                                   app_id);
+               ret = __get_classid_from_cgroup(path_to_net_cgroup_dir,
+                                                   app_id, &classid);
        else
                ret = __place_classid_to_cgroup(path_to_net_cgroup_dir,
                                                (char *)app_id, &classid, NULL);
@@ -184,9 +189,7 @@ stc_error_e place_pids_to_net_cgroup(const int pid, const char *app_id)
                return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
-       if (!strcmp(app_id, STC_BACKGROUND_APP_ID))
-               path_to_net_cgroup_dir = STC_CGROUP_NETWORK;
-       else if (strstr(app_id, STC_BACKGROUND_APP_SUFFIX))
+       if (strstr(app_id, STC_BACKGROUND_APP_SUFFIX))
                path_to_net_cgroup_dir = BACKGROUND_CGROUP_NETWORK;
        else if (strstr(app_id, STC_TETHERING_APP_SUFFIX))
                path_to_net_cgroup_dir = TETHERING_CGROUP_NETWORK;