Le 22/01/2021 à 21:09, William Dauchy a écrit :
while working on backend/servers I realised I could have written that in
a better way and avoid one extra break. This is slightly improving
readiness.
also while being here, fix function declaration which was not 100%
accurate.
this patch does not change the behaviour of the code.
Signed-off-by: William Dauchy <[email protected]>
---
include/haproxy/stats.h | 2 +-
src/stats.c | 45 +++++++++++++++++------------------------
2 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/include/haproxy/stats.h b/include/haproxy/stats.h
index eb72446ae..8210367ac 100644
--- a/include/haproxy/stats.h
+++ b/include/haproxy/stats.h
@@ -47,7 +47,7 @@ int stats_dump_one_line(const struct field *stats, size_t
stats_count, struct ap
int stats_fill_info(struct field *info, int len);
int stats_fill_fe_stats(struct proxy *px, struct field *stats, int len,
- enum stat_field *field);
+ enum stat_field *selected_field);
int stats_fill_li_stats(struct proxy *px, struct listener *l, int flags,
struct field *stats, int len);
int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
diff --git a/src/stats.c b/src/stats.c
index e1b350a44..161fc6548 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -1712,49 +1712,40 @@ int stats_fill_fe_stats(struct proxy *px, struct field
*stats, int len,
metric = mkf_u64(FN_COUNTER,
px->fe_counters.internal_errors);
break;
case ST_F_HRSP_1XX:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[1]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[1]);
break;
case ST_F_HRSP_2XX:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[2]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[2]);
break;
case ST_F_HRSP_3XX:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[3]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[3]);
break;
case ST_F_HRSP_4XX:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[4]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[4]);
break;
case ST_F_HRSP_5XX:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[5]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[5]);
break;
case ST_F_HRSP_OTHER:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[0]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.rsp[0]);
break;
case ST_F_INTERCEPTED:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER,
px->fe_counters.intercepted_req);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER,
px->fe_counters.intercepted_req);
break;
case ST_F_CACHE_LOOKUPS:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.cache_lookups);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.cache_lookups);
break;
case ST_F_CACHE_HITS:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.cache_hits);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER,
px->fe_counters.p.http.cache_hits);
break;
case ST_F_REQ_RATE:
metric = mkf_u32(FN_RATE,
read_freq_ctr(&px->fe_req_per_sec));
Merged too. Thanks !
--
Christopher Faulet