No need to check if `trace->metadata_path` is null at the point because
it has been used by `fopen()` already and `abort()` is called if
`fopen()` fails.
CID
1401238 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking trace->metadata_path suggests that it
may be null, but it has already been dereferenced on all paths leading
to the check.
Reported-by: Coverity (1401238) Dereference before null check
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I90590323764810da8a6b4cfb37445a588befd242
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1284
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins
tsdl = g_string_new(NULL);
BT_ASSERT(tsdl);
translate_trace_class_ctf_ir_to_tsdl(trace->tc, tsdl);
+
+ BT_ASSERT(trace->metadata_path);
fh = fopen(trace->metadata_path->str, "wb");
if (!fh) {
BT_LOGF_ERRNO("In trace destruction listener: "
trace->path = NULL;
}
- if (trace->metadata_path) {
- g_string_free(trace->metadata_path, TRUE);
- trace->metadata_path = NULL;
- }
+ g_string_free(trace->metadata_path, TRUE);
+ trace->metadata_path = NULL;
fs_sink_ctf_trace_class_destroy(trace->tc);
trace->tc = NULL;