msg.msg_iov = &iov;
msg.msg_iovlen = 1;
- if (fds == NULL) { /* when muse_core_msg_send is called */
+ if (!fds) { /* when muse_core_msg_send is called */
msg.msg_control = NULL;
msg.msg_controllen = 0;
} else {
LOGD("Enter");
g_return_val_if_fail(bufmgr, MM_ERROR_INVALID_ARGUMENT);
- if (ms_get_instance()->bufmgr == NULL)
+ if (!ms_get_instance()->bufmgr)
g_return_val_if_fail(ms_init_bufmgr(), MM_ERROR_INVALID_ARGUMENT);
LOGD("bufmgr: %p", ms_get_instance()->bufmgr);
g_return_val_if_fail(ch->data_queue, NULL);
g_mutex_lock(&ch->data_mutex);
- while ((raw_data = (char *)g_queue_pop_head(ch->data_queue)) == NULL) {
+ while (!(raw_data = (char *)g_queue_pop_head(ch->data_queue))) {
if (!g_cond_wait_until(&ch->data_cond, &ch->data_mutex, end_time)) {
LOGE("[%d] timeout has passed", ch->sock_fd);
break;
while (m->msg_offset < len) {
jobj = muse_core_msg_object_new(m->recv_msg + m->msg_offset, &parse_len, NULL);
- if (jobj == NULL) {
+ if (!jobj) {
LOGE("jobj is null");
break;
}
if (muse_core_msg_object_get_value(MSG_KEY_MODULE_INDEX, jobj, MUSE_TYPE_INT, &idx)) {
m->idx = idx;
m->ch[MUSE_CHANNEL_MSG].dll_handle = ms_module_open(idx);
- if (_ms_ipc_module_instance_creation_is_allowed(idx) == FALSE) {
+ if (!_ms_ipc_module_instance_creation_is_allowed(idx) || !m->ch[MUSE_CHANNEL_MSG].data_thread) {
ms_cmd_dispatch(m, MUSE_MODULE_COMMAND_RESOURCE_NOT_AVAILABLE);
g_mutex_unlock(&dispatch_lock);
ms_exit_worker(m);
default:
m->ch[MUSE_CHANNEL_MSG].tbm_fd = tbm_fd[0];
- if (m->is_create_api_called == false) {
+ if (!m->is_create_api_called) {
g_mutex_lock(&dispatch_lock);
if (muse_core_msg_object_get_value(MSG_KEY_MODULE_INDEX, jobj, MUSE_TYPE_INT, &idx)) {
m->idx = idx;
m->ch[MUSE_CHANNEL_MSG].dll_handle = ms_module_open(idx);
- if (_ms_ipc_module_instance_creation_is_allowed(idx) == FALSE) {
+ if (!_ms_ipc_module_instance_creation_is_allowed(idx)) {
ms_cmd_dispatch(m, MUSE_MODULE_COMMAND_RESOURCE_NOT_AVAILABLE);
g_mutex_unlock(&dispatch_lock);
ms_exit_worker(m);
ms_module_dispatch(m, cmd);
- if (m->is_create_api_called == false) {
+ if (!m->is_create_api_called) {
SECURE_LOGW("_ms_ipc_module_cleanup [module %p] [loaded value %d]", m, value);
if (!value) {
LOGW("release module dll handle");
SECURE_LOGD("[%p] module's msg channel fd : %d", m, m->ch[MUSE_CHANNEL_MSG].sock_fd);
m->ch[MUSE_CHANNEL_MSG].data_thread = g_thread_try_new(MSG_THREAD_NAME, _ms_ipc_dispatch_worker, (gpointer)m, &error);
- if (m->ch[MUSE_CHANNEL_MSG].data_thread == NULL && error) {
+ if (!m->ch[MUSE_CHANNEL_MSG].data_thread && error) {
LOGE("thread creation failed : %s", error->message);
g_error_free(error);
ms_log_process_info(ms_get_instance()->pid);
- m->ch[MUSE_CHANNEL_MSG].dll_handle = ms_module_open(API_CREATE);
- ms_cmd_dispatch(m, MUSE_MODULE_COMMAND_RESOURCE_NOT_AVAILABLE);
}
MUSE_FREE(job);
g_return_val_if_fail(m, FALSE);
m->ch[MUSE_CHANNEL_DATA].data_thread = g_thread_try_new(DATA_THREAD_NAME, _ms_ipc_data_worker, (gpointer)m, &error);
- if (m->ch[MUSE_CHANNEL_DATA].data_thread == NULL && error) {
+ if (!m->ch[MUSE_CHANNEL_DATA].data_thread && error) {
LOGE("thread creation failed : %s", error->message);
g_error_free(error);
ms_log_process_info(ms_get_instance()->pid);
ms_cmd_dispatch(m, MUSE_MODULE_COMMAND_RESOURCE_NOT_AVAILABLE);
+ muse_core_connection_close(m->ch[MUSE_CHANNEL_MSG].sock_fd);
}
MUSE_FREE(job);
g_mutex_lock(&module->lock);
- if (ms_module_get_loaded_dllsym(idx) == false) {
+ if (!ms_module_get_loaded_dllsym(idx)) {
dllsym = g_module_open(ms_config_get_path(idx), G_MODULE_BIND_LAZY);
if (!dllsym)
}
}
- job = malloc(sizeof(ms_workqueue_job_t));
- if (job == NULL) {
+ job = calloc(1, sizeof(ms_workqueue_job_t));
+ if (!job) {
LOGE("failed to allocate memory for job state");
goto out;
}
muse_server->main_loop = g_main_loop_new(NULL, FALSE);
muse_server->diag_thread = g_thread_try_new("muse_server_diag_thread", _ms_diag_thread, muse_server->main_loop, &error);
- if (muse_server->diag_thread == NULL && error) {
+ if (!muse_server->diag_thread && error) {
snprintf(err_msg, sizeof(err_msg), "diag_thread creation failed : %s", error->message);
LOGE("%s", err_msg);
g_error_free(error);
LOGD("Enter");
muse_server->bufmgr = tbm_bufmgr_init(-1);
- if (muse_server->bufmgr == NULL) {
+ if (!muse_server->bufmgr) {
LOGE("Error - tbm_bufmgr_init");
return FALSE;
}
trace[1] = (void *) uctxt->uc_mcontext.gregs[REG_RIP];
#endif
strings = backtrace_symbols(trace, tracesize);
- if (strings == NULL) {
+ if (!strings) {
strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
LOGE("backtrace_symbols error: %s", err_msg);
} else {
LOGD("Enter");
system->connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (system->connection == NULL) {
+ if (!system->connection) {
if (error) {
LOGE("fail to get gdbus connection (%s)", error->message);
g_error_free(error);
return(EOF);
}
ms_tool_optopt = ri = argv[ms_tool_optind][si];
- if (ri == ':' || (cp = strchr(opts, ri)) == NULL) {
+ if (ri == ':' || !(cp = strchr(opts, ri))) {
if (argv[ms_tool_optind][++si] == '\0') {
ms_tool_optind++;
si = 1;
while (1) {
/* Wait until we get notified. */
pthread_mutex_lock(&worker->workqueue->jobs_mutex);
- while (worker->workqueue->waiting_jobs == NULL) {
+ while (!worker->workqueue->waiting_jobs) {
/* If we're supposed to terminate, break out of our continuous loop. */
if (worker->terminate)
break;
pthread_mutex_unlock(&worker->workqueue->jobs_mutex);
/* If we didn't get a job, then there's nothing to do at this time. */
- if (job == NULL)
+ if (!job)
continue;
/* Execute the job. */
- if (job->job_function(job) != TRUE) {
+ if (!job->job_function(job)) {
snprintf(err_msg, sizeof(err_msg), "Error - Execute the workqueue job, Restart muse server...");
LOGE("%s", err_msg);
ms_respawn(SIGABRT);