From: Mathieu Desnoyers Date: Thu, 21 Sep 2023 05:56:03 +0000 (+0100) Subject: Convert side_type_raw_string pointer to side_ptr X-Git-Url: http://git.efficios.com/?p=libside.git;a=commitdiff_plain;h=3db2d8a1ed6d924d3a16d67330530c15eaa3073b Convert side_type_raw_string pointer to side_ptr Signed-off-by: Mathieu Desnoyers --- diff --git a/include/side/trace.h b/include/side/trace.h index 8e0604d..d63a95e 100644 --- a/include/side/trace.h +++ b/include/side/trace.h @@ -260,7 +260,7 @@ union side_float_value { } SIDE_PACKED; struct side_type_raw_string { - const void *p; /* pointer to string */ + side_ptr_t(const void) p; /* pointer to string */ uint8_t unit_size; /* 1, 2, or 4 bytes */ uint8_t byte_order; /* enum side_type_label_byte_order */ } SIDE_PACKED; @@ -678,7 +678,9 @@ struct side_event_description { #define side_attr(_key, _value) \ { \ .key = { \ - .p = (_key), \ + .p = { \ + .v = (uintptr_t) (_key), \ + }, \ .unit_size = sizeof(uint8_t), \ .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ }, \ @@ -708,7 +710,9 @@ struct side_event_description { .type = SIDE_ATTR_TYPE_STRING, \ .u = { \ .string_value = { \ - .p = (const void *) (_val), \ + .p = { \ + .v = (uintptr_t) (_val), \ + }, \ .unit_size = _unit_size, \ .byte_order = _byte_order, \ }, \ @@ -737,7 +741,9 @@ struct side_event_description { .range_begin = _begin, \ .range_end = _end, \ .label = { \ - .p = (_label), \ + .p = { \ + .v = (uintptr_t) (_label), \ + }, \ .unit_size = sizeof(uint8_t), \ .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ }, \ @@ -748,7 +754,9 @@ struct side_event_description { .range_begin = _value, \ .range_end = _value, \ .label = { \ - .p = (_label), \ + .p = { \ + .v = (uintptr_t) (_label), \ + }, \ .unit_size = sizeof(uint8_t), \ .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ }, \ @@ -770,7 +778,9 @@ struct side_event_description { .range_begin = _begin, \ .range_end = _end, \ .label = { \ - .p = (_label), \ + .p = { \ + .v = (uintptr_t) (_label), \ + }, \ .unit_size = sizeof(uint8_t), \ .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ }, \ @@ -781,7 +791,9 @@ struct side_event_description { .range_begin = _value, \ .range_end = _value, \ .label = { \ - .p = (_label), \ + .p = { \ + .v = (uintptr_t) (_label), \ + }, \ .unit_size = sizeof(uint8_t), \ .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ }, \ diff --git a/src/tracer.c b/src/tracer.c index a0567cb..dac7464 100644 --- a/src/tracer.c +++ b/src/tracer.c @@ -229,10 +229,10 @@ enum tracer_display_base get_attr_display_base(const struct side_attr *_attr, ui char *utf8_str = NULL; bool cmp; - tracer_convert_string_to_utf8(attr->key.p, attr->key.unit_size, + tracer_convert_string_to_utf8(side_ptr_get(attr->key.p), attr->key.unit_size, attr->key.byte_order, NULL, &utf8_str); cmp = strcmp(utf8_str, "std.integer.base"); - if (utf8_str != attr->key.p) + if (utf8_str != side_ptr_get(attr->key.p)) free(utf8_str); if (!cmp) { int64_t val = get_attr_integer_value(attr); @@ -260,10 +260,10 @@ void tracer_print_attr_type(const char *separator, const struct side_attr *attr) { char *utf8_str = NULL; - tracer_convert_string_to_utf8(attr->key.p, attr->key.unit_size, + tracer_convert_string_to_utf8(side_ptr_get(attr->key.p), attr->key.unit_size, attr->key.byte_order, NULL, &utf8_str); printf("{ key%s \"%s\", value%s ", separator, utf8_str, separator); - if (utf8_str != attr->key.p) + if (utf8_str != side_ptr_get(attr->key.p)) free(utf8_str); switch (attr->value.type) { case SIDE_ATTR_TYPE_BOOL: @@ -326,7 +326,7 @@ void tracer_print_attr_type(const char *separator, const struct side_attr *attr) abort(); #endif case SIDE_ATTR_TYPE_STRING: - tracer_print_string(attr->value.u.string_value.p, + tracer_print_string(side_ptr_get(attr->value.u.string_value.p), attr->value.u.string_value.unit_size, attr->value.u.string_value.byte_order, NULL); break; @@ -460,7 +460,7 @@ void print_enum_labels(const struct side_enum_mappings *mappings, union int64_va } if (v64.s >= mapping->range_begin && v64.s <= mapping->range_end) { printf("%s", print_count++ ? ", " : ""); - tracer_print_string(mapping->label.p, mapping->label.unit_size, mapping->label.byte_order, NULL); + tracer_print_string(side_ptr_get(mapping->label.p), mapping->label.unit_size, mapping->label.byte_order, NULL); } } if (!print_count) @@ -589,7 +589,7 @@ void tracer_print_enum_bitmap(const struct side_type *type_desc, match: if (match) { printf("%s", print_count++ ? ", " : ""); - tracer_print_string(mapping->label.p, mapping->label.unit_size, mapping->label.byte_order, NULL); + tracer_print_string(side_ptr_get(mapping->label.p), mapping->label.unit_size, mapping->label.byte_order, NULL); } } if (!print_count)