.gitignore: add some more IDE / tools related file
[babeltrace.git] / src / plugins / text / details / write.c
index 6d555a5f1b488c50bcdcdc9cf15fbe1c1e69555e..5c9f9e75591a6039a8ccd438ecf674aea8806004 100644 (file)
@@ -1,23 +1,7 @@
 /*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * SPDX-License-Identifier: MIT
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
  */
 
 #include <babeltrace2/babeltrace.h>
@@ -105,7 +89,10 @@ void format_uint(char *buf, uint64_t value, unsigned int base)
                bt_common_abort();
        }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
        sprintf(buf_start, spec, value);
+#pragma GCC diagnostic pop
 
        if (sep_digits) {
                bt_common_sep_digits(buf_start, digits_per_group, sep);
@@ -158,7 +145,10 @@ void format_int(char *buf, int64_t value, unsigned int base)
                bt_common_abort();
        }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
        sprintf(buf_start, spec, abs_value);
+#pragma GCC diagnostic pop
 
        if (sep_digits) {
                bt_common_sep_digits(buf_start, digits_per_group, sep);
@@ -371,7 +361,9 @@ gint compare_strings(const char **a, const char **b)
 
 static
 bt_value_map_foreach_entry_const_func_status map_value_foreach_add_key_to_array(
-               const char *key, const bt_value *object, void *data)
+               const char *key,
+               const bt_value *object __attribute__((unused)),
+               void *data)
 {
        GPtrArray *keys = data;
 
@@ -421,8 +413,11 @@ void write_value(struct details_write_ctx *ctx, const bt_value *value,
                write_float_prop_value(ctx, bt_value_real_get(value));
                break;
        case BT_VALUE_TYPE_STRING:
-               write_sp(ctx);
-               write_str_prop_value(ctx, bt_value_string_get(value));
+               if (strlen(bt_value_string_get(value)) > 0) {
+                       write_sp(ctx);
+                       write_str_prop_value(ctx, bt_value_string_get(value));
+               }
+
                break;
        case BT_VALUE_TYPE_ARRAY:
        {
@@ -670,7 +665,7 @@ void destroy_enum_field_class_mapping(struct enum_field_class_mapping *mapping)
 static
 struct int_range *int_range_at(GArray *ranges, uint64_t index)
 {
-       return &g_array_index(ranges, struct int_range, index);
+       return &bt_g_array_index(ranges, struct int_range, index);
 }
 
 static
@@ -682,7 +677,7 @@ void write_int_range(struct details_write_ctx *ctx,
        if (is_signed) {
                write_int_prop_value(ctx, range->lower.i);
        } else {
-               write_int_prop_value(ctx, range->lower.u);
+               write_uint_prop_value(ctx, range->lower.u);
        }
 
        if (range->lower.u != range->upper.u) {
@@ -691,7 +686,7 @@ void write_int_range(struct details_write_ctx *ctx,
                if (is_signed) {
                        write_int_prop_value(ctx, range->upper.i);
                } else {
-                       write_int_prop_value(ctx, range->upper.u);
+                       write_uint_prop_value(ctx, range->upper.u);
                }
        }
 
@@ -2130,16 +2125,19 @@ void write_trace(struct details_write_ctx *ctx, const bt_trace *trace)
 
                        BT_ASSERT_DBG(value);
                        write_compound_member_name(ctx, name);
-                       write_sp(ctx);
 
                        if (bt_value_get_type(value) ==
                                        BT_VALUE_TYPE_SIGNED_INTEGER) {
+                               write_sp(ctx);
                                write_int_prop_value(ctx,
                                        bt_value_integer_signed_get(value));
                        } else if (bt_value_get_type(value) ==
                                        BT_VALUE_TYPE_STRING) {
-                               write_str_prop_value(ctx,
-                                       bt_value_string_get(value));
+                               if (strlen(bt_value_string_get(value)) > 0) {
+                                       write_sp(ctx);
+                                       write_str_prop_value(ctx,
+                                               bt_value_string_get(value));
+                               }
                        } else {
                                bt_common_abort();
                        }
@@ -2540,7 +2538,6 @@ end:
        return ret;
 }
 
-BT_HIDDEN
 int details_write_message(struct details_comp *details_comp,
                const bt_message *msg)
 {
This page took 0.029828 seconds and 4 git commands to generate.