MT#55283 turn stats_metric into typedef

Change-Id: I4f41315409cc34494032e4f01f821d06d4f74d7e
pull/1776/head
Richard Fuchs 2 years ago
parent 4e7078834f
commit d4d8e0368f

@ -467,7 +467,7 @@ static void cli_incoming_list_totals(str *instr, struct cli_writer *cw) {
AUTO_CLEANUP_INIT(GQueue *metrics, statistics_free_metrics, statistics_gather_metrics(NULL)); AUTO_CLEANUP_INIT(GQueue *metrics, statistics_free_metrics, statistics_gather_metrics(NULL));
for (GList *l = metrics->head; l; l = l->next) { for (GList *l = metrics->head; l; l = l->next) {
struct stats_metric *m = l->data; stats_metric *m = l->data;
if (!m->descr) if (!m->descr)
continue; continue;
if (m->value_long) { if (m->value_long) {
@ -1706,7 +1706,7 @@ static void cli_incoming_list_jsonstats(str *instr, struct cli_writer *cw) {
AUTO_CLEANUP_INIT(GQueue *metrics, statistics_free_metrics, statistics_gather_metrics(NULL)); AUTO_CLEANUP_INIT(GQueue *metrics, statistics_free_metrics, statistics_gather_metrics(NULL));
for (GList *l = metrics->head; l; l = l->next) { for (GList *l = metrics->head; l; l = l->next) {
struct stats_metric *m = l->data; stats_metric *m = l->data;
if (!m->label) if (!m->label)
continue; continue;

@ -471,7 +471,7 @@ static void mqtt_global_stats(JsonBuilder *json) {
statistics_gather_metrics(&interface_rate_stats)); statistics_gather_metrics(&interface_rate_stats));
for (GList *l = metrics->head; l; l = l->next) { for (GList *l = metrics->head; l; l = l->next) {
struct stats_metric *m = l->data; stats_metric *m = l->data;
if (!m->label) if (!m->label)
continue; continue;

@ -198,7 +198,7 @@ found:;
INLINE void prom_metric(GQueue *ret, const char *name, const char *type) { INLINE void prom_metric(GQueue *ret, const char *name, const char *type) {
struct stats_metric *last = g_queue_peek_tail(ret); stats_metric *last = g_queue_peek_tail(ret);
last->prom_name = name; last->prom_name = name;
last->prom_type = type; last->prom_type = type;
} }
@ -207,15 +207,15 @@ static void prom_label(GQueue *ret, const char *fmt, ...) {
return; return;
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
struct stats_metric *last = g_queue_peek_tail(ret); stats_metric *last = g_queue_peek_tail(ret);
last->prom_label = g_strdup_vprintf(fmt, ap); last->prom_label = g_strdup_vprintf(fmt, ap);
va_end(ap); va_end(ap);
} }
#define PROM(name, type) prom_metric(ret, name, type) #define PROM(name, type) prom_metric(ret, name, type)
#define PROMLAB(fmt, ...) prom_label(ret, fmt, ##__VA_ARGS__) #define PROMLAB(fmt, ...) prom_label(ret, fmt, ##__VA_ARGS__)
INLINE void metric_push(GQueue *ret, struct stats_metric *m) { INLINE void metric_push(GQueue *ret, stats_metric *m) {
struct stats_metric *last = NULL; stats_metric *last = NULL;
for (GList *l_last = ret->tail; l_last; l_last = l_last->prev) { for (GList *l_last = ret->tail; l_last; l_last = l_last->prev) {
last = l_last->data; last = l_last->data;
if (last->label) if (last->label)
@ -233,7 +233,7 @@ INLINE void metric_push(GQueue *ret, struct stats_metric *m) {
static void add_metric(GQueue *ret, const char *label, const char *desc, const char *fmt1, const char *fmt2, ...) { static void add_metric(GQueue *ret, const char *label, const char *desc, const char *fmt1, const char *fmt2, ...) {
va_list ap; va_list ap;
struct stats_metric *m = g_slice_alloc0(sizeof(*m)); stats_metric *m = g_slice_alloc0(sizeof(*m));
if (label) if (label)
m->label = g_strdup(label); m->label = g_strdup(label);
if (desc) if (desc)
@ -276,7 +276,7 @@ static void add_metric(GQueue *ret, const char *label, const char *desc, const c
static void add_header(GQueue *ret, const char *fmt1, const char *fmt2, ...) { static void add_header(GQueue *ret, const char *fmt1, const char *fmt2, ...) {
va_list ap; va_list ap;
struct stats_metric *m = g_slice_alloc0(sizeof(*m)); stats_metric *m = g_slice_alloc0(sizeof(*m));
if (fmt1) { if (fmt1) {
va_start(ap, fmt2); // coverity[copy_paste_error : FALSE] va_start(ap, fmt2); // coverity[copy_paste_error : FALSE]
m->label = g_strdup_vprintf(fmt1, ap); m->label = g_strdup_vprintf(fmt1, ap);
@ -915,7 +915,7 @@ GQueue *statistics_gather_metrics(struct interface_sampled_rate_stats *interface
#pragma GCC diagnostic warning "-Wformat-zero-length" #pragma GCC diagnostic warning "-Wformat-zero-length"
static void free_stats_metric(void *p) { static void free_stats_metric(void *p) {
struct stats_metric *m = p; stats_metric *m = p;
g_free(m->descr); g_free(m->descr);
g_free(m->label); g_free(m->label);
g_free(m->value_long); g_free(m->value_long);
@ -960,7 +960,7 @@ const char *statistics_ng(bencode_item_t *input, bencode_item_t *output) {
bencode_buffer_t *buf = output->buffer; bencode_buffer_t *buf = output->buffer;
for (GList *l = metrics->head; l; l = l->next) { for (GList *l = metrics->head; l; l = l->next) {
struct stats_metric *m = l->data; stats_metric *m = l->data;
if (!m->label) if (!m->label)
continue; continue;

@ -389,7 +389,7 @@ static const char *websocket_http_metrics(struct websocket_message *wm) {
g_autoptr(GHashTable) metric_types = g_hash_table_new(g_str_hash, g_str_equal); g_autoptr(GHashTable) metric_types = g_hash_table_new(g_str_hash, g_str_equal);
for (GList *l = metrics->head; l; l = l->next) { for (GList *l = metrics->head; l; l = l->next) {
struct stats_metric *m = l->data; stats_metric *m = l->data;
if (!m->label) if (!m->label)
continue; continue;
if (!m->value_short) if (!m->value_short)

@ -2,6 +2,7 @@
#define __TYPES__H__ #define __TYPES__H__
typedef struct sdp_ng_flags sdp_ng_flags; typedef struct sdp_ng_flags sdp_ng_flags;
typedef struct stats_metric stats_metric;
#include "containers.h" #include "containers.h"

Loading…
Cancel
Save