From b54c40ac0b19075d50d2e1a3aae2b3cf49591604 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 2 Dec 2018 19:28:41 +0100 Subject: [PATCH] BUILD: threads: fix minor build warnings when threads are disabled These potential null-deref warnings are emitted on gcc 7 and above when threads are disabled due to the use of objt_server() after an existing validity test. Let's switch to __objt_server() since we know the pointer is valid, it will not confuse the compiler. Some of these may be backported to 1.8. --- src/cli.c | 6 +++--- src/proto_http.c | 28 ++++++++++++++-------------- src/proto_htx.c | 32 ++++++++++++++++---------------- src/stream.c | 4 ++-- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/cli.c b/src/cli.c index b99270d08..0fbb6f3e9 100644 --- a/src/cli.c +++ b/src/cli.c @@ -2043,10 +2043,10 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit) if (objt_server(s->target)) { if (s->flags & SF_CURR_SESS) { s->flags &= ~SF_CURR_SESS; - HA_ATOMIC_SUB(&objt_server(s->target)->cur_sess, 1); + HA_ATOMIC_SUB(&__objt_server(s->target)->cur_sess, 1); } - if (may_dequeue_tasks(objt_server(s->target), be)) - process_srv_queue(objt_server(s->target)); + if (may_dequeue_tasks(__objt_server(s->target), be)) + process_srv_queue(__objt_server(s->target)); } s->target = NULL; diff --git a/src/proto_http.c b/src/proto_http.c index 0f8bc22f9..e2f300950 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -3828,7 +3828,7 @@ void http_end_txn_clean_session(struct stream *s) if (objt_server(s->target)) { if (s->flags & SF_CURR_SESS) { s->flags &= ~SF_CURR_SESS; - HA_ATOMIC_SUB(&objt_server(s->target)->cur_sess, 1); + HA_ATOMIC_SUB(&__objt_server(s->target)->cur_sess, 1); } if (may_dequeue_tasks(objt_server(s->target), be)) process_srv_queue(objt_server(s->target)); @@ -4650,8 +4650,8 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit) HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { - HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_resp, 1); - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); } abort_response: channel_auto_close(rep); @@ -4685,8 +4685,8 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit) HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { - HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_resp, 1); - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_READ_ERROR); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_READ_ERROR); } channel_auto_close(rep); @@ -4721,8 +4721,8 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit) HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { - HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_resp, 1); - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_READ_TIMEOUT); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_READ_TIMEOUT); } channel_auto_close(rep); @@ -4771,8 +4771,8 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit) HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { - HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_resp, 1); - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_BROKEN_PIPE); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_BROKEN_PIPE); } channel_auto_close(rep); @@ -4878,9 +4878,9 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit) */ if (objt_server(s->target)) { if (txn->status >= 100 && (txn->status < 500 || txn->status == 501 || txn->status == 505)) - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_OK); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_OK); else - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_STS); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_STS); } /* @@ -5271,8 +5271,8 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s if (apply_filters_to_response(s, rep, rule_set) < 0) { return_bad_resp: if (objt_server(s->target)) { - HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_resp, 1); - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_RSP); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_RSP); } HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); return_srv_prx_502: @@ -5687,7 +5687,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit res->analysers &= AN_RES_FLT_END; s->req.analysers &= AN_REQ_FLT_END; /* we're in data phase, we want to abort both directions */ if (objt_server(s->target)) - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_PRXCOND; diff --git a/src/proto_htx.c b/src/proto_htx.c index 975fd779d..b6c127ef8 100644 --- a/src/proto_htx.c +++ b/src/proto_htx.c @@ -1478,8 +1478,8 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit) HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { - HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_resp, 1); - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_READ_ERROR); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_READ_ERROR); } rep->analysers &= AN_RES_FLT_END; @@ -1509,8 +1509,8 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit) else if (rep->flags & CF_READ_TIMEOUT) { HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { - HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_resp, 1); - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_READ_TIMEOUT); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_READ_TIMEOUT); } rep->analysers &= AN_RES_FLT_END; @@ -1530,7 +1530,7 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit) HA_ATOMIC_ADD(&sess->fe->fe_counters.cli_aborts, 1); HA_ATOMIC_ADD(&s->be->be_counters.cli_aborts, 1); if (objt_server(s->target)) - HA_ATOMIC_ADD(&objt_server(s->target)->counters.cli_aborts, 1); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.cli_aborts, 1); rep->analysers &= AN_RES_FLT_END; txn->status = 400; @@ -1552,8 +1552,8 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit) HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { - HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_resp, 1); - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_BROKEN_PIPE); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_BROKEN_PIPE); } rep->analysers &= AN_RES_FLT_END; @@ -1644,7 +1644,7 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit) stream_inc_http_err_ctr(s); if (objt_server(s->target)) - HA_ATOMIC_ADD(&objt_server(s->target)->counters.p.http.rsp[n], 1); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.p.http.rsp[n], 1); /* Adjust server's health based on status code. Note: status codes 501 * and 505 are triggered on demand by client request, so we must not @@ -1652,9 +1652,9 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit) */ if (objt_server(s->target)) { if (txn->status >= 100 && (txn->status < 500 || txn->status == 501 || txn->status == 505)) - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_OK); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_OK); else - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_STS); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_STS); } /* @@ -1764,8 +1764,8 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit) return_bad_res: HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); if (objt_server(s->target)) { - HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_resp, 1); - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); } txn->status = 502; s->si[1].flags |= SI_FL_NOLINGER; @@ -1885,7 +1885,7 @@ int htx_process_res_common(struct stream *s, struct channel *rep, int an_bit, st /* has the response been denied ? */ if (txn->flags & TX_SVDENY) { if (objt_server(s->target)) - HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_secu, 1); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_secu, 1); HA_ATOMIC_ADD(&s->be->be_counters.denied_resp, 1); HA_ATOMIC_ADD(&sess->fe->fe_counters.denied_resp, 1); @@ -2072,8 +2072,8 @@ int htx_process_res_common(struct stream *s, struct channel *rep, int an_bit, st return_bad_resp: if (objt_server(s->target)) { - HA_ATOMIC_ADD(&objt_server(s->target)->counters.failed_resp, 1); - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_RSP); + HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_resp, 1); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_RSP); } HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1); @@ -2297,7 +2297,7 @@ int htx_response_forward_body(struct stream *s, struct channel *res, int an_bit) res->analysers &= AN_RES_FLT_END; s->req.analysers &= AN_REQ_FLT_END; /* we're in data phase, we want to abort both directions */ if (objt_server(s->target)) - health_adjust(objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_PRXCOND; diff --git a/src/stream.c b/src/stream.c index 5def7f179..ed913d119 100644 --- a/src/stream.c +++ b/src/stream.c @@ -352,7 +352,7 @@ static void stream_free(struct stream *s) if (objt_server(s->target)) { /* there may be requests left pending in queue */ if (s->flags & SF_CURR_SESS) { s->flags &= ~SF_CURR_SESS; - HA_ATOMIC_SUB(&objt_server(s->target)->cur_sess, 1); + HA_ATOMIC_SUB(&__objt_server(s->target)->cur_sess, 1); } if (may_dequeue_tasks(objt_server(s->target), s->be)) process_srv_queue(objt_server(s->target)); @@ -713,7 +713,7 @@ static int sess_update_st_cer(struct stream *s) if (s->flags & SF_CURR_SESS) { s->flags &= ~SF_CURR_SESS; - HA_ATOMIC_SUB(&objt_server(s->target)->cur_sess, 1); + HA_ATOMIC_SUB(&__objt_server(s->target)->cur_sess, 1); } if ((si->flags & SI_FL_ERR) &&