BUILD: tree-wide: Avoid warnings about undefined entities retrieved from a CS

Since recent changes related to the conn-stream/stream-interface
refactoring, GCC reports potential null pointer dereferences when we get the
appctx, the stream or the stream-interface from the conn-strem. Of course,
depending on the time, these entities may be null. But at many places, we
know they are defined and it is safe to get them without any check. Thus, we
use ALREADY_CHECKED() macro to silent these warnings.

Note that the refactoring is unfinished, so it is not a real issue for now.
diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h
index 97b9c34..b4c33ea 100644
--- a/include/haproxy/applet.h
+++ b/include/haproxy/applet.h
@@ -113,6 +113,8 @@
 /* wakes up an applet when conditions have changed */
 static inline void appctx_wakeup(struct appctx *appctx)
 {
+	ALREADY_CHECKED(appctx);
+
 	task_wakeup(appctx->t, TASK_WOKEN_OTHER);
 }
 
diff --git a/include/haproxy/conn_stream.h b/include/haproxy/conn_stream.h
index 517d6d2..5dc9cf2 100644
--- a/include/haproxy/conn_stream.h
+++ b/include/haproxy/conn_stream.h
@@ -93,7 +93,7 @@
 
 static inline struct stream_interface *cs_si(const struct conn_stream *cs)
 {
-	return (cs_strm(cs) ? cs->si : NULL);
+	return cs->si;
 }
 
 static inline const char *cs_get_data_name(const struct conn_stream *cs)
diff --git a/include/haproxy/stream_interface.h b/include/haproxy/stream_interface.h
index 8119a42..88fc16f 100644
--- a/include/haproxy/stream_interface.h
+++ b/include/haproxy/stream_interface.h
@@ -55,13 +55,19 @@
 /* returns the channel which receives data from this stream interface (input channel) */
 static inline struct channel *si_ic(struct stream_interface *si)
 {
-	return ((si->flags & SI_FL_ISBACK) ? &(cs_strm(si->cs)->res) : &(cs_strm(si->cs)->req));
+	struct stream *strm = cs_strm(si->cs);
+
+	ALREADY_CHECKED(strm);
+	return ((si->flags & SI_FL_ISBACK) ? &(strm->res) : &(strm->req));
 }
 
 /* returns the channel which feeds data to this stream interface (output channel) */
 static inline struct channel *si_oc(struct stream_interface *si)
 {
-	return ((si->flags & SI_FL_ISBACK) ? &(cs_strm(si->cs)->req) : &(cs_strm(si->cs)->res));
+	struct stream *strm = cs_strm(si->cs);
+
+	ALREADY_CHECKED(strm);
+	return ((si->flags & SI_FL_ISBACK) ? &(strm->req) : &(strm->res));
 }
 
 /* returns the buffer which receives data from this stream interface (input channel's buffer) */
@@ -79,19 +85,28 @@
 /* returns the stream associated to a stream interface */
 static inline struct stream *si_strm(struct stream_interface *si)
 {
-	return cs_strm(si->cs);
+	struct stream *strm = cs_strm(si->cs);
+
+	ALREADY_CHECKED(strm);
+	return strm;
 }
 
 /* returns the task associated to this stream interface */
 static inline struct task *si_task(struct stream_interface *si)
 {
-	return cs_strm(si->cs)->task;
+	struct stream *strm = cs_strm(si->cs);
+
+	ALREADY_CHECKED(strm);
+	return strm->task;
 }
 
 /* returns the stream interface on the other side. Used during forwarding. */
 static inline struct stream_interface *si_opposite(struct stream_interface *si)
 {
-	return ((si->flags & SI_FL_ISBACK) ? cs_strm(si->cs)->csf->si : cs_strm(si->cs)->csb->si);
+	struct stream *strm = cs_strm(si->cs);
+
+	ALREADY_CHECKED(strm);
+	return ((si->flags & SI_FL_ISBACK) ? strm->csf->si : strm->csb->si);
 }
 
 /* initializes a stream interface in the SI_ST_INI state and create the event
diff --git a/src/hlua.c b/src/hlua.c
index 3b2bd73..8b42746 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -2685,6 +2685,7 @@
 	}
 
 	appctx = cs_appctx(s->csf);
+	ALREADY_CHECKED(appctx);
 
 	/* Check for connection established. */
 	if (appctx->ctx.hlua_cosocket.connected) {
@@ -4272,7 +4273,10 @@
 	struct hlua_appctx *luactx;
 	struct stream_interface *si = cs_si(ctx->owner);
 	struct stream *s = si_strm(si);
-	struct proxy *p = s->be;
+	struct proxy *p;
+
+	ALREADY_CHECKED(s);
+	p = s->be;
 
 	/* Check stack size. */
 	if (!lua_checkstack(L, 3))
diff --git a/src/http_ana.c b/src/http_ana.c
index a3fd15c..ff98a7b 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -3883,6 +3883,7 @@
 	struct htx_sl *sl;
 
 	appctx = cs_appctx(s->csb);
+	ALREADY_CHECKED(appctx);
 	memset(&appctx->ctx.stats, 0, sizeof(appctx->ctx.stats));
 	appctx->st1 = appctx->st2 = 0;
 	appctx->ctx.stats.st_code = STAT_STATUS_INIT;
diff --git a/src/mux_pt.c b/src/mux_pt.c
index 9f1aaa8..1a70627 100644
--- a/src/mux_pt.c
+++ b/src/mux_pt.c
@@ -407,7 +407,10 @@
 static void mux_pt_detach(struct conn_stream *cs)
 {
 	struct connection *conn = cs_conn(cs);
-	struct mux_pt_ctx *ctx = conn->ctx;
+	struct mux_pt_ctx *ctx;
+
+	ALREADY_CHECKED(conn);
+	ctx = conn->ctx;
 
 	TRACE_ENTER(PT_EV_STRM_END, conn, cs);
 
diff --git a/src/proxy.c b/src/proxy.c
index c392b4c..c486376 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -2613,7 +2613,7 @@
 static int dump_servers_state(struct stream_interface *si)
 {
 	struct appctx *appctx = cs_appctx(si->cs);
-	struct proxy *px = appctx->ctx.cli.p0;
+	struct proxy *px;
 	struct server *srv;
 	char srv_addr[INET6_ADDRSTRLEN + 1];
 	char srv_agent_addr[INET6_ADDRSTRLEN + 1];
@@ -2622,6 +2622,9 @@
 	int bk_f_forced_id, srv_f_forced_id;
 	char *srvrecord;
 
+	ALREADY_CHECKED(appctx);
+	px = appctx->ctx.cli.p0;
+
 	if (!appctx->ctx.cli.p1)
 		appctx->ctx.cli.p1 = px->srv;
 
diff --git a/src/stats.c b/src/stats.c
index bffd3e3..854515b 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -1984,6 +1984,8 @@
 	struct stats_module *mod;
 	size_t stats_count = ST_F_TOTAL_FIELDS;
 
+	ALREADY_CHECKED(appctx);
+
 	memset(stats, 0, sizeof(struct field) * stat_count[STATS_DOMAIN_PROXY]);
 
 	if (!stats_fill_li_stats(px, l, appctx->ctx.stats.flags, stats,
@@ -2495,6 +2497,8 @@
 	struct field *stats = stat_l[STATS_DOMAIN_PROXY];
 	size_t stats_count = ST_F_TOTAL_FIELDS;
 
+	ALREADY_CHECKED(appctx);
+
 	memset(stats, 0, sizeof(struct field) * stat_count[STATS_DOMAIN_PROXY]);
 
 	if (!stats_fill_sv_stats(px, sv, appctx->ctx.stats.flags, stats,
@@ -4205,6 +4209,8 @@
 	struct htx_sl *sl;
 	unsigned int flags;
 
+	ALREADY_CHECKED(appctx);
+
 	/* scope_txt = search pattern + search query, appctx->ctx.stats.scope_len is always <= STAT_SCOPE_TXT_MAXLEN */
 	scope_txt[0] = 0;
 	if (appctx->ctx.stats.scope_len) {
@@ -4518,6 +4524,8 @@
 {
 	struct appctx *appctx = cs_appctx(si->cs);
 
+	ALREADY_CHECKED(appctx);
+
 	if (!stats_fill_info(info, INF_TOTAL_FIELDS, appctx->ctx.stats.flags))
 		return 0;
 
diff --git a/src/stream.c b/src/stream.c
index 935fce4..37cd793 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -980,11 +980,11 @@
 	if (flags & ACT_OPT_FIRST) {
 		/* Register applet. this function schedules the applet. */
 		s->target = &rule->applet.obj_type;
-		if (unlikely(!si_register_handler(cs_si(s->csb), objt_applet(s->target))))
+		appctx = si_register_handler(cs_si(s->csb), objt_applet(s->target));
+		if (unlikely(!appctx))
 			return ACT_RET_ERR;
 
 		/* Initialise the context. */
-		appctx = cs_appctx(s->csb);
 		memset(&appctx->ctx, 0, sizeof(appctx->ctx));
 		appctx->rule = rule;
 	}
@@ -3101,6 +3101,8 @@
 	struct connection *conn;
 	struct appctx *tmpctx;
 
+	ALREADY_CHECKED(appctx);
+
 	chunk_reset(&trash);
 
 	if (appctx->ctx.sess.section > 0 && appctx->ctx.sess.uid != strm->uniq_id) {