From b6a35ea862340125ed29457c9bb7e6a1295104c0 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 13 Jun 2023 22:33:51 +0000 Subject: Adapt to iter_func fix Signed-off-by: Laurent Bercot --- src/caches/dcache_save.c | 25 ++++++++++++------------- src/skadns/skadns_end.c | 4 ++-- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/caches/dcache_save.c b/src/caches/dcache_save.c index 04d1dac..f7ae6a4 100644 --- a/src/caches/dcache_save.c +++ b/src/caches/dcache_save.c @@ -1,14 +1,15 @@ /* ISC license. */ #include +#include #include +#include #include #include #include #include #include -#include #include #include #include @@ -16,9 +17,9 @@ #include -static int write_node_iter (char *data, void *aux) +static int write_node_iter (void *data, void *aux) { - dcache_node_t *y = (dcache_node_t *)data ; + dcache_node_t *y = data ; buffer *b = aux ; char pack[TAI_PACK * 2 + 4] ; tai_pack(pack, tain_secp(&y->entry)) ; @@ -49,26 +50,24 @@ static inline int dcache_save_to_buffer (dcache_t const *z, buffer *b) int dcache_save (dcache_t const *z, char const *file) { - stralloc sa = STRALLOC_ZERO ; + size_t len = strlen(file) ; int fd ; buffer b ; char buf[N] ; - if (!stralloc_cats(&sa, file)) return 0 ; - if (!sauniquename(&sa) || !stralloc_0(&sa)) goto err0 ; - fd = open_excl(sa.s) ; - if (fd == -1) goto err0 ; + char tmp[len + 20] ; + memcpy(tmp, file, len) ; + memcpy(tmp + len, ":dcache_save:XXXXXX", 20) ; + fd = mkstemp(tmp) ; + if (fd == -1) return 0 ; buffer_init(&b, &buffer_write, fd, buf, N) ; if (!dcache_save_to_buffer(z, &b) || fsync(fd) < 0) goto err2 ; fd_close(fd) ; - if (rename(sa.s, file) == -1) goto err1 ; - stralloc_free(&sa) ; + if (rename(tmp, file) == -1) goto err1 ; return 1 ; err2: fd_close(fd) ; err1: - unlink_void(sa.s) ; - err0: - stralloc_free(&sa) ; + unlink_void(tmp) ; return 0 ; } diff --git a/src/skadns/skadns_end.c b/src/skadns/skadns_end.c index afcab58..c6298fa 100644 --- a/src/skadns/skadns_end.c +++ b/src/skadns/skadns_end.c @@ -7,9 +7,9 @@ #include #include -static int skadnsanswer_free (char *p, void *stuff) +static int skadnsanswer_free (void *p, void *stuff) { - skadnsanswer_t *q = (skadnsanswer_t_ref)p ; + skadnsanswer_t *q = p ; alloc_free(q->data) ; (void)stuff ; return 1 ; -- cgit v1.2.3