projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleanup: add `#include <stdbool.h>` whenever `bool` type is used
[babeltrace.git]
/
src
/
plugins
/
text
/
pretty
/
print.c
diff --git
a/src/plugins/text/pretty/print.c
b/src/plugins/text/pretty/print.c
index c098dd6ca993326f5fd054f014bdc3244ac3f3cc..6fb1e9fd69ca6bafb9d80173a1a38d332c9a73bb 100644
(file)
--- a/
src/plugins/text/pretty/print.c
+++ b/
src/plugins/text/pretty/print.c
@@
-31,6
+31,7
@@
#include "common/assert.h"
#include <inttypes.h>
#include <ctype.h>
#include "common/assert.h"
#include <inttypes.h>
#include <ctype.h>
+#include <stdbool.h>
#include <string.h>
#include "pretty.h"
#include <string.h>
#include "pretty.h"
@@
-440,7
+441,7
@@
int print_event_header(struct pretty_component *pretty,
&log_level);
if (prop_avail == BT_PROPERTY_AVAILABILITY_AVAILABLE) {
log_level_str = log_level_names[log_level];
&log_level);
if (prop_avail == BT_PROPERTY_AVAILABILITY_AVAILABLE) {
log_level_str = log_level_names[log_level];
- BT_ASSERT(log_level_str);
+ BT_ASSERT
_DBG
(log_level_str);
if (!pretty->start_line) {
bt_common_g_string_append(pretty->string, ", ");
if (!pretty->start_line) {
bt_common_g_string_append(pretty->string, ", ");
@@
-528,10
+529,10
@@
int print_integer(struct pretty_component *pretty,
bt_field_class_type ft_type;
int_fc = bt_field_borrow_class_const(field);
bt_field_class_type ft_type;
int_fc = bt_field_borrow_class_const(field);
- BT_ASSERT(int_fc);
+ BT_ASSERT
_DBG
(int_fc);
ft_type = bt_field_get_class_type(field);
ft_type = bt_field_get_class_type(field);
- if (
ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER ||
-
ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
) {
+ if (
bt_field_class_type_is(ft_type,
+
BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER)
) {
v.u = bt_field_integer_unsigned_get_value(field);
} else {
v.s = bt_field_integer_signed_get_value(field);
v.u = bt_field_integer_unsigned_get_value(field);
} else {
v.s = bt_field_integer_signed_get_value(field);
@@
-560,8
+561,8
@@
int print_integer(struct pretty_component *pretty,
}
case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL:
{
}
case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL:
{
- if (
ft_type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER ||
-
ft_type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
) {
+ if (
bt_field_class_type_is(ft_type,
+
BT_FIELD_CLASS_TYPE_SIGNED_INTEGER)
) {
int len;
len = bt_field_class_integer_get_field_value_range(
int len;
len = bt_field_class_integer_get_field_value_range(
@@
-569,7
+570,7
@@
int print_integer(struct pretty_component *pretty,
if (len < 64) {
size_t rounded_len;
if (len < 64) {
size_t rounded_len;
- BT_ASSERT(len != 0);
+ BT_ASSERT
_DBG
(len != 0);
/* Round length to the nearest 3-bit */
rounded_len = (((len - 1) / 3) + 1) * 3;
v.u &= ((uint64_t) 1 << rounded_len) - 1;
/* Round length to the nearest 3-bit */
rounded_len = (((len - 1) / 3) + 1) * 3;
v.u &= ((uint64_t) 1 << rounded_len) - 1;
@@
-580,8
+581,8
@@
int print_integer(struct pretty_component *pretty,
break;
}
case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL:
break;
}
case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL:
- if (
ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER ||
-
ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
) {
+ if (
bt_field_class_type_is(ft_type,
+
BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER)
) {
bt_common_g_string_append_printf(pretty->string, "%" PRIu64, v.u);
} else {
bt_common_g_string_append_printf(pretty->string, "%" PRId64, v.s);
bt_common_g_string_append_printf(pretty->string, "%" PRIu64, v.u);
} else {
bt_common_g_string_append_printf(pretty->string, "%" PRId64, v.s);
@@
-836,7
+837,7
@@
int print_array_field(struct pretty_component *pretty,
}
field = bt_field_array_borrow_element_field_by_index_const(array, i);
}
field = bt_field_array_borrow_element_field_by_index_const(array, i);
- BT_ASSERT(field);
+ BT_ASSERT
_DBG
(field);
return print_field(pretty, field, print_names);
}
return print_field(pretty, field, print_names);
}
@@
-886,7
+887,7
@@
int print_sequence_field(struct pretty_component *pretty,
}
field = bt_field_array_borrow_element_field_by_index_const(seq, i);
}
field = bt_field_array_borrow_element_field_by_index_const(seq, i);
- BT_ASSERT(field);
+ BT_ASSERT
_DBG
(field);
return print_field(pretty, field, print_names);
}
return print_field(pretty, field, print_names);
}
@@
-952,7
+953,7
@@
int print_variant(struct pretty_component *pretty,
const bt_field *field = NULL;
field = bt_field_variant_borrow_selected_option_field_const(variant);
const bt_field *field = NULL;
field = bt_field_variant_borrow_selected_option_field_const(variant);
- BT_ASSERT(field);
+ BT_ASSERT
_DBG
(field);
bt_common_g_string_append(pretty->string, "{ ");
pretty->depth++;
if (print_names) {
bt_common_g_string_append(pretty->string, "{ ");
pretty->depth++;
if (print_names) {
@@
-977,9
+978,7
@@
int print_field(struct pretty_component *pretty,
bt_field_class_type class_id;
class_id = bt_field_get_class_type(field);
bt_field_class_type class_id;
class_id = bt_field_get_class_type(field);
- switch (class_id) {
- case BT_FIELD_CLASS_TYPE_BOOL:
- {
+ if (class_id == BT_FIELD_CLASS_TYPE_BOOL) {
bt_bool v;
const char *text;
bt_bool v;
const char *text;
@@
-997,9
+996,7
@@
int print_field(struct pretty_component *pretty,
bt_common_g_string_append(pretty->string, COLOR_RST);
}
return 0;
bt_common_g_string_append(pretty->string, COLOR_RST);
}
return 0;
- }
- case BT_FIELD_CLASS_TYPE_BIT_ARRAY:
- {
+ } else if (class_id == BT_FIELD_CLASS_TYPE_BIT_ARRAY) {
uint64_t v = bt_field_bit_array_get_value_as_integer(field);
if (pretty->use_colors) {
uint64_t v = bt_field_bit_array_get_value_as_integer(field);
if (pretty->use_colors) {
@@
-1012,17
+1009,18
@@
int print_field(struct pretty_component *pretty,
bt_common_g_string_append(pretty->string, COLOR_RST);
}
return 0;
bt_common_g_string_append(pretty->string, COLOR_RST);
}
return 0;
- }
- case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
- case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
+ } else if (bt_field_class_type_is(class_id,
+ BT_FIELD_CLASS_TYPE_ENUMERATION)) {
+ return print_enum(pretty, field);
+ } else if (bt_field_class_type_is(class_id,
+ BT_FIELD_CLASS_TYPE_INTEGER)) {
return print_integer(pretty, field);
return print_integer(pretty, field);
- case BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL:
- case BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL:
- {
+ } else if (bt_field_class_type_is(class_id,
+ BT_FIELD_CLASS_TYPE_REAL)) {
double v;
if (class_id == BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL) {
double v;
if (class_id == BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL) {
- v =
(float)
bt_field_real_single_precision_get_value(field);
+ v = bt_field_real_single_precision_get_value(field);
} else {
v = bt_field_real_double_precision_get_value(field);
}
} else {
v = bt_field_real_double_precision_get_value(field);
}
@@
-1035,12
+1033,7
@@
int print_field(struct pretty_component *pretty,
bt_common_g_string_append(pretty->string, COLOR_RST);
}
return 0;
bt_common_g_string_append(pretty->string, COLOR_RST);
}
return 0;
- }
- case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
- case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
- return print_enum(pretty, field);
- case BT_FIELD_CLASS_TYPE_STRING:
- {
+ } else if (class_id == BT_FIELD_CLASS_TYPE_STRING) {
const char *str;
str = bt_field_string_get_value(field);
const char *str;
str = bt_field_string_get_value(field);
@@
-1056,23
+1049,20
@@
int print_field(struct pretty_component *pretty,
bt_common_g_string_append(pretty->string, COLOR_RST);
}
return 0;
bt_common_g_string_append(pretty->string, COLOR_RST);
}
return 0;
- }
- case BT_FIELD_CLASS_TYPE_STRUCTURE:
+ } else if (class_id == BT_FIELD_CLASS_TYPE_STRUCTURE) {
return print_struct(pretty, field, print_names);
return print_struct(pretty, field, print_names);
- case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
- case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR:
- case BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR:
- case BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR:
+ } else if (bt_field_class_type_is(class_id,
+ BT_FIELD_CLASS_TYPE_OPTION)) {
return print_option(pretty, field, print_names);
return print_option(pretty, field, print_names);
- case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
- case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
- case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
+ } else if (bt_field_class_type_is(class_id,
+ BT_FIELD_CLASS_TYPE_VARIANT)) {
return print_variant(pretty, field, print_names);
return print_variant(pretty, field, print_names);
- case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
+ } else if (class_id == BT_FIELD_CLASS_TYPE_STATIC_ARRAY) {
return print_array(pretty, field, print_names);
return print_array(pretty, field, print_names);
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ } else if (bt_field_class_type_is(class_id,
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY)) {
return print_sequence(pretty, field, print_names);
return print_sequence(pretty, field, print_names);
- default:
+ } else {
// TODO: log instead
fprintf(pretty->err, "[error] Unknown type id: %d\n", (int) class_id);
return -1;
// TODO: log instead
fprintf(pretty->err, "[error] Unknown type id: %d\n", (int) class_id);
return -1;
@@
-1209,7
+1199,7
@@
int pretty_print_event(struct pretty_component *pretty,
const bt_event *event =
bt_message_event_borrow_event_const(event_msg);
const bt_event *event =
bt_message_event_borrow_event_const(event_msg);
- BT_ASSERT(event);
+ BT_ASSERT
_DBG
(event);
pretty->start_line = true;
g_string_assign(pretty->string, "");
ret = print_event_header(pretty, event_msg);
pretty->start_line = true;
g_string_assign(pretty->string, "");
ret = print_event_header(pretty, event_msg);
This page took
0.029088 seconds
and
4
git commands to generate.