const int pid)
{
int ret;
- char buf[ERR_BUF_SIZE];
- if (pid <=0) {
+ if (pid <= 0) {
_E("try to write empty pid to %s", cgroup_full_path);
return RESOURCED_ERROR_NO_DATA;
}
(u_int32_t)pid);
ret_value_msg_if(ret < 0, RESOURCED_ERROR_FAIL,
- "Failed place all pid to cgroup %s, error %s",
- cgroup_full_path, strerror_r(errno, buf, ERR_BUF_SIZE));
+ "Failed place all pid to cgroup %s : %m",
+ cgroup_full_path);
return RESOURCED_ERROR_NONE;
}
#define TIME_TO_SAFE_DATA 1 /* one second */
-#define ERR_BUF_SIZE 256
-
/*
* @desc reserved classid enums
* internal structure, we don't provide it externally
struct meminfo mi;
static unsigned int swap_total = 0;
unsigned int proc_swap_usage, zram_usage;
- char buf[ERR_BUF_SIZE];
/* Read total swap size just once and cache it */
if (!swap_total) {
ret = proc_get_meminfo(&mi, MEMINFO_MASK_SWAP_TOTAL);
if (ret < 0) {
- _E("Failed to get %s: %s",
- meminfo_id_to_string(MEMINFO_ID_SWAP_TOTAL),
- strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to get %s: %m",
+ meminfo_id_to_string(MEMINFO_ID_SWAP_TOTAL));
return RESOURCED_ERROR_FAIL;
}
swap_total = mi.value[MEMINFO_ID_SWAP_TOTAL];
{
struct meminfo mi;
int ret;
- char buf[ERR_BUF_SIZE];
ret = proc_get_meminfo(&mi, MEMINFO_MASK_MEM_AVAILABLE);
if (ret < 0) {
- _E("Failed to get %s: %s",
- meminfo_id_to_string(MEMINFO_ID_MEM_AVAILABLE),
- strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to get %s: %m",
+ meminfo_id_to_string(MEMINFO_ID_MEM_AVAILABLE));
return 0;
}
{
struct meminfo mi;
int ret;
- char buf[ERR_BUF_SIZE];
ret = proc_get_meminfo(&mi, MEMINFO_MASK_SWAP_FREE);
if (ret < 0) {
- _E("Failed to get %s: %s",
- meminfo_id_to_string(MEMINFO_ID_SWAP_FREE),
- strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to get %s: %m",
+ meminfo_id_to_string(MEMINFO_ID_SWAP_FREE));
return 0;
}
int proc_sys_node_trigger(enum sys_node_id sys_node_id)
{
FILE *fp = NULL;
- char buf[ERR_BUF_SIZE];
if (sys_node_id >= ARRAY_SIZE(sys_node_tables)) {
_E("sys_node_id[%d] is out of range.\n", sys_node_id);
/* open and check if the path exists, else return fail */
fp = fopen(sys_node_tables[sys_node_id].path, "w");
if (fp == NULL) {
- _E("Failed to open: %s: %s\n",
- sys_node_tables[sys_node_id].path,
- strerror_r(errno, buf, ERR_BUF_SIZE));
+ _E("Failed to open %s: %m\n",
+ sys_node_tables[sys_node_id].path);
sys_node_tables[sys_node_id].valid = 0;
return RESOURCED_ERROR_FAIL;
}
sqlite3_free(a); \
}
-#define TRACE_RET_ERRCODE(type, error_code) do { \
- char buf[ERR_BUF_SIZE]; \
- _##type("errno %d, errmsg %s", error_code, strerror_r(-error_code, buf, ERR_BUF_SIZE)); \
+#define TRACE_RET_ERRCODE(type, error_code) \
+do { \
+ _##type("errno %d, errmsg %m", error_code); \
} while (0)
#define DTRACE_RET_ERRCODE(error_code) TRACE_RET_ERRCODE(D, error_code)
#define ETRACE_RET_ERRCODE(error_code) TRACE_RET_ERRCODE(E, error_code)
-#define TRACE_RET_ERRCODE_MSG(type, error_code, fmt, arg...) do { \
- char buf[ERR_BUF_SIZE]; \
- _##type(fmt, ##arg); \
- _##type("errno %d, errmsg %s", error_code, strerror_r(-error_code, buf, ERR_BUF_SIZE)); \
+#define TRACE_RET_ERRCODE_MSG(type, error_code, fmt, arg...) \
+do { \
+ _##type(fmt, ##arg); \
+ _##type("errno %d, errmsg %m", error_code); \
} while (0)
#define DTRACE_RET_ERRCODE_MSG(error_code, fmt, arg...) \
_cleanup_free_ char *info = NULL;
unsigned int pss = 0, uss = 0;
int ret;
- char error_buf[ERR_BUF_SIZE];
/* For write to data crud during period */
/* write memory usage in proc_list */
SMAPS_MASK_PRIVATE_DIRTY |
SMAPS_MASK_SWAP));
if (ret < 0) {
- _E("Failed to get PID(%d) smaps: %s",
- p_data->pid,
- strerror_r(-ret, error_buf, ERR_BUF_SIZE));
+ _E("Failed to get PID(%d) smaps: %m", p_data->pid);
return ret;
}
{
void *mem = NULL;
int r;
- char buf[ERR_BUF_SIZE];
fprintf(stdout, "Memory stress size is: %zu", arg_size);
r = mem_stress_allocate_memory(&mem, arg_size);
if (r < 0) {
- fprintf(stderr, "Failed to allocate memory: %s", strerror_r(-r, buf, ERR_BUF_SIZE));
+ fprintf(stderr, "Failed to allocate memory: %m");
return r;
}
r = mem_stress_free_memory(mem, arg_size);
if (r < 0) {
- fprintf(stderr, "Failed to free memory: %s", strerror_r(-r, buf, ERR_BUF_SIZE));
+ fprintf(stderr, "Failed to free memory: %m");
return r;
}
void proc_app_list_close(void)
{
int err;
- char buf[ERR_BUF_SIZE];
app_list.ref--;
err = pthread_mutex_unlock(&app_list.lock);
if (err)
- _E("Failed to unlock app list mutex: %s",
- strerror_r(err, buf, ERR_BUF_SIZE));
+ _E("Failed to unlock app list mutex: %m");
}
static bool is_ui_app(enum application_type type)
{
_cleanup_free_ char *runtime_app_info_path = NULL;
int ret;
- char buf[ERR_BUF_SIZE];
assert(pai);
assert(pid > 0);
runtime_app_info_path = proc_get_runtime_app_info_path(pai);
if (!runtime_app_info_path) {
- _E("Failed to get runtime appinfo path: %s",
- strerror_r(ENOMEM, buf, ERR_BUF_SIZE));
+ _E("Failed to get runtime appinfo path: not enough memory");
return;
}
ret = proc_runtime_app_info_write_procs(runtime_app_info_path, pai->childs);
if (ret < 0)
- _E("Failed to write appinfo children '%s': %s",
- runtime_app_info_path, strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to write appinfo children '%s': %m", runtime_app_info_path);
}
void proc_set_process_memory_state(struct proc_app_info *pai,
{
_cleanup_app_list_close_ GSList *proc_app_list = PAL_INIT_VALUE;
int ret;
- char buf[ERR_BUF_SIZE];
if (pai->main_pid <= 0)
return;
ret = proc_runtime_write_app_info(pai);
if (ret < 0)
- _E("Failed to add runtime app info: %s", strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to add runtime app info: %m");
proc_app_list = proc_app_list_open();
app_list.list = g_slist_prepend(proc_app_list, pai);
{
_cleanup_app_list_close_ GSList *proc_app_list = PAL_INIT_VALUE;
int ret;
- char buf[ERR_BUF_SIZE];
ret = proc_runtime_remove_app_info(pai);
if (ret < 0)
- _E("Failed to remove appinfo '%s': %s",
- pai->appid, strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to remove appinfo '%s': %m", pai->appid);
proc_app_list = proc_app_list_open();
app_list.list = g_slist_remove(proc_app_list, pai);
{
_cleanup_free_ char *runtime_app_info_path = NULL;
int ret;
- char buf[ERR_BUF_SIZE];
assert(pai);
assert(pid >= 0);
runtime_app_info_path = proc_get_runtime_app_info_path(pai);
if (!runtime_app_info_path) {
- _E("Failed to get runtime appinfo path: %s",
- strerror_r(ENOMEM, buf, ERR_BUF_SIZE));
+ _E("Failed to get runtime appinfo path: not enough memory");
return;
}
ret = proc_runtime_app_info_write_procs(runtime_app_info_path, pai->childs);
if (ret < 0)
- _E("Failed to write appinfo children '%s': %s",
- runtime_app_info_path, strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to write appinfo children '%s': %m", runtime_app_info_path);
return;
ret = proc_runtime_app_info_remove_procs(runtime_app_info_path);
if (ret < 0)
- _E("Failed to remove appinfo children '%s': %s",
- runtime_app_info_path, strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to remove appinfo children '%s': %m", runtime_app_info_path);
return;
}
_cleanup_closedir_ DIR *dp = NULL;
struct dirent dentry;
struct dirent *dir;
- char buf[ERR_BUF_SIZE];
dp = opendir(RUNTIME_APP_INFO_DIR);
if (!dp)
ret = proc_restore_runtime_app_info(path);
if (ret < 0)
- _E("Failed to restore runtime appinfo '%s': %s",
- dir->d_name, strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to restore runtime appinfo '%s': %m", dir->d_name);
}
}
static int resourced_proc_init(void* data)
{
- char buf[ERR_BUF_SIZE];
int ret = mkdir(RUNTIME_APP_INFO_DIR, S_IRWXU | S_IRGRP | S_IXGRP);
if (ret < 0 && errno != EEXIST) {
- _E("Failed to create directory %s: %s", RUNTIME_APP_INFO_DIR,
- strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to create directory %s: %m", RUNTIME_APP_INFO_DIR);
return RESOURCED_ERROR_FAIL;
}
DBusMessage *reply;
struct meminfo mi;
int r;
- char error_buf[ERR_BUF_SIZE];
reply = dbus_message_new_method_return(msg);
MEMINFO_MASK_SWAP_TOTAL |
MEMINFO_MASK_SWAP_FREE);
if (r < 0) {
- _E("Failed to get meminfo: %s",
- strerror_r(-r, error_buf, ERR_BUF_SIZE));
+ _E("Failed to get meminfo: %m");
return reply;
}
{
pid_t pid = getpid(), old_pid = 0;
int ret;
- char buf[ERR_BUF_SIZE];
assert(pid >= 0);
ret = mkdir(RUNTIME_RESOURCED_DIR, S_IRWXU | S_IRGRP | S_IXGRP);
if (ret < 0 && errno != EEXIST)
- _E("Failed to create directory %s: %s",
- RUNTIME_RESOURCED_DIR, strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to create directory %s: %m",
+ RUNTIME_RESOURCED_DIR);
if (access(RUNTIME_RESOURCED_PID_PATH, F_OK) < 0)
goto write_pid;
ret = fread_uint(RUNTIME_RESOURCED_PID_PATH, (u_int32_t*)&old_pid);
if (ret < 0) {
- _E("Failed to read old resourced pid: %s", strerror_r(-ret, buf, ERR_BUF_SIZE));
+ _E("Failed to read old resourced pid: %m");
return ret;
}
int status;
pid_t child_pid;
pid_t pid = fork();
- char error_buf[ERR_BUF_SIZE];
if (pid < 0) {
_E("failed to fork");
/* parent */
child_pid = waitpid(pid, &status, 0);
if (child_pid < 0) {
- _E("can't wait for a pid %d %d %s", pid, status,
- strerror_r(errno, error_buf, ERR_BUF_SIZE));
+ _E("can't wait for a pid %d %d: %m", pid, status);
return child_pid;
}
_cleanup_free_ char *cgroup_name = NULL;
bool already;
int r;
- char buf[ERR_BUF_SIZE];
assert(name);
assert(pid);
r = cgroup_write_node_uint32(cgroup_name, TASK_FILE_NAME, pid);
if (r < 0) {
- _E("failed to write pid '%d' to '%s': %s",
- pid, cgroup_name, strerror_r(-r, buf, ERR_BUF_SIZE));
+ _E("failed to write pid '%d' to '%s': %m",
+ pid, cgroup_name);
return r;
}
{
_cleanup_close_ int checkfd = -1;
int r;
- char buf[ERR_BUF_SIZE];
r = access(CHECK_RELEASE_PROGRESS, F_OK);
if (r == 0) {
r = config_parse(VIP_CONF_FILE, vip_load_config, NULL);
if (r < 0) {
- _E("failed to parse vip config file: %s", strerror_r(-r, buf, ERR_BUF_SIZE));
+ _E("failed to parse vip config file: %m");
return RESOURCED_ERROR_FAIL;
}
r = cgroup_set_release_agent("vip", "/usr/bin/vip-release-agent");
if (r < 0) {
- _E("failed to set vip release agent: %s", strerror_r(-r, buf, ERR_BUF_SIZE));
+ _E("failed to set vip release agent: %m");
return RESOURCED_ERROR_FAIL;
}
}
{
int status = 0, times = 0, wpid;
pid_t pid = 0;
- char buf[ERR_BUF_SIZE];
if (argv == NULL)
return -3;
if (pid == 0) {
setpgid(0, 0);
if (execv(argv[0], argv) == -1) {
- _E("Error execv: %s.\n", strerror_r(errno, buf, ERR_BUF_SIZE));
+ _E("Error execv: %m.\n");
_exit(-1);
}
_exit(1);