ogs_core_initialize:
   40|      1|{
   41|      1|    ogs_mem_init();
   42|      1|    ogs_log_init();
   43|      1|    ogs_pkbuf_init();
   44|      1|    ogs_socket_init();
   45|      1|    ogs_tlv_init();
   46|       |
   47|      1|    ogs_log_install_domain(&__ogs_mem_domain, "mem", ogs_core()->log.level);
   48|      1|    ogs_log_install_domain(&__ogs_sock_domain, "sock", ogs_core()->log.level);
   49|      1|    ogs_log_install_domain(&__ogs_event_domain, "event", ogs_core()->log.level);
   50|      1|    ogs_log_install_domain(&__ogs_thread_domain,
   51|      1|            "thread", ogs_core()->log.level);
   52|      1|    ogs_log_install_domain(&__ogs_tlv_domain, "tlv", ogs_core()->log.level);
   53|      1|}
ogs_core:
   65|    605|{
   66|    605|    return &self;
   67|    605|}

ogs_hash_make:
   70|      3|{
   71|      3|    ogs_hash_t *ht;
   72|      3|    ogs_time_t now = ogs_get_monotonic_time();
   73|       |
   74|      3|    ht = ogs_malloc(sizeof(ogs_hash_t));
  ------------------
  |  |   68|      3|    ogs_talloc_size(__ogs_talloc_core, size, __location__)
  ------------------
   75|      3|    if (!ht) {
  ------------------
  |  Branch (75:9): [True: 0, False: 3]
  ------------------
   76|      0|        ogs_error("ogs_malloc() failed");
  ------------------
  |  |   36|      0|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  ------------------
  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
   77|      0|        return NULL;
   78|      0|    }
   79|       |
   80|      3|    ht->free = NULL;
   81|      3|    ht->count = 0;
   82|      3|    ht->max = INITIAL_MAX;
  ------------------
  |  |   60|      3|#define INITIAL_MAX 15 /* tunable == 2^n - 1 */
  ------------------
   83|      3|    ht->seed = (unsigned int)((now >> 32) ^ now ^ 
   84|      3|                              (uintptr_t)ht ^ (uintptr_t)&now) - 1;
   85|      3|    ht->array = alloc_array(ht, ht->max);
   86|      3|    ht->hash_func = NULL;
   87|       |
   88|      3|    return ht;
   89|      3|}
ogs-hash.c:alloc_array:
   63|      3|{
   64|      3|    ogs_hash_entry_t **ptr = ogs_calloc(1, sizeof(*ht->array) * (max + 1));
  ------------------
  |  |   70|      3|    ogs_talloc_zero_size(__ogs_talloc_core, (nmemb) * (size), __location__)
  ------------------
   65|      3|    ogs_assert(ptr);
  ------------------
  |  |  113|      3|    do { \
  |  |  114|      3|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|      3|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  115|      3|        else { \
  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|            ogs_abort(); \
  |  |  118|      0|        } \
  |  |  119|      3|    } while(0)
  |  |  ------------------
  |  |  |  Branch (119:13): [Folded, False: 3]
  |  |  ------------------
  ------------------
   66|      3|    return ptr;
   67|      3|}

ogs-log.c:ogs_list_first:
   51|    292|{
   52|    292|    return list->next;
   53|    292|}
ogs-log.c:ogs_list_next:
   61|     21|{
   62|     21|    ogs_list_t *node = (ogs_list_t *)lnode;
   63|     21|    return node->next;
   64|     21|}
ogs-log.c:ogs_list_add:
  115|      8|{
  116|      8|    ogs_list_t *node = (ogs_list_t *)lnode;
  117|       |
  118|      8|    node->prev = list->prev;
  119|      8|    node->next = NULL;
  120|      8|    if (list->prev)
  ------------------
  |  Branch (120:9): [True: 6, False: 2]
  ------------------
  121|      6|        list->prev->next = node;
  122|      2|    else
  123|      2|        list->next = node;
  124|      8|    list->prev = node;
  125|      8|}

ogs_log_init:
  115|      1|{
  116|      1|    ogs_pool_init(&log_pool, ogs_core()->log.pool);
  ------------------
  |  |   52|      1|#define ogs_pool_init(pool, _size) do { \
  |  |   53|      1|    int i; \
  |  |   54|      1|    (pool)->name = #pool; \
  |  |   55|      1|    (pool)->free = malloc(sizeof(*(pool)->free) * _size); \
  |  |   56|      1|    ogs_assert((pool)->free); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|      1|    (pool)->array = malloc(sizeof(*(pool)->array) * _size); \
  |  |   58|      1|    ogs_assert((pool)->array); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   59|      1|    (pool)->index = malloc(sizeof(*(pool)->index) * _size); \
  |  |   60|      1|    ogs_assert((pool)->index); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   61|      1|    (pool)->size = (pool)->avail = _size; \
  |  |   62|      1|    (pool)->head = (pool)->tail = 0; \
  |  |   63|      9|    for (i = 0; i < _size; i++) { \
  |  |  ------------------
  |  |  |  Branch (63:17): [True: 8, False: 1]
  |  |  ------------------
  |  |   64|      8|        (pool)->free[i] = &((pool)->array[i]); \
  |  |   65|      8|        (pool)->index[i] = NULL; \
  |  |   66|      8|    } \
  |  |   67|      1|    \
  |  |   68|      1|    (pool)->id_hash = ogs_hash_make(); \
  |  |   69|      1|    ogs_assert((pool)->id_hash); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   70|      1|} while (0)
  |  |  ------------------
  |  |  |  Branch (70:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  117|      1|    ogs_pool_init(&domain_pool, ogs_core()->log.domain_pool);
  ------------------
  |  |   52|      1|#define ogs_pool_init(pool, _size) do { \
  |  |   53|      1|    int i; \
  |  |   54|      1|    (pool)->name = #pool; \
  |  |   55|      1|    (pool)->free = malloc(sizeof(*(pool)->free) * _size); \
  |  |   56|      1|    ogs_assert((pool)->free); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|      1|    (pool)->array = malloc(sizeof(*(pool)->array) * _size); \
  |  |   58|      1|    ogs_assert((pool)->array); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   59|      1|    (pool)->index = malloc(sizeof(*(pool)->index) * _size); \
  |  |   60|      1|    ogs_assert((pool)->index); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   61|      1|    (pool)->size = (pool)->avail = _size; \
  |  |   62|      1|    (pool)->head = (pool)->tail = 0; \
  |  |   63|     65|    for (i = 0; i < _size; i++) { \
  |  |  ------------------
  |  |  |  Branch (63:17): [True: 64, False: 1]
  |  |  ------------------
  |  |   64|     64|        (pool)->free[i] = &((pool)->array[i]); \
  |  |   65|     64|        (pool)->index[i] = NULL; \
  |  |   66|     64|    } \
  |  |   67|      1|    \
  |  |   68|      1|    (pool)->id_hash = ogs_hash_make(); \
  |  |   69|      1|    ogs_assert((pool)->id_hash); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   70|      1|} while (0)
  |  |  ------------------
  |  |  |  Branch (70:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  118|       |
  119|      1|    ogs_log_add_domain("core", ogs_core()->log.level);
  120|      1|    ogs_log_add_stderr();
  121|      1|}
ogs_log_add_stderr:
  152|      1|{
  153|      1|    ogs_log_t *log = NULL;
  154|       |    
  155|      1|    log = add_log(OGS_LOG_STDERR_TYPE);
  156|      1|    ogs_assert(log);
  ------------------
  |  |  113|      1|    do { \
  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  115|      1|        else { \
  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|            ogs_abort(); \
  |  |  118|      0|        } \
  |  |  119|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  ------------------
  ------------------
  157|       |
  158|      1|    log->file.out = stderr;
  159|      1|    log->writer = file_writer;
  160|       |
  161|      1|#if !defined(_WIN32)
  162|      1|    log->print.color = 1;
  163|      1|#endif
  164|       |
  165|      1|    return log;
  166|      1|}
ogs_log_add_domain:
  204|      7|{
  205|      7|    ogs_log_domain_t *domain = NULL;
  206|       |
  207|      7|    ogs_assert(name);
  ------------------
  |  |  113|      7|    do { \
  |  |  114|      7|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|      7|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  115|      7|        else { \
  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|            ogs_abort(); \
  |  |  118|      0|        } \
  |  |  119|      7|    } while(0)
  |  |  ------------------
  |  |  |  Branch (119:13): [Folded, False: 7]
  |  |  ------------------
  ------------------
  208|       |
  209|      7|    ogs_pool_alloc(&domain_pool, &domain);
  ------------------
  |  |  132|      7|#define ogs_pool_alloc(pool, node) do { \
  |  |  133|      7|    *(node) = NULL; \
  |  |  134|      7|    if ((pool)->avail > 0) { \
  |  |  ------------------
  |  |  |  Branch (134:9): [True: 7, False: 0]
  |  |  ------------------
  |  |  135|      7|        (pool)->avail--; \
  |  |  136|      7|        *(node) = (void*)(pool)->free[(pool)->head]; \
  |  |  137|      7|        (pool)->free[(pool)->head] = NULL; \
  |  |  138|      7|        (pool)->head = ((pool)->head + 1) % ((pool)->size); \
  |  |  139|      7|        (pool)->index[ogs_pool_index(pool, *(node))-1] = *(node); \
  |  |  ------------------
  |  |  |  |  152|      7|#define ogs_pool_index(pool, node) (((node) - (pool)->array)+1)
  |  |  ------------------
  |  |  140|      7|    } \
  |  |  141|      7|} while (0)
  |  |  ------------------
  |  |  |  Branch (141:10): [Folded, False: 7]
  |  |  ------------------
  ------------------
  210|      7|    ogs_assert(domain);
  ------------------
  |  |  113|      7|    do { \
  |  |  114|      7|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|      7|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  115|      7|        else { \
  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|            ogs_abort(); \
  |  |  118|      0|        } \
  |  |  119|      7|    } while(0)
  |  |  ------------------
  |  |  |  Branch (119:13): [Folded, False: 7]
  |  |  ------------------
  ------------------
  211|       |
  212|      7|    domain->name = name;
  213|      7|    domain->id = ogs_pool_index(&domain_pool, domain);
  ------------------
  |  |  152|      7|#define ogs_pool_index(pool, node) (((node) - (pool)->array)+1)
  ------------------
  214|      7|    domain->level = level;
  215|       |
  216|      7|    ogs_list_add(&domain_list, domain);
  217|       |
  218|      7|    return domain;
  219|      7|}
ogs_log_find_domain:
  222|      6|{
  223|      6|    ogs_log_domain_t *domain = NULL;
  224|       |
  225|      6|    ogs_assert(name);
  ------------------
  |  |  113|      6|    do { \
  |  |  114|      6|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|      6|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  115|      6|        else { \
  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|            ogs_abort(); \
  |  |  118|      0|        } \
  |  |  119|      6|    } while(0)
  |  |  ------------------
  |  |  |  Branch (119:13): [Folded, False: 6]
  |  |  ------------------
  ------------------
  226|       |
  227|      6|    ogs_list_for_each(&domain_list, domain)
  ------------------
  |  |   76|     27|    for (node = ogs_list_first(list); (node); \
  |  |  ------------------
  |  |  |  Branch (76:39): [True: 21, False: 6]
  |  |  ------------------
  |  |   77|     21|        node = ogs_list_next(node))
  ------------------
  228|     21|        if (!ogs_strcasecmp(domain->name, name))
  ------------------
  |  |   63|     21|#define ogs_strcasecmp strcasecmp
  ------------------
  |  Branch (228:13): [True: 0, False: 21]
  ------------------
  229|      0|            return domain;
  230|       |
  231|      6|    return NULL;
  232|      6|}
ogs_log_install_domain:
  292|      6|{
  293|      6|    ogs_log_domain_t *domain = NULL;
  294|       |
  295|      6|    ogs_assert(domain_id);
  ------------------
  |  |  113|      6|    do { \
  |  |  114|      6|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|      6|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  115|      6|        else { \
  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|            ogs_abort(); \
  |  |  118|      0|        } \
  |  |  119|      6|    } while(0)
  |  |  ------------------
  |  |  |  Branch (119:13): [Folded, False: 6]
  |  |  ------------------
  ------------------
  296|      6|    ogs_assert(name);
  ------------------
  |  |  113|      6|    do { \
  |  |  114|      6|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|      6|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  115|      6|        else { \
  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|            ogs_abort(); \
  |  |  118|      0|        } \
  |  |  119|      6|    } while(0)
  |  |  ------------------
  |  |  |  Branch (119:13): [Folded, False: 6]
  |  |  ------------------
  ------------------
  297|       |
  298|      6|    domain = ogs_log_find_domain(name);
  299|      6|    if (domain) {
  ------------------
  |  Branch (299:9): [True: 0, False: 6]
  ------------------
  300|      0|        ogs_warn("`%s` log-domain duplicated", name);
  ------------------
  |  |   37|      0|#define ogs_warn(...) ogs_log_message(OGS_LOG_WARN, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  ------------------
  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
  301|      0|        if (level != domain->level) {
  ------------------
  |  Branch (301:13): [True: 0, False: 0]
  ------------------
  302|      0|            ogs_warn("[%s]->[%s] log-level changed",
  ------------------
  |  |   37|      0|#define ogs_warn(...) ogs_log_message(OGS_LOG_WARN, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  ------------------
  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
  303|      0|                    level_strings[domain->level], level_strings[level]);
  304|      0|            ogs_log_set_domain_level(domain->id, level);
  305|      0|        }
  306|      6|    } else {
  307|      6|        domain = ogs_log_add_domain(name, level);
  308|      6|        ogs_assert(domain);
  ------------------
  |  |  113|      6|    do { \
  |  |  114|      6|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|      6|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  115|      6|        else { \
  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|            ogs_abort(); \
  |  |  118|      0|        } \
  |  |  119|      6|    } while(0)
  |  |  ------------------
  |  |  |  Branch (119:13): [Folded, False: 6]
  |  |  ------------------
  ------------------
  309|      6|    }
  310|       |
  311|      6|    *domain_id = domain->id;
  312|      6|}
ogs_log_vprintf:
  404|    286|{
  405|    286|    ogs_log_t *log = NULL;
  406|    286|    ogs_log_domain_t *domain = NULL;
  407|       |
  408|    286|    char logstr[OGS_HUGE_LEN];
  409|    286|    char *p, *last;
  410|       |
  411|    286|    int wrote_stderr = 0;
  412|       |
  413|    286|    ogs_list_for_each(&log_list, log) {
  ------------------
  |  |   76|    286|    for (node = ogs_list_first(list); (node); \
  |  |  ------------------
  |  |  |  Branch (76:39): [True: 286, False: 0]
  |  |  ------------------
  |  |   77|    286|        node = ogs_list_next(node))
  ------------------
  414|    286|        domain = ogs_pool_find(&domain_pool, id);
  ------------------
  |  |  154|    286|    (_index > 0 && _index <= (pool)->size) ? (pool)->index[_index-1] : NULL
  |  |  ------------------
  |  |  |  Branch (154:6): [True: 286, False: 0]
  |  |  |  Branch (154:20): [True: 286, False: 0]
  |  |  ------------------
  ------------------
  415|    286|        if (!domain) {
  ------------------
  |  Branch (415:13): [True: 0, False: 286]
  ------------------
  416|      0|            fprintf(stderr, "No LogDomain[id:%d] in %s:%d", id, file, line);
  417|      0|            ogs_assert_if_reached();
  ------------------
  |  |  122|      0|    do { \
  |  |  123|      0|        ogs_fatal("%s: should not be reached.", OGS_FUNC); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|      0|        ogs_abort(); \
  |  |  125|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  418|      0|        }
  419|    286|        if (domain->level < level)
  ------------------
  |  Branch (419:13): [True: 286, False: 0]
  ------------------
  420|    286|            return;
  421|       |
  422|      0|        p = logstr;
  423|      0|        last = logstr + OGS_HUGE_LEN;
  ------------------
  |  |  210|      0|#define OGS_HUGE_LEN                    8192  /* Can Stack */
  ------------------
  424|       |
  425|      0|        if (!content_only) {
  ------------------
  |  Branch (425:13): [True: 0, False: 0]
  ------------------
  426|      0|            if (log->print.timestamp)
  ------------------
  |  Branch (426:17): [True: 0, False: 0]
  ------------------
  427|      0|                p = log_timestamp(p, last, log->print.color);
  428|      0|            if (log->print.domain)
  ------------------
  |  Branch (428:17): [True: 0, False: 0]
  ------------------
  429|      0|                p = log_domain(p, last, domain->name, log->print.color);
  430|      0|            if (log->print.level)
  ------------------
  |  Branch (430:17): [True: 0, False: 0]
  ------------------
  431|      0|                p = log_level(p, last, level, log->print.color);
  432|      0|        }
  433|       |
  434|      0|        p = log_content(p, last, format, ap);
  435|       |
  436|      0|        if (err) {
  ------------------
  |  Branch (436:13): [True: 0, False: 0]
  ------------------
  437|      0|            char errbuf[OGS_HUGE_LEN];
  438|      0|            p = ogs_slprintf(p, last, " (%d:%s)",
  439|      0|                    (int)err, ogs_strerror(err, errbuf, OGS_HUGE_LEN));
  ------------------
  |  |  210|      0|#define OGS_HUGE_LEN                    8192  /* Can Stack */
  ------------------
  440|      0|        }
  441|       |
  442|      0|        if (!content_only) {
  ------------------
  |  Branch (442:13): [True: 0, False: 0]
  ------------------
  443|      0|            if (log->print.fileline)
  ------------------
  |  Branch (443:17): [True: 0, False: 0]
  ------------------
  444|      0|                p = ogs_slprintf(p, last, " (%s:%d)", file, line);
  445|      0|            if (log->print.function)
  ------------------
  |  Branch (445:17): [True: 0, False: 0]
  ------------------
  446|      0|                p = ogs_slprintf(p, last, " %s()", func);
  447|      0|            if (log->print.linefeed) 
  ------------------
  |  Branch (447:17): [True: 0, False: 0]
  ------------------
  448|      0|                p = log_linefeed(p, last);
  449|      0|        }
  450|       |
  451|      0|        log->writer(log, level, logstr);
  452|       |        
  453|      0|        if (log->type == OGS_LOG_STDERR_TYPE)
  ------------------
  |  Branch (453:13): [True: 0, False: 0]
  ------------------
  454|      0|            wrote_stderr = 1;
  455|      0|    }
  456|       |
  457|      0|    if (!wrote_stderr)
  ------------------
  |  Branch (457:9): [True: 0, False: 0]
  ------------------
  458|      0|    {
  459|      0|        int use_color = 0;
  460|      0|#if !defined(_WIN32)
  461|      0|        use_color = 1;
  462|      0|#endif
  463|       |
  464|      0|        p = logstr;
  465|      0|        last = logstr + OGS_HUGE_LEN;
  ------------------
  |  |  210|      0|#define OGS_HUGE_LEN                    8192  /* Can Stack */
  ------------------
  466|       |
  467|      0|        if (!content_only) {
  ------------------
  |  Branch (467:13): [True: 0, False: 0]
  ------------------
  468|      0|            p = log_timestamp(p, last, use_color);
  469|      0|            p = log_level(p, last, level, use_color);
  470|      0|        }
  471|      0|        p = log_content(p, last, format, ap);
  472|      0|        if (!content_only) {
  ------------------
  |  Branch (472:13): [True: 0, False: 0]
  ------------------
  473|      0|            p = ogs_slprintf(p, last, " (%s:%d)", file, line);
  474|      0|            p = ogs_slprintf(p, last, " %s()", func);
  475|      0|            p = log_linefeed(p, last);
  476|      0|        }
  477|       |
  478|      0|        fprintf(stderr, "%s", logstr);
  479|       |        fflush(stderr);
  480|      0|    }
  481|      0|}
ogs_log_printf:
  486|    286|{
  487|    286|    va_list args;
  488|       |
  489|    286|    va_start(args, format);
  490|    286|    ogs_log_vprintf(level, id,
  491|    286|            err, file, line, func, content_only, format, args);
  492|       |    va_end(args);
  493|    286|}
ogs-log.c:add_log:
  536|      1|{
  537|      1|    ogs_log_t *log = NULL;
  538|       |
  539|      1|    ogs_pool_alloc(&log_pool, &log);
  ------------------
  |  |  132|      1|#define ogs_pool_alloc(pool, node) do { \
  |  |  133|      1|    *(node) = NULL; \
  |  |  134|      1|    if ((pool)->avail > 0) { \
  |  |  ------------------
  |  |  |  Branch (134:9): [True: 1, False: 0]
  |  |  ------------------
  |  |  135|      1|        (pool)->avail--; \
  |  |  136|      1|        *(node) = (void*)(pool)->free[(pool)->head]; \
  |  |  137|      1|        (pool)->free[(pool)->head] = NULL; \
  |  |  138|      1|        (pool)->head = ((pool)->head + 1) % ((pool)->size); \
  |  |  139|      1|        (pool)->index[ogs_pool_index(pool, *(node))-1] = *(node); \
  |  |  ------------------
  |  |  |  |  152|      1|#define ogs_pool_index(pool, node) (((node) - (pool)->array)+1)
  |  |  ------------------
  |  |  140|      1|    } \
  |  |  141|      1|} while (0)
  |  |  ------------------
  |  |  |  Branch (141:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
  540|      1|    ogs_assert(log);
  ------------------
  |  |  113|      1|    do { \
  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  115|      1|        else { \
  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|            ogs_abort(); \
  |  |  118|      0|        } \
  |  |  119|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  ------------------
  ------------------
  541|      1|    memset(log, 0, sizeof *log);
  542|       |
  543|      1|    log->type = type;
  544|       |
  545|      1|    log->print.timestamp = 1;
  546|      1|    log->print.domain = 1;
  547|      1|    log->print.level = 1;
  548|      1|    log->print.fileline = 1;
  549|      1|    log->print.linefeed = 1;
  550|       |
  551|      1|    ogs_list_add(&log_list, log);
  552|       |
  553|      1|    return log;
  554|      1|}

ogs_mem_init:
   34|      1|{
   35|      1|    ogs_thread_mutex_init(&mutex);
  ------------------
  |  |   37|      1|#define ogs_thread_mutex_init(_n) (void)pthread_mutex_init((_n), NULL)
  ------------------
   36|       |
   37|      1|    talloc_enable_null_tracking();
   38|       |
   39|      1|#define TALLOC_MEMSIZE 1
   40|      1|    __ogs_talloc_core = talloc_named_const(NULL, TALLOC_MEMSIZE, "core");
  ------------------
  |  |   39|      1|#define TALLOC_MEMSIZE 1
  ------------------
   41|      1|}
ogs_talloc_size:
   59|      3|{
   60|      3|    void *ptr = NULL;
   61|       |
   62|      3|    ogs_thread_mutex_lock(&mutex);
  ------------------
  |  |   38|      3|#define ogs_thread_mutex_lock (void)pthread_mutex_lock
  ------------------
   63|       |
   64|      3|    ptr = talloc_named_const(ctx, size, name);
   65|      3|    ogs_expect(ptr);
  ------------------
  |  |  128|      3|    do { \
  |  |  129|      3|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|      3|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  130|      3|        else { \
  |  |  131|      0|            ogs_error("%s: Expectation `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   36|      0|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|      0|#define OGS_LOG_DOMAIN __ogs_mem_domain
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  132|      0|        } \
  |  |  133|      3|    } while (0)
  |  |  ------------------
  |  |  |  Branch (133:14): [Folded, False: 3]
  |  |  ------------------
  ------------------
   66|       |
   67|      3|    ogs_thread_mutex_unlock(&mutex);
  ------------------
  |  |   39|      3|#define ogs_thread_mutex_unlock (void)pthread_mutex_unlock
  ------------------
   68|       |
   69|      3|    return ptr;
   70|      3|}
ogs_talloc_zero_size:
   73|    139|{
   74|    139|    void *ptr = NULL;
   75|       |
   76|    139|    ogs_thread_mutex_lock(&mutex);
  ------------------
  |  |   38|    139|#define ogs_thread_mutex_lock (void)pthread_mutex_lock
  ------------------
   77|       |
   78|    139|    ptr = _talloc_zero(ctx, size, name);
   79|    139|    ogs_expect(ptr);
  ------------------
  |  |  128|    139|    do { \
  |  |  129|    139|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|    139|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 139, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  130|    139|        else { \
  |  |  131|      0|            ogs_error("%s: Expectation `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   36|      0|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   23|      0|#define OGS_LOG_DOMAIN __ogs_mem_domain
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  132|      0|        } \
  |  |  133|    139|    } while (0)
  |  |  ------------------
  |  |  |  Branch (133:14): [Folded, False: 139]
  |  |  ------------------
  ------------------
   80|       |
   81|    139|    ogs_thread_mutex_unlock(&mutex);
  ------------------
  |  |   39|    139|#define ogs_thread_mutex_unlock (void)pthread_mutex_unlock
  ------------------
   82|       |
   83|    139|    return ptr;
   84|    139|}
ogs_talloc_free:
  102|    136|{
  103|    136|    int ret;
  104|       |
  105|    136|    ogs_thread_mutex_lock(&mutex);
  ------------------
  |  |   38|    136|#define ogs_thread_mutex_lock (void)pthread_mutex_lock
  ------------------
  106|       |
  107|    136|    ret = _talloc_free(ptr, location);
  108|       |
  109|    136|    ogs_thread_mutex_unlock(&mutex);
  ------------------
  |  |   39|    136|#define ogs_thread_mutex_unlock (void)pthread_mutex_unlock
  ------------------
  110|       |
  111|    136|    return ret;
  112|    136|}

ogs_pkbuf_put_data:
   91|    136|{
   92|    136|    void *tmp = ogs_pkbuf_put(pkbuf, len);
   93|       |
   94|    136|    memcpy(tmp, data, len);
   95|    136|    return tmp;
   96|    136|}
ogs_pkbuf_init:
   99|      1|{
  100|       |#if OGS_USE_TALLOC == 0
  101|       |    ogs_pool_init(&pkbuf_pool, ogs_core()->pkbuf.pool);
  102|       |
  103|       |#endif
  104|      1|}
ogs_pkbuf_default_init:
  114|      1|{
  115|       |#if OGS_USE_TALLOC == 0
  116|       |    ogs_assert(config);
  117|       |    memset(config, 0, sizeof *config);
  118|       |
  119|       |    config->cluster_128_pool = 65536;
  120|       |    config->cluster_256_pool = 16384;
  121|       |    config->cluster_512_pool = 4096;
  122|       |    config->cluster_1024_pool = 2048;
  123|       |    config->cluster_2048_pool = 1024;
  124|       |    config->cluster_8192_pool = 256;
  125|       |    config->cluster_32768_pool = 64;
  126|       |    config->cluster_big_pool = 8;
  127|       |#endif
  128|      1|}
ogs_pkbuf_default_create:
  131|      1|{
  132|       |#if OGS_USE_TALLOC == 0
  133|       |    default_pool = ogs_pkbuf_pool_create(config);
  134|       |#endif
  135|      1|}
ogs_pkbuf_alloc_debug:
  222|    136|{
  223|    136|#if OGS_USE_TALLOC == 1
  224|    136|    ogs_pkbuf_t *pkbuf = NULL;
  225|       |
  226|    136|    pkbuf = ogs_talloc_zero_size(pool, sizeof(*pkbuf) + size, file_line);
  227|    136|    if (!pkbuf) {
  ------------------
  |  Branch (227:9): [True: 0, False: 136]
  ------------------
  228|      0|        ogs_error("ogs_pkbuf_alloc() failed [size=%d]", size);
  ------------------
  |  |   36|      0|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   23|      0|#define OGS_LOG_DOMAIN __ogs_mem_domain
  |  |  |  |  ------------------
  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
  229|      0|        return NULL;
  230|      0|    }
  231|       |
  232|    136|    pkbuf->head = pkbuf->_data;
  233|    136|    pkbuf->end = pkbuf->_data + size;
  234|       |
  235|    136|    pkbuf->len = 0;
  236|       |
  237|    136|    pkbuf->data = pkbuf->_data;
  238|    136|    pkbuf->tail = pkbuf->_data;
  239|       |
  240|    136|    pkbuf->file_line = file_line; /* For debug */
  241|       |
  242|    136|    return pkbuf;
  243|       |#else
  244|       |    ogs_pkbuf_t *pkbuf = NULL;
  245|       |    ogs_cluster_t *cluster = NULL;
  246|       |
  247|       |    if (pool == NULL)
  248|       |        pool = default_pool;
  249|       |    ogs_assert(pool);
  250|       |
  251|       |    ogs_thread_mutex_lock(&pool->mutex);
  252|       |
  253|       |    cluster = cluster_alloc(pool, size);
  254|       |    if (!cluster) {
  255|       |        ogs_error("ogs_pkbuf_alloc() failed [size=%d]", size);
  256|       |        ogs_thread_mutex_unlock(&pool->mutex);
  257|       |        return NULL;
  258|       |    }
  259|       |
  260|       |    ogs_pool_alloc(&pool->pkbuf, &pkbuf);
  261|       |    if (!pkbuf) {
  262|       |        ogs_error("ogs_pkbuf_alloc() failed [size=%d]", size);
  263|       |        ogs_thread_mutex_unlock(&pool->mutex);
  264|       |        return NULL;
  265|       |    }
  266|       |    memset(pkbuf, 0, sizeof(*pkbuf));
  267|       |
  268|       |    OGS_OBJECT_REF(cluster);
  269|       |
  270|       |    pkbuf->cluster = cluster;
  271|       |
  272|       |    pkbuf->len = 0;
  273|       |
  274|       |    pkbuf->data = cluster->buffer;
  275|       |    pkbuf->head = cluster->buffer;
  276|       |    pkbuf->tail = cluster->buffer;
  277|       |    pkbuf->end = cluster->buffer + size;
  278|       |
  279|       |    pkbuf->file_line = file_line; /* For debug */
  280|       |
  281|       |    pkbuf->pool = pool;
  282|       |
  283|       |    ogs_thread_mutex_unlock(&pool->mutex);
  284|       |
  285|       |    return pkbuf;
  286|       |#endif
  287|    136|}
ogs_pkbuf_free:
  290|    136|{
  291|    136|#if OGS_USE_TALLOC == 1
  292|    136|    ogs_talloc_free(pkbuf, OGS_FILE_LINE);
  ------------------
  |  |  213|    136|#define OGS_FILE_LINE __FILE__ ":" OGS_STRINGIFY(__LINE__)
  |  |  ------------------
  |  |  |  |  167|    136|#define OGS_STRINGIFY(n)            OGS_STRINGIFY_HELPER(n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  168|    136|#define OGS_STRINGIFY_HELPER(n)     #n
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  293|       |#else
  294|       |    ogs_pkbuf_pool_t *pool = NULL;
  295|       |    ogs_cluster_t *cluster = NULL;
  296|       |    ogs_assert(pkbuf);
  297|       |
  298|       |    pool = pkbuf->pool;
  299|       |    ogs_assert(pool);
  300|       |
  301|       |    ogs_thread_mutex_lock(&pool->mutex);
  302|       |
  303|       |    cluster = pkbuf->cluster;
  304|       |    ogs_assert(cluster);
  305|       |
  306|       |    if (OGS_OBJECT_IS_REF(cluster))
  307|       |        OGS_OBJECT_UNREF(cluster);
  308|       |    else
  309|       |        cluster_free(pool, pkbuf->cluster);
  310|       |
  311|       |    ogs_pool_free(&pool->pkbuf, pkbuf);
  312|       |
  313|       |    ogs_thread_mutex_unlock(&pool->mutex);
  314|       |#endif
  315|    136|}

ogs-pkbuf.c:ogs_pkbuf_put:
  115|    136|{
  116|    136|    void *tmp = pkbuf->tail;
  117|       |
  118|    136|    if (ogs_unlikely(ogs_pkbuf_tailroom(pkbuf) < (int)len))
  ------------------
  |  |   55|    136|#define ogs_unlikely(x) __builtin_expect (!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (55:25): [True: 0, False: 136]
  |  |  ------------------
  ------------------
  119|      0|        ogs_assert_if_reached();
  ------------------
  |  |  122|      0|    do { \
  |  |  123|      0|        ogs_fatal("%s: should not be reached.", OGS_FUNC); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|#define OGS_LOG_DOMAIN      1
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|      0|        ogs_abort(); \
  |  |  125|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  120|       |
  121|    136|    pkbuf->tail += len;
  122|    136|    pkbuf->len += len;
  123|       |
  124|    136|    return tmp;
  125|    136|}
ogs-pkbuf.c:ogs_pkbuf_tailroom:
   99|    136|{
  100|    136|    return pkbuf->end - pkbuf->tail;
  101|    136|}

ogs_socket_init:
   36|      1|{
   37|       |#if _WIN32
   38|       |    WORD wVersionRequested;
   39|       |    WSADATA wsaData;
   40|       |    int err;
   41|       |
   42|       |    wVersionRequested = MAKEWORD(2, 2);
   43|       |
   44|       |    err = WSAStartup(wVersionRequested, &wsaData);
   45|       |    ogs_assert(err == 0);
   46|       |#endif
   47|      1|}

ogs_get_monotonic_time:
  241|      3|{
  242|      3|#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
  243|      3|    struct timespec ts;
  244|      3|    clock_gettime(CLOCK_MONOTONIC, &ts);
  245|      3|    return ogs_time_from_sec(ts.tv_sec) + ts.tv_nsec / 1000UL;
  ------------------
  |  |   97|      3|#define ogs_time_from_sec(sec) ((ogs_time_t)(sec) * OGS_USEC_PER_SEC)
  |  |  ------------------
  |  |  |  |   76|      3|#define OGS_USEC_PER_SEC (1000000LL)
  |  |  ------------------
  ------------------
  246|       |#elif defined(__APPLE__)
  247|       |    static mach_timebase_info_data_t info = {0};
  248|       |    static double ratio = 0.0;
  249|       |
  250|       |    if (!info.denom) {
  251|       |        /* the value from mach_absolute_time () * info.numer / info.denom
  252|       |        * is in nano seconds. So we have to divid by 1000.0 to get micro
  253|       |        * seconds*/
  254|       |        mach_timebase_info(&info);
  255|       |        ratio = (double) info.numer / (double) info.denom / 1000.0;
  256|       |    }
  257|       |
  258|       |    return mach_absolute_time() * ratio;
  259|       |#elif defined(_WIN32)
  260|       |    /* Despite it's name, this is in milliseconds! */
  261|       |    ogs_time_t ticks = GetTickCount64();
  262|       |    return (ticks * 1000L);
  263|       |#elif defined(__hpux__)
  264|       |    ogs_time_t nanosec = gethrtime();
  265|       |    return (nanosec / 1000UL);
  266|       |#else
  267|       |#warning "Monotonic clock is not yet supported on your platform."
  268|       |    struct timeval tv;
  269|       |
  270|       |    ogs_gettimeofday(&tv);
  271|       |    return ogs_time_from_sec(tv.tv_sec) + tv.tv_usec;
  272|       |#endif
  273|      3|}

ogs_tlv_init:
   54|      1|{
   55|       |    ogs_pool_init(&pool, ogs_core()->tlv.pool);
  ------------------
  |  |   52|      1|#define ogs_pool_init(pool, _size) do { \
  |  |   53|      1|    int i; \
  |  |   54|      1|    (pool)->name = #pool; \
  |  |   55|      1|    (pool)->free = malloc(sizeof(*(pool)->free) * _size); \
  |  |   56|      1|    ogs_assert((pool)->free); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   24|      0|#define OGS_LOG_DOMAIN __ogs_tlv_domain
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|      1|    (pool)->array = malloc(sizeof(*(pool)->array) * _size); \
  |  |   58|      1|    ogs_assert((pool)->array); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   24|      0|#define OGS_LOG_DOMAIN __ogs_tlv_domain
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   59|      1|    (pool)->index = malloc(sizeof(*(pool)->index) * _size); \
  |  |   60|      1|    ogs_assert((pool)->index); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   24|      0|#define OGS_LOG_DOMAIN __ogs_tlv_domain
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   61|      1|    (pool)->size = (pool)->avail = _size; \
  |  |   62|      1|    (pool)->head = (pool)->tail = 0; \
  |  |   63|    513|    for (i = 0; i < _size; i++) { \
  |  |  ------------------
  |  |  |  Branch (63:17): [True: 512, False: 1]
  |  |  ------------------
  |  |   64|    512|        (pool)->free[i] = &((pool)->array[i]); \
  |  |   65|    512|        (pool)->index[i] = NULL; \
  |  |   66|    512|    } \
  |  |   67|      1|    \
  |  |   68|      1|    (pool)->id_hash = ogs_hash_make(); \
  |  |   69|      1|    ogs_assert((pool)->id_hash); \
  |  |  ------------------
  |  |  |  |  113|      1|    do { \
  |  |  |  |  114|      1|        if (ogs_likely(expr)) ; \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      1|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (54:23): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  115|      1|        else { \
  |  |  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   24|      0|#define OGS_LOG_DOMAIN __ogs_tlv_domain
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  117|      0|            ogs_abort(); \
  |  |  |  |  118|      0|        } \
  |  |  |  |  119|      1|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   70|      1|} while (0)
  |  |  ------------------
  |  |  |  Branch (70:10): [Folded, False: 1]
  |  |  ------------------
  ------------------
   56|      1|}

ogs_gtpu_parse_header:
   24|    272|{
   25|    272|    ogs_gtp2_header_t *gtp_h = NULL;
   26|    272|    ogs_gtp2_extension_header_t ext_hdesc;
   27|    272|    uint8_t *ext_h = NULL;
   28|    272|    uint16_t len = 0;
   29|    272|    int i;
   30|       |
   31|    272|    ogs_assert(pkbuf);
  ------------------
  |  |  113|    272|    do { \
  |  |  114|    272|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|    272|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 272, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  115|    272|        else { \
  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   56|      0|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|            ogs_abort(); \
  |  |  118|      0|        } \
  |  |  119|    272|    } while(0)
  |  |  ------------------
  |  |  |  Branch (119:13): [Folded, False: 272]
  |  |  ------------------
  ------------------
   32|    272|    ogs_assert(pkbuf->data);
  ------------------
  |  |  113|    272|    do { \
  |  |  114|    272|        if (ogs_likely(expr)) ; \
  |  |  ------------------
  |  |  |  |   54|    272|#define ogs_likely(x) __builtin_expect (!!(x), 1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (54:23): [True: 272, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  115|    272|        else { \
  |  |  116|      0|            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
  |  |  ------------------
  |  |  |  |   35|      0|#define ogs_fatal(...) ogs_log_message(OGS_LOG_FATAL, 0, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   56|      0|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|            ogs_abort(); \
  |  |  118|      0|        } \
  |  |  119|    272|    } while(0)
  |  |  ------------------
  |  |  |  Branch (119:13): [Folded, False: 272]
  |  |  ------------------
  ------------------
   33|       |
   34|    272|    gtp_h = (ogs_gtp2_header_t *)pkbuf->data;
   35|       |
   36|    272|    if (header_desc) {
  ------------------
  |  Branch (36:9): [True: 136, False: 136]
  ------------------
   37|    136|        memset(header_desc, 0, sizeof(*header_desc));
   38|       |
   39|    136|        header_desc->flags = gtp_h->flags;
   40|    136|        header_desc->type = gtp_h->type;
   41|    136|        header_desc->teid = be32toh(gtp_h->teid);
   42|    136|    }
   43|       |
   44|    272|    len = OGS_GTPV1U_HEADER_LEN;
  ------------------
  |  |   39|    272|#define OGS_GTPV1U_HEADER_LEN   8
  ------------------
   45|    272|    if (pkbuf->len < len) {
  ------------------
  |  Branch (45:9): [True: 0, False: 272]
  ------------------
   46|      0|        ogs_error("the length of the packet is insufficient[%d:%d]",
  ------------------
  |  |   36|      0|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|      0|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|      0|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  ------------------
  |  |  |  |   44|      0|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|      0|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
   47|      0|                pkbuf->len, len);
   48|      0|        return -1;
   49|      0|    }
   50|       |
   51|    272|    if (gtp_h->flags & OGS_GTPU_FLAGS_E) {
  ------------------
  |  |   55|    272|#define OGS_GTPU_FLAGS_E                        0x04
  ------------------
  |  Branch (51:9): [True: 232, False: 40]
  ------------------
   52|       |
   53|    232|        len += OGS_GTPV1U_EXTENSION_HEADER_LEN;
  ------------------
  |  |   52|    232|#define OGS_GTPV1U_EXTENSION_HEADER_LEN 4
  ------------------
   54|    232|        if (pkbuf->len < len) {
  ------------------
  |  Branch (54:13): [True: 6, False: 226]
  ------------------
   55|      6|            ogs_error("the length of the packet is insufficient[%d:%d]",
  ------------------
  |  |   36|      6|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|      6|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|      6|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  ------------------
  |  |  |  |   44|      6|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      6|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|      6|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
   56|      6|                    pkbuf->len, len);
   57|      6|            return -1;
   58|      6|        }
   59|       |
   60|       |        /*
   61|       |         * TS29.281
   62|       |         * 5.2.1 General format of the GTP-U Extension Header
   63|       |         *
   64|       |         * If no such Header follows,
   65|       |         * then the value of the Next Extension Header Type shall be 0. */
   66|       |
   67|    226|        i = 0;
   68|  3.92k|        while (*(ext_h = (((uint8_t *)gtp_h) + len - 1)) &&
  ------------------
  |  Branch (68:16): [True: 3.88k, False: 44]
  ------------------
   69|  3.88k|                i < OGS_GTP2_NUM_OF_EXTENSION_HEADER) {
  ------------------
  |  |   80|  3.88k|#define OGS_GTP2_NUM_OF_EXTENSION_HEADER 8
  ------------------
  |  Branch (69:17): [True: 3.84k, False: 40]
  ------------------
   70|       |        /*
   71|       |         * The length of the Extension header shall be defined
   72|       |         * in a variable length of 4 octets, i.e. m+1 = n*4 octets,
   73|       |         * where n is a positive integer.
   74|       |         */
   75|       |            /* The Extension Header Length octet must be in the packet */
   76|  3.84k|            if (pkbuf->len < len + 1) {
  ------------------
  |  Branch (76:17): [True: 54, False: 3.78k]
  ------------------
   77|     54|                ogs_error("the length of the packet is insufficient[%d:%d]",
  ------------------
  |  |   36|     54|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|     54|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|     54|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  ------------------
  |  |  |  |   44|     54|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     54|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|     54|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
   78|     54|                        pkbuf->len, len + 1);
   79|     54|                return -1;
   80|     54|            }
   81|       |
   82|  3.78k|            len += (*(++ext_h)) * 4;
   83|  3.78k|            if (*ext_h == 0) {
  ------------------
  |  Branch (83:17): [True: 16, False: 3.77k]
  ------------------
   84|     16|                ogs_error("No length in the Extension header");
  ------------------
  |  |   36|     16|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|     16|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|     16|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  ------------------
  |  |  |  |   44|     16|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     16|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|     16|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
   85|     16|                return -1;
   86|     16|            }
   87|       |
   88|  3.77k|            if (((*ext_h) * 4) > OGS_GTP2_MAX_EXTENSION_HEADER_LEN) {
  ------------------
  |  |   78|  3.77k|#define OGS_GTP2_MAX_EXTENSION_HEADER_LEN 4
  ------------------
  |  Branch (88:17): [True: 57, False: 3.71k]
  ------------------
   89|     57|                ogs_error("Overflow length : %d", (*ext_h));
  ------------------
  |  |   36|     57|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|     57|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|     57|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  ------------------
  |  |  |  |   44|     57|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     57|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|     57|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
   90|     57|                return -1;
   91|     57|            }
   92|       |
   93|  3.71k|            if (pkbuf->len < len) {
  ------------------
  |  Branch (93:17): [True: 15, False: 3.69k]
  ------------------
   94|     15|                ogs_error("the length of the packet is insufficient[%d:%d]",
  ------------------
  |  |   36|     15|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|     15|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|     15|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  ------------------
  |  |  |  |   44|     15|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     15|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|     15|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
   95|     15|                        pkbuf->len, len);
   96|     15|                return -1;
   97|     15|            }
   98|       |
   99|  3.69k|            if (!header_desc) /* Skip to extract header content */
  ------------------
  |  Branch (99:17): [True: 3.25k, False: 439]
  ------------------
  100|  3.25k|                continue;
  101|       |
  102|       |            /* Copy Header Content */
  103|    439|            memcpy(&ext_hdesc.array[i], ext_h-1, (*ext_h) * 4);
  104|       |
  105|    439|            switch (ext_hdesc.array[i].type) {
  106|     95|            case OGS_GTP2_EXTENSION_HEADER_TYPE_PDU_SESSION_CONTAINER:
  ------------------
  |  |   55|     95|#define OGS_GTP2_EXTENSION_HEADER_TYPE_PDU_SESSION_CONTAINER 0x85
  ------------------
  |  Branch (106:13): [True: 95, False: 344]
  ------------------
  107|     95|                header_desc->pdu_type = ext_hdesc.array[i].pdu_type;
  108|     95|                if (ext_hdesc.array[i].pdu_type ==
  ------------------
  |  Branch (108:21): [True: 23, False: 72]
  ------------------
  109|     95|                    OGS_GTP2_EXTENSION_HEADER_PDU_TYPE_UL_PDU_SESSION_INFORMATION) {
  ------------------
  |  |   66|     95|#define OGS_GTP2_EXTENSION_HEADER_PDU_TYPE_UL_PDU_SESSION_INFORMATION 1
  ------------------
  110|     23|                        header_desc->qos_flow_identifier =
  111|     23|                            ext_hdesc.array[i].qos_flow_identifier;
  112|     23|                        ogs_trace("   QFI [0x%x]",
  ------------------
  |  |   40|     23|#define ogs_trace(...) ogs_log_message(OGS_LOG_TRACE, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|     23|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|     23|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  ------------------
  |  |  |  |   44|     23|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     23|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|     23|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
  113|     23|                                header_desc->qos_flow_identifier);
  114|     23|                }
  115|     95|                break;
  116|     39|            case OGS_GTP2_EXTENSION_HEADER_TYPE_UDP_PORT:
  ------------------
  |  |   54|     39|#define OGS_GTP2_EXTENSION_HEADER_TYPE_UDP_PORT 0x40
  ------------------
  |  Branch (116:13): [True: 39, False: 400]
  ------------------
  117|     39|                header_desc->udp.presence = true;
  118|     39|                header_desc->udp.port = be16toh(ext_hdesc.array[i].udp_port);
  119|       |
  120|     39|                ogs_trace("   UDP Port [%d]", header_desc->udp.port);
  ------------------
  |  |   40|     39|#define ogs_trace(...) ogs_log_message(OGS_LOG_TRACE, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|     39|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|     39|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  ------------------
  |  |  |  |   44|     39|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     39|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|     39|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
  121|     39|                break;
  122|     27|            case OGS_GTP2_EXTENSION_HEADER_TYPE_PDCP_NUMBER:
  ------------------
  |  |   56|     27|#define OGS_GTP2_EXTENSION_HEADER_TYPE_PDCP_NUMBER 0xc0
  ------------------
  |  Branch (122:13): [True: 27, False: 412]
  ------------------
  123|     27|                header_desc->pdcp_number_presence = true;
  124|     27|                header_desc->pdcp_number =
  125|     27|                    be16toh(ext_hdesc.array[i].pdcp_number);
  126|       |
  127|     27|                ogs_trace("   PDCP Number [%d]", header_desc->pdcp_number);
  ------------------
  |  |   40|     27|#define ogs_trace(...) ogs_log_message(OGS_LOG_TRACE, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|     27|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|     27|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  ------------------
  |  |  |  |   44|     27|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     27|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|     27|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
  128|     27|                break;
  129|    278|            default:
  ------------------
  |  Branch (129:13): [True: 278, False: 161]
  ------------------
  130|    278|                break;
  131|    439|            }
  132|       |
  133|    439|            i++;
  134|    439|        }
  135|       |
  136|     84|        if (i >= OGS_GTP2_NUM_OF_EXTENSION_HEADER) {
  ------------------
  |  |   80|     84|#define OGS_GTP2_NUM_OF_EXTENSION_HEADER 8
  ------------------
  |  Branch (136:13): [True: 41, False: 43]
  ------------------
  137|     41|            ogs_error("The number of extension headers is limited to [%d]", i);
  ------------------
  |  |   36|     41|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|     41|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|     41|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  ------------------
  |  |  |  |   44|     41|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     41|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|     41|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
  138|     41|            return -1;
  139|     41|        }
  140|       |
  141|     84|    } else if (gtp_h->flags & (OGS_GTPU_FLAGS_S|OGS_GTPU_FLAGS_PN)) {
  ------------------
  |  |   56|     40|#define OGS_GTPU_FLAGS_S                        0x02
  ------------------
                  } else if (gtp_h->flags & (OGS_GTPU_FLAGS_S|OGS_GTPU_FLAGS_PN)) {
  ------------------
  |  |   57|     40|#define OGS_GTPU_FLAGS_PN                       0x01
  ------------------
  |  Branch (141:16): [True: 22, False: 18]
  ------------------
  142|       |        /*
  143|       |         * If and only if one or more of these three flags are set,
  144|       |         * the fields Sequence Number, N-PDU and Extension Header
  145|       |         * shall be present. The sender shall set all the bits of
  146|       |         * the unused fields to zero. The receiver shall not evaluate
  147|       |         * the unused fields.
  148|       |         * For example, if only the E flag is set to 1, then
  149|       |         * the N-PDU Number and Sequence Number fields shall also be present,
  150|       |         * but will not have meaningful values and shall not be evaluated.
  151|       |         */
  152|     22|        len += 4;
  153|     22|    }
  154|       |
  155|     83|    if (pkbuf->len < len) {
  ------------------
  |  Branch (155:9): [True: 8, False: 75]
  ------------------
  156|      8|        ogs_error("the length of the packet is insufficient[%d:%d]",
  ------------------
  |  |   36|      8|#define ogs_error(...) ogs_log_message(OGS_LOG_ERROR, 0, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   43|      8|    ogs_log_printf(level, OGS_LOG_DOMAIN, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|      8|#define OGS_LOG_DOMAIN __ogs_gtp_domain
  |  |  |  |  ------------------
  |  |  |  |   44|      8|    err, __FILE__, __LINE__, OGS_FUNC,  \
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      8|#define OGS_FUNC __func__
  |  |  |  |  ------------------
  |  |  |  |   45|      8|    0, __VA_ARGS__) 
  |  |  ------------------
  ------------------
  157|      8|                pkbuf->len, len);
  158|      8|        return -1;
  159|      8|    }
  160|       |
  161|     75|    return len;
  162|     83|}

initialize:
   24|      1|void initialize(void) {
   25|       |
   26|      1|    ogs_pkbuf_config_t config;
   27|       |
   28|      1|    ogs_core_initialize();
   29|       |
   30|      1|    ogs_pkbuf_default_init(&config);
   31|      1|    ogs_pkbuf_default_create(&config);
   32|       |
   33|      1|    initialized = 1;
   34|      1|}

LLVMFuzzerTestOneInput:
   10|    142|{
   11|    142|    ogs_pkbuf_t *pkbuf;
   12|    142|    ogs_gtp2_header_desc_t header;
   13|       |
   14|    142|    if (Size < kMinInputLength || Size > kMaxInputLength)
  ------------------
  |  |    6|    142|#define kMinInputLength OGS_GTPV1U_HEADER_LEN
  |  |  ------------------
  |  |  |  |   39|    284|#define OGS_GTPV1U_HEADER_LEN   8
  |  |  ------------------
  ------------------
                  if (Size < kMinInputLength || Size > kMaxInputLength)
  ------------------
  |  |    7|    138|#define kMaxInputLength 2048
  ------------------
  |  Branch (14:9): [True: 4, False: 138]
  |  Branch (14:35): [True: 2, False: 136]
  ------------------
   15|      6|        return 0;
   16|       |
   17|    136|    if (!initialized) {
  ------------------
  |  Branch (17:9): [True: 1, False: 135]
  ------------------
   18|      1|        initialize();
   19|      1|        ogs_log_install_domain(&__ogs_gtp_domain, "gtp", OGS_LOG_NONE);
   20|      1|    }
   21|       |
   22|    136|    pkbuf = ogs_pkbuf_alloc(NULL, Size);
  ------------------
  |  |   87|    136|    ogs_pkbuf_alloc_debug(pool, size, OGS_FILE_LINE)
  |  |  ------------------
  |  |  |  |  213|    136|#define OGS_FILE_LINE __FILE__ ":" OGS_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  167|    136|#define OGS_STRINGIFY(n)            OGS_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  168|    136|#define OGS_STRINGIFY_HELPER(n)     #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   23|    136|    if (pkbuf == NULL)
  ------------------
  |  Branch (23:9): [True: 0, False: 136]
  ------------------
   24|      0|        return 0;
   25|       |
   26|    136|    ogs_pkbuf_put_data(pkbuf, Data, Size);
   27|    136|    ogs_gtpu_parse_header(&header, pkbuf);
   28|    136|    ogs_gtpu_parse_header(NULL, pkbuf);
   29|    136|    ogs_pkbuf_free(pkbuf);
   30|       |
   31|    136|    return 0;
   32|    136|}

