From 9ec9b5d086d0defe6be9dc960e46fa6db0381398 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 12 Nov 2018 12:31:49 +0000 Subject: [PATCH] simplify code for resolver_getnaimeinfo() ok gilles@ --- usr.sbin/smtpd/resolver.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/usr.sbin/smtpd/resolver.c b/usr.sbin/smtpd/resolver.c index 22011520f09..5422141647b 100644 --- a/usr.sbin/smtpd/resolver.c +++ b/usr.sbin/smtpd/resolver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolver.c,v 1.3 2018/11/11 14:56:05 eric Exp $ */ +/* $OpenBSD: resolver.c,v 1.4 2018/11/12 12:31:49 eric Exp $ */ /* * Copyright (c) 2017-2018 Eric Faurot @@ -206,6 +206,8 @@ resolver_dispatch_request(struct mproc *proc, struct imsg *imsg) m_create(proc, IMSG_GETNAMEINFO, reqid, 0, -1); m_add_int(proc, EAI_SYSTEM); m_add_int(proc, save_errno); + m_add_string(proc, NULL); + m_add_string(proc, NULL); m_close(proc); break; @@ -283,15 +285,12 @@ resolver_dispatch_result(struct mproc *proc, struct imsg *imsg) case IMSG_GETNAMEINFO: m_get_int(&m, &gai_errno); m_get_int(&m, &errno); - if (gai_errno == 0) { - m_get_string(&m, &host); - m_get_string(&m, &serv); - } + m_get_string(&m, &host); + m_get_string(&m, &serv); m_end(&m); SPLAY_REMOVE(reqtree, &reqs, req); - req->cb_ni(req->arg, gai_errno, gai_errno ? NULL : host, - gai_errno ? NULL : serv); + req->cb_ni(req->arg, gai_errno, host, serv); free(req); break; } @@ -343,10 +342,8 @@ resolver_getnameinfo_cb(struct asr_result *ar, void *arg) m_create(s->proc, IMSG_GETNAMEINFO, s->reqid, 0, -1); m_add_int(s->proc, ar->ar_gai_errno); m_add_int(s->proc, ar->ar_errno); - if (ar->ar_gai_errno == 0) { - m_add_string(s->proc, s->host); - m_add_string(s->proc, s->serv); - } + m_add_string(s->proc, ar->ar_gai_errno ? NULL : s->host); + m_add_string(s->proc, ar->ar_gai_errno ? NULL : s->serv); m_close(s->proc); free(s->host); -- 2.20.1