From 22d584a993b1756405556f9ee0fb4dbc8ffcc8c6 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Mon, 15 May 2023 17:38:44 +0200 Subject: [PATCH] CLEANUP: server: remove useless tmptrash assigments in srv_update_status() Within srv_update_status subfunctions _op() and _adm(), each time tmptrash is freed, we assign it to NULL to ensure it will not be reused. However, within those functions it is not very useful given that tmptrash is never checked against NULL except upon allocation through alloc_trash_chunk(), which happens everytime a new log message is generated, sent, and then freed right away, so there are no code paths that could lead to tmptrash being checked for reuse (tmptrash is systematically overwritten since all log messages are independant from each other). This was raised by coverity, see GH #2162. --- src/server.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/server.c b/src/server.c index 8e02cb432..956b78b3a 100644 --- a/src/server.c +++ b/src/server.c @@ -5411,7 +5411,6 @@ static int _srv_update_status_op(struct server *s, enum srv_op_st_chg_cause caus send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->area); free_trash_chunk(tmptrash); - tmptrash = NULL; } } else if (((s->cur_state != SRV_ST_RUNNING) && (s->next_state == SRV_ST_RUNNING)) @@ -5453,7 +5452,6 @@ static int _srv_update_status_op(struct server *s, enum srv_op_st_chg_cause caus send_email_alert(s, LOG_NOTICE, "%s", tmptrash->area); free_trash_chunk(tmptrash); - tmptrash = NULL; } } else if (s->cur_eweight != s->next_eweight) { @@ -5499,7 +5497,6 @@ static int _srv_update_status_adm(struct server *s, enum srv_adm_st_chg_cause ca tmptrash->area); } free_trash_chunk(tmptrash); - tmptrash = NULL; } } else { /* server was still running */ @@ -5534,7 +5531,6 @@ static int _srv_update_status_adm(struct server *s, enum srv_adm_st_chg_cause ca tmptrash->area); } free_trash_chunk(tmptrash); - tmptrash = NULL; } } } @@ -5607,7 +5603,6 @@ static int _srv_update_status_adm(struct server *s, enum srv_adm_st_chg_cause ca send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->area); free_trash_chunk(tmptrash); - tmptrash = NULL; } server_recalc_eweight(s, 0); @@ -5647,7 +5642,6 @@ static int _srv_update_status_adm(struct server *s, enum srv_adm_st_chg_cause ca send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->area); free_trash_chunk(tmptrash); - tmptrash = NULL; } } if (!(s->next_admin & SRV_ADMF_RMAINT) && (s->cur_admin & SRV_ADMF_RMAINT)) { @@ -5665,7 +5659,6 @@ static int _srv_update_status_adm(struct server *s, enum srv_adm_st_chg_cause ca send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->area); free_trash_chunk(tmptrash); - tmptrash = NULL; } } else if (!(s->next_admin & SRV_ADMF_IMAINT) && (s->cur_admin & SRV_ADMF_IMAINT)) { @@ -5679,7 +5672,6 @@ static int _srv_update_status_adm(struct server *s, enum srv_adm_st_chg_cause ca send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->area); free_trash_chunk(tmptrash); - tmptrash = NULL; } } /* don't report anything when leaving drain mode and remaining in maintenance */ @@ -5712,7 +5704,6 @@ static int _srv_update_status_adm(struct server *s, enum srv_adm_st_chg_cause ca tmptrash->area); } free_trash_chunk(tmptrash); - tmptrash = NULL; } } else if ((s->cur_admin & SRV_ADMF_DRAIN) && !(s->next_admin & SRV_ADMF_DRAIN)) { @@ -5743,7 +5734,6 @@ static int _srv_update_status_adm(struct server *s, enum srv_adm_st_chg_cause ca send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->area); free_trash_chunk(tmptrash); - tmptrash = NULL; } /* now propagate the status change to any LB algorithms */ @@ -5774,7 +5764,6 @@ static int _srv_update_status_adm(struct server *s, enum srv_adm_st_chg_cause ca send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->area); free_trash_chunk(tmptrash); - tmptrash = NULL; } } } -- 2.47.3