projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ctf, ctf-writer: Fix -Wnull-dereference warnings
[babeltrace.git]
/
src
/
ctf-writer
/
resolve.c
diff --git
a/src/ctf-writer/resolve.c
b/src/ctf-writer/resolve.c
index 6e9e2006c1d3ece72c76df6765b9afce31976463..4636e1c55348786ec6122624ba5cc94244606980 100644
(file)
--- a/
src/ctf-writer/resolve.c
+++ b/
src/ctf-writer/resolve.c
@@
-28,7
+28,7
@@
* SOFTWARE.
*/
* SOFTWARE.
*/
-#define BT_LOG_TAG "CTF-WRITER
-
RESOLVE"
+#define BT_LOG_TAG "CTF-WRITER
/
RESOLVE"
#include "logging.h"
#include <glib.h>
#include "logging.h"
#include <glib.h>
@@
-36,12
+36,12
@@
#include <limits.h>
#include <stdlib.h>
#include <limits.h>
#include <stdlib.h>
-#include <babeltrace2
/
ctf-writer/field-types.h>
-#include <babeltrace2
/
ctf-writer/object.h>
-#include <babeltrace2
/
ctf-writer/stream-class.h>
+#include <babeltrace2
-
ctf-writer/field-types.h>
+#include <babeltrace2
-
ctf-writer/object.h>
+#include <babeltrace2
-
ctf-writer/stream-class.h>
#include <babeltrace2/types.h>
#include <babeltrace2/types.h>
-#include "common/
babeltrace
.h"
+#include "common/
macros
.h"
#include "common/assert.h"
#include "field-path.h"
#include "common/assert.h"
#include "field-path.h"
@@
-166,7
+166,7
@@
int type_stack_push(type_stack *stack, struct bt_ctf_field_type_common *type)
goto end;
}
goto end;
}
- BT_LOG
V
("Pushing field type on context's stack: "
+ BT_LOG
T
("Pushing field type on context's stack: "
"ft-addr=%p, stack-size-before=%u", type, stack->len);
frame->type = bt_ctf_object_get_ref(type);
g_ptr_array_add(stack, frame);
"ft-addr=%p, stack-size-before=%u", type, stack->len);
frame->type = bt_ctf_object_get_ref(type);
g_ptr_array_add(stack, frame);
@@
-179,7
+179,7
@@
end:
* Checks whether or not `stack` is empty.
*/
static
* Checks whether or not `stack` is empty.
*/
static
-bt_bool type_stack_empty(type_stack *stack)
+bt_
ctf_
bool type_stack_empty(type_stack *stack)
{
return stack->len == 0;
}
{
return stack->len == 0;
}
@@
-201,15
+201,10
@@
size_t type_stack_size(type_stack *stack)
static
struct type_stack_frame *type_stack_peek(type_stack *stack)
{
static
struct type_stack_frame *type_stack_peek(type_stack *stack)
{
- struct type_stack_frame *entry = NULL;
+ BT_ASSERT(stack);
+ BT_ASSERT(!type_stack_empty(stack));
- if (!stack || type_stack_empty(stack)) {
- goto end;
- }
-
- entry = g_ptr_array_index(stack, stack->len - 1);
-end:
- return entry;
+ return g_ptr_array_index(stack, stack->len - 1);
}
/*
}
/*
@@
-218,19
+213,12
@@
end:
* Return value is owned by `stack`.
*/
static
* Return value is owned by `stack`.
*/
static
-struct type_stack_frame *type_stack_at(type_stack *stack,
- size_t index)
+struct type_stack_frame *type_stack_at(type_stack *stack, size_t index)
{
{
- struct type_stack_frame *entry = NULL;
+ BT_ASSERT(stack);
+ BT_ASSERT(index < stack->len);
- if (!stack || index >= stack->len) {
- goto end;
- }
-
- entry = g_ptr_array_index(stack, index);
-
-end:
- return entry;
+ return g_ptr_array_index(stack, index);
}
/*
}
/*
@@
-244,7
+232,7
@@
void type_stack_pop(type_stack *stack)
* This will call the frame's destructor and free it, as
* well as put its contained field type.
*/
* This will call the frame's destructor and free it, as
* well as put its contained field type.
*/
- BT_LOG
V
("Popping context's stack: stack-size-before=%u",
+ BT_LOG
T
("Popping context's stack: stack-size-before=%u",
stack->len);
g_ptr_array_set_size(stack, stack->len - 1);
}
stack->len);
g_ptr_array_set_size(stack, stack->len - 1);
}
@@
-259,7
+247,7
@@
static
struct bt_ctf_field_type_common *get_type_from_ctx(struct resolve_context *ctx,
enum bt_ctf_scope scope)
{
struct bt_ctf_field_type_common *get_type_from_ctx(struct resolve_context *ctx,
enum bt_ctf_scope scope)
{
- BT_ASSERT(scope >= BT_CTF_SCOPE_TRACE_PACKET_HEADER &&
+ BT_ASSERT
_DBG
(scope >= BT_CTF_SCOPE_TRACE_PACKET_HEADER &&
scope <= BT_CTF_SCOPE_EVENT_FIELDS);
return ctx->scopes[scope - BT_CTF_SCOPE_TRACE_PACKET_HEADER];
scope <= BT_CTF_SCOPE_EVENT_FIELDS);
return ctx->scopes[scope - BT_CTF_SCOPE_TRACE_PACKET_HEADER];
@@
-288,7
+276,7
@@
enum bt_ctf_scope get_root_scope_from_absolute_pathstr(const char *pathstr)
if (strncmp(pathstr, absolute_path_prefixes[scope],
strlen(absolute_path_prefixes[scope]))) {
/* Prefix does not match: try the next one */
if (strncmp(pathstr, absolute_path_prefixes[scope],
strlen(absolute_path_prefixes[scope]))) {
/* Prefix does not match: try the next one */
- BT_LOG
V
("Prefix does not match: trying the next one: "
+ BT_LOG
T
("Prefix does not match: trying the next one: "
"path=\"%s\", path-prefix=\"%s\", scope=%s",
pathstr, absolute_path_prefixes[scope],
bt_ctf_scope_string(scope));
"path=\"%s\", path-prefix=\"%s\", scope=%s",
pathstr, absolute_path_prefixes[scope],
bt_ctf_scope_string(scope));
@@
-297,7
+285,7
@@
enum bt_ctf_scope get_root_scope_from_absolute_pathstr(const char *pathstr)
/* Found it! */
ret = scope;
/* Found it! */
ret = scope;
- BT_LOG
V
("Found root scope from absolute path: "
+ BT_LOG
T
("Found root scope from absolute path: "
"path=\"%s\", scope=%s", pathstr,
bt_ctf_scope_string(scope));
goto end;
"path=\"%s\", scope=%s", pathstr,
bt_ctf_scope_string(scope));
goto end;
@@
-402,7
+390,7
@@
int ptokens_to_field_path(GList *ptokens, struct bt_ctf_field_path *field_path,
{
int ret = 0;
GList *cur_ptoken = ptokens;
{
int ret = 0;
GList *cur_ptoken = ptokens;
- bt_
bool first_level_done = BT
_FALSE;
+ bt_
ctf_bool first_level_done = BT_CTF
_FALSE;
/* Get our own reference */
bt_ctf_object_get_ref(type);
/* Get our own reference */
bt_ctf_object_get_ref(type);
@@
-415,7
+403,7
@@
int ptokens_to_field_path(GList *ptokens, struct bt_ctf_field_path *field_path,
enum bt_ctf_field_type_id type_id =
bt_ctf_field_type_common_get_type_id(type);
enum bt_ctf_field_type_id type_id =
bt_ctf_field_type_common_get_type_id(type);
- BT_LOG
V
("Current path token: token=\"%s\"", field_name);
+ BT_LOG
T
("Current path token: token=\"%s\"", field_name);
/* Find to which index corresponds the current path token */
if (type_id == BT_CTF_FIELD_TYPE_ID_ARRAY ||
/* Find to which index corresponds the current path token */
if (type_id == BT_CTF_FIELD_TYPE_ID_ARRAY ||
@@
-445,7
+433,7
@@
int ptokens_to_field_path(GList *ptokens, struct bt_ctf_field_path *field_path,
/* Next path token */
cur_ptoken = g_list_next(cur_ptoken);
/* Next path token */
cur_ptoken = g_list_next(cur_ptoken);
- first_level_done = BT_TRUE;
+ first_level_done = BT_
CTF_
TRUE;
}
/* Create new field path entry */
}
/* Create new field path entry */
@@
-541,7
+529,7
@@
int relative_ptokens_to_field_path(GList *ptokens,
int cur_index = type_stack_at(ctx->type_stack,
parent_pos_in_stack)->index;
int cur_index = type_stack_at(ctx->type_stack,
parent_pos_in_stack)->index;
- BT_LOG
V
("Locating target field type from current parent field type: "
+ BT_LOG
T
("Locating target field type from current parent field type: "
"parent-pos=%d, parent-ft-addr=%p, cur-index=%d",
parent_pos_in_stack, parent_type, cur_index);
"parent-pos=%d, parent-ft-addr=%p, cur-index=%d",
parent_pos_in_stack, parent_type, cur_index);
@@
-550,7
+538,7
@@
int relative_ptokens_to_field_path(GList *ptokens,
parent_type, cur_index);
if (ret) {
/* Not found... yet */
parent_type, cur_index);
if (ret) {
/* Not found... yet */
- BT_LOG
V
_STR("Not found at this point.");
+ BT_LOG
T
_STR("Not found at this point.");
bt_ctf_field_path_clear(tail_field_path);
} else {
/* Found: stitch tail field path to head field path */
bt_ctf_field_path_clear(tail_field_path);
} else {
/* Found: stitch tail field path to head field path */
@@
-558,7
+546,7
@@
int relative_ptokens_to_field_path(GList *ptokens,
int tail_field_path_len =
tail_field_path->indexes->len;
int tail_field_path_len =
tail_field_path->indexes->len;
- while (BT_TRUE) {
+ while (BT_
CTF_
TRUE) {
struct bt_ctf_field_type_common *cur_type =
type_stack_at(ctx->type_stack, i)->type;
int index = type_stack_at(
struct bt_ctf_field_type_common *cur_type =
type_stack_at(ctx->type_stack, i)->type;
int index = type_stack_at(
@@
-595,7
+583,7
@@
int relative_ptokens_to_field_path(GList *ptokens,
struct bt_ctf_field_type_common *root_type;
bt_ctf_field_path_clear(field_path);
struct bt_ctf_field_type_common *root_type;
bt_ctf_field_path_clear(field_path);
- BT_LOG
V
("Looking into potential root scope: scope=%s",
+ BT_LOG
T
("Looking into potential root scope: scope=%s",
bt_ctf_scope_string(field_path->root));
root_type = get_type_from_ctx(ctx, field_path->root);
if (!root_type) {
bt_ctf_scope_string(field_path->root));
root_type = get_type_from_ctx(ctx, field_path->root);
if (!root_type) {
@@
-608,13
+596,13
@@
int relative_ptokens_to_field_path(GList *ptokens,
root_type, INT_MAX);
if (ret) {
/* Not found yet */
root_type, INT_MAX);
if (ret) {
/* Not found yet */
- BT_LOG
V
_STR("Not found in this scope.");
+ BT_LOG
T
_STR("Not found in this scope.");
field_path->root--;
continue;
}
/* Found */
field_path->root--;
continue;
}
/* Found */
- BT_LOG
V
_STR("Found in this scope.");
+ BT_LOG
T
_STR("Found in this scope.");
break;
}
}
break;
}
}
@@
-662,7
+650,7
@@
struct bt_ctf_field_path *pathstr_to_field_path(const char *pathstr,
if (root_scope == BT_CTF_SCOPE_UNKNOWN) {
/* Relative path: start with current root scope */
field_path->root = ctx->root_scope;
if (root_scope == BT_CTF_SCOPE_UNKNOWN) {
/* Relative path: start with current root scope */
field_path->root = ctx->root_scope;
- BT_LOG
V
("Detected relative path: starting with current root scope: "
+ BT_LOG
T
("Detected relative path: starting with current root scope: "
"scope=%s", bt_ctf_scope_string(field_path->root));
ret = relative_ptokens_to_field_path(ptokens, field_path, ctx);
if (ret) {
"scope=%s", bt_ctf_scope_string(field_path->root));
ret = relative_ptokens_to_field_path(ptokens, field_path, ctx);
if (ret) {
@@
-680,7
+668,7
@@
struct bt_ctf_field_path *pathstr_to_field_path(const char *pathstr,
} else {
/* Absolute path: use found root scope */
field_path->root = root_scope;
} else {
/* Absolute path: use found root scope */
field_path->root = root_scope;
- BT_LOG
V
("Detected absolute path: using root scope: "
+ BT_LOG
T
("Detected absolute path: using root scope: "
"scope=%s", bt_ctf_scope_string(field_path->root));
ret = absolute_ptokens_to_field_path(ptokens, field_path, ctx);
if (ret) {
"scope=%s", bt_ctf_scope_string(field_path->root));
ret = absolute_ptokens_to_field_path(ptokens, field_path, ctx);
if (ret) {
@@
-697,7
+685,7
@@
struct bt_ctf_field_path *pathstr_to_field_path(const char *pathstr,
const char *field_path_pretty_str =
field_path_pretty ? field_path_pretty->str : NULL;
const char *field_path_pretty_str =
field_path_pretty ? field_path_pretty->str : NULL;
- BT_LOG
V
("Found field path: path=\"%s\", field-path=\"%s\"",
+ BT_LOG
T
("Found field path: path=\"%s\", field-path=\"%s\"",
pathstr, field_path_pretty_str);
if (field_path_pretty) {
pathstr, field_path_pretty_str);
if (field_path_pretty) {
@@
-812,7
+800,7
@@
int get_field_paths_lca_index(struct bt_ctf_field_path *field_path1,
int lca_index = 0;
int field_path1_len, field_path2_len;
int lca_index = 0;
int field_path1_len, field_path2_len;
- if (BT_LOG_ON_
VERBOS
E) {
+ if (BT_LOG_ON_
TRAC
E) {
GString *field_path1_pretty =
bt_ctf_field_path_string(field_path1);
GString *field_path2_pretty =
GString *field_path1_pretty =
bt_ctf_field_path_string(field_path1);
GString *field_path2_pretty =
@@
-822,7
+810,7
@@
int get_field_paths_lca_index(struct bt_ctf_field_path *field_path1,
const char *field_path2_pretty_str =
field_path2_pretty ? field_path2_pretty->str : NULL;
const char *field_path2_pretty_str =
field_path2_pretty ? field_path2_pretty->str : NULL;
- BT_LOG
V
("Finding lowest common ancestor (LCA) between two field paths: "
+ BT_LOG
T
("Finding lowest common ancestor (LCA) between two field paths: "
"field-path-1=\"%s\", field-path-2=\"%s\"",
field_path1_pretty_str, field_path2_pretty_str);
"field-path-1=\"%s\", field-path-2=\"%s\"",
field_path1_pretty_str, field_path2_pretty_str);
@@
-838,11
+826,11
@@
int get_field_paths_lca_index(struct bt_ctf_field_path *field_path1,
/*
* Start from both roots and find the first mismatch.
*/
/*
* Start from both roots and find the first mismatch.
*/
- BT_ASSERT(field_path1->root == field_path2->root);
+ BT_ASSERT
_DBG
(field_path1->root == field_path2->root);
field_path1_len = field_path1->indexes->len;
field_path2_len = field_path2->indexes->len;
field_path1_len = field_path1->indexes->len;
field_path2_len = field_path2->indexes->len;
- while (BT_TRUE) {
+ while (BT_
CTF_
TRUE) {
int target_index, ctx_index;
if (lca_index == field_path2_len ||
int target_index, ctx_index;
if (lca_index == field_path2_len ||
@@
-873,7
+861,7
@@
int get_field_paths_lca_index(struct bt_ctf_field_path *field_path1,
lca_index++;
}
lca_index++;
}
- BT_LOG
V
("Found LCA: lca-index=%d", lca_index);
+ BT_LOG
T
("Found LCA: lca-index=%d", lca_index);
return lca_index;
}
return lca_index;
}
@@
-1193,7
+1181,7
@@
int resolve_type(struct bt_ctf_field_type_common *type, struct resolve_context *
f_index;
}
f_index;
}
- BT_LOG
V
("Resolving field type's child field type: "
+ BT_LOG
T
("Resolving field type's child field type: "
"parent-ft-addr=%p, child-ft-addr=%p, "
"index=%" PRId64 ", count=%" PRId64,
type, child_type, f_index, field_count);
"parent-ft-addr=%p, child-ft-addr=%p, "
"index=%" PRId64 ", count=%" PRId64,
type, child_type, f_index, field_count);
@@
-1222,7
+1210,7
@@
int resolve_root_type(enum bt_ctf_scope root_scope, struct resolve_context *ctx)
{
int ret;
{
int ret;
- BT_ASSERT(type_stack_size(ctx->type_stack) == 0);
+ BT_ASSERT
_DBG
(type_stack_size(ctx->type_stack) == 0);
ctx->root_scope = root_scope;
ret = resolve_type(get_type_from_ctx(ctx, root_scope), ctx);
ctx->root_scope = BT_CTF_SCOPE_UNKNOWN;
ctx->root_scope = root_scope;
ret = resolve_type(get_type_from_ctx(ctx, root_scope), ctx);
ctx->root_scope = BT_CTF_SCOPE_UNKNOWN;
@@
-1255,7
+1243,7
@@
int bt_ctf_resolve_types(
.root_scope = BT_CTF_SCOPE_UNKNOWN,
};
.root_scope = BT_CTF_SCOPE_UNKNOWN,
};
- BT_LOG
V
("Resolving field types: "
+ BT_LOG
T
("Resolving field types: "
"packet-header-ft-addr=%p, "
"packet-context-ft-addr=%p, "
"event-header-ft-addr=%p, "
"packet-header-ft-addr=%p, "
"packet-context-ft-addr=%p, "
"event-header-ft-addr=%p, "
@@
-1333,7
+1321,7
@@
int bt_ctf_resolve_types(
}
}
}
}
- BT_LOG
V
_STR("Resolved field types.");
+ BT_LOG
T
_STR("Resolved field types.");
end:
type_stack_destroy(ctx.type_stack);
end:
type_stack_destroy(ctx.type_stack);
This page took
0.03019 seconds
and
4
git commands to generate.