Move to kernel style SPDX license identifiers
[babeltrace.git] / src / lib / lib-logging.c
index 710aab62f780fbe1c367eb10b635faf2c460fb6f..88be5c769e6ac2b59fb953aa262bc2c5b508adfe 100644 (file)
@@ -1,23 +1,7 @@
 /*
- * Copyright 2018 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 2018 Philippe Proulx <pproulx@efficios.com>
  */
 
 #define BT_LOG_TAG "LIB/LIB-LOGGING"
@@ -28,6 +12,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <inttypes.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <wchar.h>
 #include <glib.h>
@@ -110,7 +95,7 @@ static __thread char lib_logging_buf[LIB_LOGGING_BUF_SIZE];
                                prefix, (_prefix2));                    \
                                                                        \
                if (snprintf_ret < 0 || snprintf_ret >= TMP_PREFIX_LEN - 1) { \
-                       abort();                                        \
+                       bt_common_abort();                                      \
                }                                                       \
                                                                        \
                tmp_prefix[TMP_PREFIX_LEN - 1] = '\0';                  \
@@ -489,7 +474,7 @@ static inline void format_field_path(char **buf_ch, bool extended,
                        BUF_APPEND("%s", ", <CUR>");
                        break;
                default:
-                       abort();
+                       bt_common_abort();
                }
        }
 
@@ -909,9 +894,8 @@ static inline void format_value(char **buf_ch, bool extended,
        }
        case BT_VALUE_TYPE_ARRAY:
        {
-               int64_t count = bt_value_array_get_length(value);
+               uint64_t count = bt_value_array_get_length(value);
 
-               BT_ASSERT(count >= 0);
                BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count));
                break;
        }
@@ -1198,12 +1182,19 @@ static inline void format_graph(char **buf_ch, bool extended,
                &graph->packet_end_msg_pool);
 }
 
+static inline void format_message_iterator_class(char **buf_ch,
+               bool extended, const char *prefix,
+               const struct bt_message_iterator_class *iterator_class)
+{
+       /* Empty, the address is automatically printed. */
+}
+
 static inline void format_message_iterator(char **buf_ch,
                bool extended, const char *prefix,
                const struct bt_message_iterator *iterator)
 {
        char tmp_prefix[TMP_PREFIX_LEN];
-       const struct bt_self_component_port_input_message_iterator *
+       const struct bt_message_iterator *
                port_in_iter = (const void *) iterator;
 
        if (port_in_iter->upstream_component) {
@@ -1447,6 +1438,9 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
        case 'n':
                format_message(buf_ch, extended, prefix, obj);
                break;
+       case 'I':
+               format_message_iterator_class(buf_ch, extended, prefix, obj);
+               break;
        case 'i':
                format_message_iterator(buf_ch, extended, prefix, obj);
                break;
@@ -1481,7 +1475,7 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
                format_error_cause(buf_ch, extended, prefix, obj);
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
 update_fmt:
@@ -1522,7 +1516,8 @@ void bt_lib_maybe_log_and_append_cause(const char *func, const char *file,
        }
 
        status = bt_current_thread_error_append_cause_from_unknown(
-               "Babeltrace library", file, line, "%s", lib_logging_buf);
+               BT_LIB_LOG_LIBBABELTRACE2_NAME, file, line, "%s",
+               lib_logging_buf);
        if (status) {
                /*
                 * Worst case: this error cause is not appended to the
This page took 0.025047 seconds and 4 git commands to generate.