Add retry mechanism for netlink socket creation
[platform/core/connectivity/stc-manager.git] / src / helper / helper-file.c
index 636ef5d..e2f284f 100755 (executable)
@@ -23,23 +23,15 @@ int fwrite_str(const char *path, const char *str)
 {
        _cleanup_fclose_ FILE *f = NULL;
        int ret;
-       char * t;
 
        assert(path);
        assert(str);
 
-       t = realpath(path, NULL);
-       ret_value_errno_msg_if(!t, -errno,
-                              "Fail to get realpath %s", path);
-       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;
 }
@@ -50,8 +42,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);
 }
@@ -62,12 +53,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;
 }