Download raw body.
relayd: fix DEBUG build
On Mon, May 18, 2026 at 08:35:06AM +0200, Rafael Sadowski wrote:
> Simple diff to fix the build with -DDEBUG. OK?
>
> diff --git a/usr.sbin/relayd/Makefile b/usr.sbin/relayd/Makefile
> index db2ed0f0867..008a636dae3 100644
> --- a/usr.sbin/relayd/Makefile
> +++ b/usr.sbin/relayd/Makefile
> @@ -11,6 +11,7 @@ MAN= relayd.8 relayd.conf.5
>
> LDADD= -lagentx -levent -ltls -lssl -lcrypto -lutil
> DPADD= ${LIBAGENTX} ${LIBEVENT} ${LIBSSL} ${LIBCRYPTO} ${LIBUTIL}
> +#DEBUG= -g -DDEBUG=3 -O0
> CFLAGS+= -Wall -I${.CURDIR}
> CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
> CFLAGS+= -Wmissing-declarations
> diff --git a/usr.sbin/relayd/config.c b/usr.sbin/relayd/config.c
> index d5ab25f76f4..4e1a6879848 100644
> --- a/usr.sbin/relayd/config.c
> +++ b/usr.sbin/relayd/config.c
> @@ -1179,7 +1179,7 @@ config_getrelayfd(struct relayd *env, struct imsg *imsg)
>
> DPRINTF("%s: %s %d received relay fd %d type %d for relay %s", __func__,
> env->sc_ps->ps_title[privsep_process], env->sc_ps->ps_instance,
> - imsg->fd, crfd.type, rlay->rl_conf.name);
> + imsg_get_fd(imsg), crfd.type, rlay->rl_conf.name);
imsg_get_fd() removes the fd from imsg and sets it to -1, so this will
(almost?) always print -1. I think this should just be removed from the
DPRINTF.
>
> return (0);
> }
> diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
> index a035f996f0a..6ff3a35ccd0 100644
> --- a/usr.sbin/relayd/relay.c
> +++ b/usr.sbin/relayd/relay.c
> @@ -1521,7 +1521,7 @@ relay_connect_state(struct rsession *con, struct ctl_relay_event *cre,
> DPRINTF("%s: session %d: %s state %s -> %s",
> __func__, con->se_id,
> cre->dir == RELAY_DIR_REQUEST ? "accept" : "connect",
> - relay_state(cre->state), relay_state(new));
> + relay_state_name(cre->state), relay_state_name(new));
> cre->state = new;
> }
>
> diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h
> index 5536b4789e4..bd75a70ebb9 100644
> --- a/usr.sbin/relayd/relayd.h
> +++ b/usr.sbin/relayd/relayd.h
> @@ -1168,7 +1168,7 @@ const char *host_error(enum host_error);
> const char *host_status(enum host_status);
> const char *table_check(enum table_check);
> #ifdef DEBUG
> -const char *relay_state(enum relay_state);
> +const char *relay_state_name(enum relay_state);
> #endif
> const char *print_availability(u_long, u_long);
> const char *print_host(struct sockaddr_storage *, char *, size_t);
> diff --git a/usr.sbin/relayd/util.c b/usr.sbin/relayd/util.c
> index 527891f6dd0..2dce30cacd6 100644
> --- a/usr.sbin/relayd/util.c
> +++ b/usr.sbin/relayd/util.c
> @@ -181,7 +181,7 @@ table_check(enum table_check check)
>
> #ifdef DEBUG
> const char *
> -relay_state(enum relay_state state)
> +relay_state_name(enum relay_state state)
> {
> switch (state) {
> case STATE_INIT:
>
relayd: fix DEBUG build