From: claudio Date: Tue, 23 May 2023 12:43:26 +0000 (+0000) Subject: There is no need to ibuf_zero() or memset() any buffers. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=022b5824b0c557d486b8603306d87db88cb300df;p=openbsd There is no need to ibuf_zero() or memset() any buffers. More cleanup will follow. OK tobhe@ --- diff --git a/sbin/iked/iked.h b/sbin/iked/iked.h index 6eac02342a3..9750805348e 100644 --- a/sbin/iked/iked.h +++ b/sbin/iked/iked.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iked.h,v 1.210 2023/03/05 22:17:22 tobhe Exp $ */ +/* $OpenBSD: iked.h,v 1.211 2023/05/23 12:43:26 claudio Exp $ */ /* * Copyright (c) 2019 Tobias Heider @@ -1282,7 +1282,6 @@ struct ibuf * ibuf_random(size_t); int ibuf_prepend(struct ibuf *, void *, size_t); void *ibuf_advance(struct ibuf *, size_t); -void ibuf_zero(struct ibuf *); int ibuf_strcat(struct ibuf **, const char *); int ibuf_strlen(struct ibuf *); diff --git a/sbin/iked/imsg_util.c b/sbin/iked/imsg_util.c index 2f0ee324ed4..65e8ba5df55 100644 --- a/sbin/iked/imsg_util.c +++ b/sbin/iked/imsg_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg_util.c,v 1.13 2021/05/17 08:14:37 tobhe Exp $ */ +/* $OpenBSD: imsg_util.c,v 1.14 2023/05/23 12:43:26 claudio Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter @@ -42,12 +42,6 @@ ibuf_cat(struct ibuf *dst, struct ibuf *src) return (ibuf_add(dst, src->buf, ibuf_size(src))); } -void -ibuf_zero(struct ibuf *buf) -{ - explicit_bzero(buf->buf, buf->wpos); -} - struct ibuf * ibuf_new(const void *data, size_t len) { @@ -57,8 +51,6 @@ ibuf_new(const void *data, size_t len) IKED_MSGBUF_MAX)) == NULL) return (NULL); - ibuf_zero(buf); - if (len == 0) return (buf); @@ -80,37 +72,19 @@ ibuf_new(const void *data, size_t len) struct ibuf * ibuf_static(void) { - struct ibuf *buf; - - if ((buf = ibuf_open(IKED_MSGBUF_MAX)) == NULL) - return (NULL); - - ibuf_zero(buf); - - return (buf); + return ibuf_open(IKED_MSGBUF_MAX); } void * ibuf_advance(struct ibuf *buf, size_t len) { - void *ptr; - - if ((ptr = ibuf_reserve(buf, len)) != NULL) - memset(ptr, 0, len); - - return (ptr); + return ibuf_reserve(buf, len); } void ibuf_release(struct ibuf *buf) { - if (buf == NULL) - return; - if (buf->buf != NULL) { - ibuf_zero(buf); - free(buf->buf); - } - free(buf); + ibuf_free(buf); } size_t