From: Aurelien DARRAGON Date: Tue, 8 Apr 2025 13:18:21 +0000 (+0200) Subject: MINOR: stats: add ME_NEW_COMMON() helper X-Git-Tag: v3.3-dev1~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7c017ec3c73c6d4d7d1453cdc610f7eec8b8a46;p=thirdparty%2Fhaproxy.git MINOR: stats: add ME_NEW_COMMON() helper Split ME_NEW_* helper into COMMON part and specific part so it becomes easier to add alternative helpers without code duplication. --- diff --git a/src/stats-proxy.c b/src/stats-proxy.c index 90d82f0e9..1ea3114ff 100644 --- a/src/stats-proxy.c +++ b/src/stats-proxy.c @@ -19,32 +19,35 @@ #include #include -/* Define a new generic metric for both frontend and backend sides. */ -#define ME_NEW_PX(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \ - { .name = (name_f), .desc = (desc_f), .type = (nature)|(format), \ - .metric.offset[0] = offsetof(struct fe_counters, offset_f), \ - .metric.offset[1] = offsetof(struct be_counters, offset_f), \ +/* Common helper to create a new generic metric */ +#define ME_NEW_COMMON(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \ + .name = (name_f), .desc = (desc_f), .type = (nature)|(format), \ .cap = (cap_f), \ - .flags = STAT_COL_FL_GENERIC, \ .alt_name = alt_n, \ + +/* Define a new generic metric for both frontend and backend sides. */ +#define ME_NEW_PX(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \ + { \ + ME_NEW_COMMON(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \ + .flags = STAT_COL_FL_GENERIC, \ + .metric.offset[0] = offsetof(struct fe_counters, offset_f), \ + .metric.offset[1] = offsetof(struct be_counters, offset_f), \ } /* Define a new generic metric for frontend side only. */ #define ME_NEW_FE(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \ - { .name = (name_f), .desc = (desc_f), .type = (nature)|(format), \ - .metric.offset[0] = offsetof(struct fe_counters, offset_f), \ - .cap = (cap_f), \ + { \ + ME_NEW_COMMON(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \ .flags = STAT_COL_FL_GENERIC, \ - .alt_name = alt_n, \ + .metric.offset[0] = offsetof(struct fe_counters, offset_f), \ } /* Define a new generic metric for backend side only. */ #define ME_NEW_BE(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \ - { .name = (name_f), .desc = (desc_f), .type = (nature)|(format), \ - .metric.offset[1] = offsetof(struct be_counters, offset_f), \ - .cap = (cap_f), \ + { \ + ME_NEW_COMMON(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \ .flags = STAT_COL_FL_GENERIC, \ - .alt_name = alt_n, \ + .metric.offset[1] = offsetof(struct be_counters, offset_f), \ } const struct stat_col stat_cols_px[ST_I_PX_MAX] = {