DEBUG: opentracing: show return values of all functions in the debug output

If the OpenTracing filter is compiled using the 'OT_DEBUG=1' option, then
log messages are printed to stderr when the filter is running.  In the log
one can then find (among other things) the order in which the function is
called and the value that the function returns (if it is not a void type).

Prior to applying this patch, no value returned by a function was logged.

Log output example:
  [ 1]    0.038807 [OT]: flt_ot_init_per_thread(0x56365bd45ec0, 0x56365bd48210) {
  [ 1]    0.038807 [OT]:    ot_start(0x56365bd58920, 0x56365bd4e3a0, 0x7f561acba168:(nil)) {
  [ 1]    0.038807 [OT]:    } = 0
  [ 1]    0.038807 [OT]: } = 0

This patch must be backported as far as 2.4.

(cherry picked from commit ca09e01a137ebb557fbda3edb79dd22922753667)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 83eb076c3be8ef2eaa61c3b33f219d1decb575cb)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/addons/ot/src/parser.c b/addons/ot/src/parser.c
index e26ca18..513054b 100644
--- a/addons/ot/src/parser.c
+++ b/addons/ot/src/parser.c
@@ -67,7 +67,7 @@
 		retval |= ERR_ABORT | ERR_ALERT;
 	}
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -112,7 +112,7 @@
 		retval = flt_ot_parse_strdup(ptr, args[pos + 1], err, args[cur_arg]);
 	}
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -137,7 +137,7 @@
 	FLT_OT_FUNC("\"%s\", %d", name, type);
 
 	if (!FLT_OT_STR_ISVALID(name))
-		FLT_OT_RETURN(retptr);
+		FLT_OT_RETURN_EX(retptr, const char *, "%p");
 
 	if (type == 1) {
 		retptr = invalid_char(name);
@@ -162,7 +162,7 @@
 			retptr = NULL;
 	}
 
-	FLT_OT_RETURN(retptr);
+	FLT_OT_RETURN_EX(retptr, const char *, "%p");
 }
 
 
@@ -241,7 +241,7 @@
 	if (!(retval & ERR_CODE) && (*pdata)->flag_check_id && (id == NULL))
 		FLT_OT_PARSE_ERR(err, "'%s' : %s ID not set (use '%s%s')", args[0], parse_data[1].name, parse_data[1].name, parse_data[1].usage);
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -285,7 +285,7 @@
 	if (retval & ERR_CODE)
 		flt_ot_conf_sample_expr_free(&expr);
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -335,7 +335,7 @@
 	else
 		FLT_OT_DBG(3, "sample '%s' -> '%s' added", sample->key, sample->value);
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -371,7 +371,7 @@
 	if (retval & ERR_CODE)
 		flt_ot_conf_str_free(&str);
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -409,7 +409,7 @@
 	else
 		retval = flt_ot_parse_keyword(ptr, args, 0, 0, err, err_msg);
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -470,13 +470,13 @@
 	FLT_OT_FUNC("\"%s\", %d, %p, 0x%08x", file, linenum, args, kw_mod);
 
 	if (flt_ot_parse_check_scope())
-		FLT_OT_RETURN(retval);
+		FLT_OT_RETURN_INT(retval);
 
 	retval = flt_ot_parse_cfg_check(file, linenum, args, flt_ot_current_tracer, parse_data, FLT_OT_TABLESIZE(parse_data), &pdata, &err);
 	if (retval & ERR_CODE) {
 		FLT_OT_PARSE_IFERR_ALERT();
 
-		FLT_OT_RETURN(retval);
+		FLT_OT_RETURN_INT(retval);
 	}
 
 	if (pdata->keyword == FLT_OT_PARSE_TRACER_ID) {
@@ -554,7 +554,7 @@
 	if ((retval & ERR_CODE) && (flt_ot_current_tracer != NULL))
 		flt_ot_conf_tracer_free(&flt_ot_current_tracer);
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -580,12 +580,12 @@
 	FLT_OT_FUNC("");
 
 	if (flt_ot_current_tracer == NULL)
-		FLT_OT_RETURN(retval);
+		FLT_OT_RETURN_INT(retval);
 
 	flt_ot_current_config->tracer = flt_ot_current_tracer;
 
 	if (flt_ot_current_tracer->id == NULL)
-		FLT_OT_RETURN(retval);
+		FLT_OT_RETURN_INT(retval);
 
 	if (flt_ot_current_tracer->config == NULL) {
 		FLT_OT_POST_PARSE_ALERT("tracer '%s' has no configuration file specified", flt_ot_current_tracer->cfg_line, flt_ot_current_tracer->id);
@@ -600,7 +600,7 @@
 
 	flt_ot_current_tracer = NULL;
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -633,13 +633,13 @@
 	FLT_OT_FUNC("\"%s\", %d, %p, 0x%08x", file, linenum, args, kw_mod);
 
 	if (flt_ot_parse_check_scope())
-		FLT_OT_RETURN(retval);
+		FLT_OT_RETURN_INT(retval);
 
 	retval = flt_ot_parse_cfg_check(file, linenum, args, flt_ot_current_group, parse_data, FLT_OT_TABLESIZE(parse_data), &pdata, &err);
 	if (retval & ERR_CODE) {
 		FLT_OT_PARSE_IFERR_ALERT();
 
-		FLT_OT_RETURN(retval);
+		FLT_OT_RETURN_INT(retval);
 	}
 
 	if (pdata->keyword == FLT_OT_PARSE_GROUP_ID) {
@@ -658,7 +658,7 @@
 	if ((retval & ERR_CODE) && (flt_ot_current_group != NULL))
 		flt_ot_conf_group_free(&flt_ot_current_group);
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -683,7 +683,7 @@
 	FLT_OT_FUNC("");
 
 	if (flt_ot_current_group == NULL)
-		FLT_OT_RETURN(retval);
+		FLT_OT_RETURN_INT(retval);
 
 	/* Check that the group has at least one scope defined. */
 	if (LIST_ISEMPTY(&(flt_ot_current_group->ph_scopes)))
@@ -691,7 +691,7 @@
 
 	flt_ot_current_group = NULL;
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -734,7 +734,7 @@
 
 	FLT_OT_DBG(2, "ctx_flags: 0x%02hhx (0x%02hhx)", flt_ot_current_span->ctx_flags, flags);
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -774,7 +774,7 @@
 	if ((retptr != NULL) && (err != NULL))
 		FLT_OT_FREE_CLEAR(*err);
 
-	FLT_OT_RETURN(retptr);
+	FLT_OT_RETURN_PTR(retptr);
 }
 
 
@@ -807,13 +807,13 @@
 	FLT_OT_FUNC("\"%s\", %d, %p, 0x%08x", file, linenum, args, kw_mod);
 
 	if (flt_ot_parse_check_scope())
-		FLT_OT_RETURN(retval);
+		FLT_OT_RETURN_INT(retval);
 
 	retval = flt_ot_parse_cfg_check(file, linenum, args, flt_ot_current_span, parse_data, FLT_OT_TABLESIZE(parse_data), &pdata, &err);
 	if (retval & ERR_CODE) {
 		FLT_OT_PARSE_IFERR_ALERT();
 
-		FLT_OT_RETURN(retval);
+		FLT_OT_RETURN_INT(retval);
 	}
 
 	if (pdata->keyword == FLT_OT_PARSE_SCOPE_ID) {
@@ -1005,7 +1005,7 @@
 		flt_ot_current_span = NULL;
 	}
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -1034,7 +1034,7 @@
 	FLT_OT_FUNC("");
 
 	if (flt_ot_current_scope == NULL)
-		FLT_OT_RETURN(retval);
+		FLT_OT_RETURN_INT(retval);
 
 	/* If span context inject is used, check that this is possible. */
 	list_for_each_entry(conf_span, &(flt_ot_current_scope->spans), list)
@@ -1048,7 +1048,7 @@
 	flt_ot_current_scope = NULL;
 	flt_ot_current_span  = NULL;
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -1099,7 +1099,7 @@
 
 	flt_ot_current_config = NULL;
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }
 
 
@@ -1144,7 +1144,7 @@
 		if (otc_dbg_mem_init(&dbg_mem, dbg_mem_data, FLT_OT_TABLESIZE(dbg_mem_data), 0xff) == -1) {
 			FLT_OT_PARSE_ERR(err, "cannot initialize memory debugger");
 
-			FLT_OT_RETURN(retval);
+			FLT_OT_RETURN_INT(retval);
 		}
 	);
 #endif
@@ -1155,7 +1155,7 @@
 	if (conf == NULL) {
 		FLT_OT_PARSE_ERR(err, "'%s' : out of memory", args[*cur_arg]);
 
-		FLT_OT_RETURN(retval);
+		FLT_OT_RETURN_INT(retval);
 	}
 
 	for (pos = *cur_arg + 1; !(retval & ERR_CODE) && FLT_OT_ARG_ISVALID(pos); pos++) {
@@ -1198,7 +1198,7 @@
 		FLT_OT_DBG(3, "filter set: id '%s', config '%s'", conf->id, conf->cfg_file);
 	}
 
-	FLT_OT_RETURN(retval);
+	FLT_OT_RETURN_INT(retval);
 }