{
_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;
}
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);
}
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;
}