Separate monitoring function plugin
[platform/core/connectivity/stc-manager.git] / src / helper / helper-file.c
index 73b93bd..53dcad0 100755 (executable)
@@ -24,25 +24,19 @@ int fwrite_str(const char *path, const char *str)
        _cleanup_fclose_ FILE *f = NULL;
        int ret;
        char * t;
-       struct stat stat_buf;
 
        assert(path);
        assert(str);
 
-       if (stat(path, &stat_buf) == 0) {
-               t = realpath(path, NULL);
-               ret_value_errno_msg_if(!t, -errno,
-                                      "Fail to get realpath %s", path);
-               free(t);
-       }
+       t = realpath(path, NULL);
+       ret_value_if(!t, -errno);
+       free(t);
 
        f = fopen(path, "w");
-       ret_value_errno_msg_if(!f, -errno,
-                              "Fail to open file %s", path);
+       ret_value_if(!f, -errno);
 
        ret = fputs(str, f);
-       ret_value_errno_msg_if(ret == EOF, errno ? -errno : -EIO,
-                              "Fail to write file");
+       ret_value_if(ret == EOF, errno ? -errno : -EIO);
 
        return STC_ERROR_NONE;
 }
@@ -53,8 +47,7 @@ int fwrite_uint(const char *path, const uint32_t number)
        int ret;
 
        ret = asprintf(&digit_buf, "%d", number);
-       ret_value_errno_msg_if(ret < 0, -ENOMEM,
-                              "sprintf failed\n");
+       ret_value_if(ret < 0, -ENOMEM);
 
        return fwrite_str(path, digit_buf);
 }
@@ -65,12 +58,10 @@ int fread_uint(const char *path, uint32_t *number)
        int ret;
 
        f = fopen(path, "r");
-       ret_value_errno_msg_if(!f, -errno,
-                              "Fail to open %s file.", path);
+       ret_value_if(!f, -errno);
 
        ret = fscanf(f, "%u", number);
-       ret_value_errno_msg_if(ret == EOF, -errno,
-                              "Fail to read file\n");
+       ret_value_if(ret == EOF, -errno);
 
        return STC_ERROR_NONE;
 }