-
Notifications
You must be signed in to change notification settings - Fork 27
Replace g_assert with error handling #669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
779c4cc to
6b46aa7
Compare
d4ffb8e to
c371fbf
Compare
fcb8e67 to
18ee9bf
Compare
| G_LOCK (nns_native_lock); | ||
| g_assert (g_nns_is_initialized); | ||
|
|
||
| if (!g_nns_is_initialized) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (g_nns_is_initialized) {
data_path = g_files_dir;
} else {
_ml_loge ("NNStreamer native library is not initialized.");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. And I wll add const.
const char *data_path = NULL;
| g_assert (pipe_info->jvm); | ||
| if (!pipe_info->jvm) { | ||
| _ml_loge ("Failed to get Java VM."); | ||
| nns_destroy_pipe_info (pipe_info, env); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You called nns_destroy_pipe_info() before creating all params (e.g., pipe_info->cls tensors_data_cls_info tensors_info_cls_info).
This causes null-ptr exception.
I suggest just removing this line, handling all error case is too complex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will fixe code like below.
pipe_info = g_new0 (pipeline_info_s, 1);
g_return_val_if_fail (pipe_info != NULL, NULL);
(*env)->GetJavaVM (env, &pipe_info->jvm);
if (!pipe_info->jvm) {
_ml_loge ("Failed to get Java VM.");
g_free (pipe_info);
return NULL;
}
pipe_info->pipeline_type = type;
pipe_info->pipeline_handle = handle;
pipe_info->element_handles =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
nns_free_element_data);
g_mutex_init (&pipe_info->lock);
pthread_key_create (&pipe_info->jni_env, NULL);
Release builds often define the compile option -DG_DISABLE_ASSERT for performance optimization. When this option is enabled, the g_assert(condition) macro is replaced by a no-op by the preprocessor. Signed-off-by: hyunil park <[email protected]>
18ee9bf to
e945388
Compare
Release builds often define the compile option -DG_DISABLE_ASSERT for performance optimization. When this option is enabled, the g_assert(condition) macro is replaced by a no-op by the preprocessor.