Replace g_assert with error handling#669
Merged
myungjoo merged 1 commit intonnstreamer:mainfrom Dec 5, 2025
Merged
Conversation
779c4cc to
6b46aa7
Compare
jaeyun-jung
reviewed
Dec 3, 2025
jaeyun-jung
reviewed
Dec 3, 2025
d4ffb8e to
c371fbf
Compare
songgot
commented
Dec 4, 2025
fcb8e67 to
18ee9bf
Compare
jaeyun-jung
reviewed
Dec 4, 2025
| G_LOCK (nns_native_lock); | ||
| g_assert (g_nns_is_initialized); | ||
|
|
||
| if (!g_nns_is_initialized) { |
Collaborator
There was a problem hiding this comment.
if (g_nns_is_initialized) {
data_path = g_files_dir;
} else {
_ml_loge ("NNStreamer native library is not initialized.");
}
Contributor
Author
There was a problem hiding this comment.
Thank you. And I wll add const.
const char *data_path = NULL;
jaeyun-jung
reviewed
Dec 4, 2025
| g_assert (pipe_info->jvm); | ||
| if (!pipe_info->jvm) { | ||
| _ml_loge ("Failed to get Java VM."); | ||
| nns_destroy_pipe_info (pipe_info, env); |
Collaborator
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
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 <hyunil46.park@samsung.com>
18ee9bf to
e945388
Compare
jaeyun-jung
approved these changes
Dec 5, 2025
myungjoo
approved these changes
Dec 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.