From 7c72298636647f49681f4570506f4cc0ccf9fc77 Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Thu, 16 Sep 2004 01:06:52 +0000 Subject: use imsg_add instead of the lower level buf_add in imsg_create; it already does the error checking for us. --- usr.sbin/ntpd/imsg.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/usr.sbin/ntpd/imsg.c b/usr.sbin/ntpd/imsg.c index 41b139f4be6..8d0c0a28d78 100644 --- a/usr.sbin/ntpd/imsg.c +++ b/usr.sbin/ntpd/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.4 2004/09/16 01:02:37 henning Exp $ */ +/* $OpenBSD: imsg.c,v 1.5 2004/09/16 01:06:51 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -132,16 +132,13 @@ imsg_create(struct imsgbuf *ibuf, int type, u_int32_t peerid, hdr.type = type; hdr.peerid = peerid; hdr.pid = pid; - wbuf = buf_open(hdr.len); - if (wbuf == NULL) { + if ((wbuf = buf_open(hdr.len)) == NULL) { log_warn("imsg_create: buf_open"); return (NULL); } - if (buf_add(wbuf, &hdr, sizeof(hdr)) == -1) { - log_warnx("imsg_create: buf_add error"); - buf_free(wbuf); + if (imsg_add(wbuf, &hdr, sizeof(hdr)) == -1) return (NULL); - } + return (wbuf); } -- cgit v1.2.3