CLEANUP: conn_stream: apply cs_endp_flags.cocci tree-wide

This changes all main uses of cs->endp->flags to the sc_ep_*() equivalent
by applying coccinelle script cs_endp_flags.cocci.

Note: 143 locations were touched, manually reviewed and found to be OK,
except a single one that was adjusted in cs_reset_endp() where the flags
are read and filtered to be used as-is and not as a boolean, hence was
replaced with sc_ep_get() & $FLAGS.

The script was applied with all includes:

  spatch --in-place --recursive-includes -I include --sp-file $script $files
diff --git a/src/tcpcheck.c b/src/tcpcheck.c
index 3b1d75a..caceb6d 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -1484,7 +1484,7 @@
 	TRACE_DATA("send data", CHK_EV_TCPCHK_SND|CHK_EV_TX_DATA, check);
 	if (conn->mux->snd_buf(cs, &check->bo,
 			       (IS_HTX_CONN(conn) ? (htxbuf(&check->bo))->data: b_data(&check->bo)), 0) <= 0) {
-		if ((conn->flags & CO_FL_ERROR) || (cs->endp->flags & CS_EP_ERROR)) {
+		if ((conn->flags & CO_FL_ERROR) || sc_ep_test(cs, CS_EP_ERROR)) {
 			ret = TCPCHK_EVAL_STOP;
 			TRACE_DEVEL("connection error during send", CHK_EV_TCPCHK_SND|CHK_EV_TX_DATA|CHK_EV_TX_ERR, check);
 			goto out;
@@ -1548,7 +1548,7 @@
 		goto wait_more_data;
 	}
 
-	if (cs->endp->flags & CS_EP_EOS)
+	if (sc_ep_test(cs, CS_EP_EOS))
 		goto end_recv;
 
 	if (check->state & CHK_ST_IN_ALLOC) {
@@ -1565,15 +1565,15 @@
 	/* errors on the connection and the conn-stream were already checked */
 
 	/* prepare to detect if the mux needs more room */
-	cs->endp->flags &= ~CS_EP_WANT_ROOM;
+	sc_ep_clr(cs, CS_EP_WANT_ROOM);
 
-	while ((cs->endp->flags & CS_EP_RCV_MORE) ||
-	       (!(conn->flags & CO_FL_ERROR) && !(cs->endp->flags & (CS_EP_ERROR|CS_EP_EOS)))) {
+	while (sc_ep_test(cs, CS_EP_RCV_MORE) ||
+	       (!(conn->flags & CO_FL_ERROR) && !sc_ep_test(cs, CS_EP_ERROR | CS_EP_EOS))) {
 		max = (IS_HTX_CS(cs) ?  htx_free_space(htxbuf(&check->bi)) : b_room(&check->bi));
 		read = conn->mux->rcv_buf(cs, &check->bi, max, 0);
 		cur_read += read;
 		if (!read ||
-		    (cs->endp->flags & CS_EP_WANT_ROOM) ||
+		    sc_ep_test(cs, CS_EP_WANT_ROOM) ||
 		    (--read_poll <= 0) ||
 		    (read < max && read >= global.tune.recv_enough))
 			break;
@@ -1581,7 +1581,7 @@
 
   end_recv:
 	is_empty = (IS_HTX_CS(cs) ? htx_is_empty(htxbuf(&check->bi)) : !b_data(&check->bi));
-	if (is_empty && ((conn->flags & CO_FL_ERROR) || (cs->endp->flags & CS_EP_ERROR))) {
+	if (is_empty && ((conn->flags & CO_FL_ERROR) || sc_ep_test(cs, CS_EP_ERROR))) {
 		/* Report network errors only if we got no other data. Otherwise
 		 * we'll let the upper layers decide whether the response is OK
 		 * or not. It is very common that an RST sent by the server is
@@ -1591,15 +1591,17 @@
 		goto stop;
 	}
 	if (!cur_read) {
-		if (cs->endp->flags & CS_EP_EOI) {
+		if (sc_ep_test(cs, CS_EP_EOI)) {
 			/* If EOI is set, it means there is a response or an error */
 			goto out;
 		}
-		if (!(cs->endp->flags & (CS_EP_WANT_ROOM|CS_EP_ERROR|CS_EP_EOS))) {
+
+		if (!sc_ep_test(cs, CS_EP_WANT_ROOM | CS_EP_ERROR | CS_EP_EOS)) {
 			conn->mux->subscribe(cs, SUB_RETRY_RECV, &cs->wait_event);
 			TRACE_DEVEL("waiting for response", CHK_EV_RX_DATA, check);
 			goto wait_more_data;
 		}
+
 		if (is_empty) {
 			int status;
 
@@ -2141,7 +2143,7 @@
 	 */
 
 	/* 1- check for connection error, if any */
-	if ((conn && conn->flags & CO_FL_ERROR) || (cs->endp->flags & CS_EP_ERROR))
+	if ((conn && conn->flags & CO_FL_ERROR) || sc_ep_test(cs, CS_EP_ERROR))
 		goto out_end_tcpcheck;
 
 	/* 2- check if a rule must be resume. It happens if check->current_step
@@ -2223,7 +2225,7 @@
 					goto out_end_tcpcheck;
 				else if (eval_ret == TCPCHK_EVAL_WAIT)
 					goto out;
-				last_read = ((conn->flags & CO_FL_ERROR) || (cs->endp->flags & (CS_EP_ERROR|CS_EP_EOS)));
+				last_read = ((conn->flags & CO_FL_ERROR) || sc_ep_test(cs, CS_EP_ERROR | CS_EP_EOS));
 				must_read = 0;
 			}
 
@@ -2304,7 +2306,7 @@
 	TRACE_PROTO("tcp-check passed", CHK_EV_TCPCHK_EVAL, check);
 
   out_end_tcpcheck:
-	if ((conn && conn->flags & CO_FL_ERROR) || (cs->endp->flags & CS_EP_ERROR)) {
+	if ((conn && conn->flags & CO_FL_ERROR) || sc_ep_test(cs, CS_EP_ERROR)) {
 		TRACE_ERROR("report connection error", CHK_EV_TCPCHK_EVAL|CHK_EV_TCPCHK_ERR, check);
 		chk_report_conn_err(check, errno, 0);
 	}