From 179a5728e367b8eca388e404a7fbcc08b887b86c Mon Sep 17 00:00:00 2001 From: claudio Date: Thu, 23 Apr 2026 14:15:53 +0000 Subject: [PATCH] Move repo_tree_free() up to where the other repo functions live. OK tb@ --- usr.sbin/rpki-client/parser.c | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/usr.sbin/rpki-client/parser.c b/usr.sbin/rpki-client/parser.c index 4b903634f1a..6dbf45a8e45 100644 --- a/usr.sbin/rpki-client/parser.c +++ b/usr.sbin/rpki-client/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.178 2026/01/27 09:41:42 tb Exp $ */ +/* $OpenBSD: parser.c,v 1.179 2026/04/23 14:15:53 claudio Exp $ */ /* * Copyright (c) 2019 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -108,6 +108,26 @@ repo_add(unsigned int id, char *path, char *validpath) errx(1, "pthread_rwlock_unlock: %s", strerror(error)); } +static void +repo_tree_free(struct repo_tree *tree) +{ + struct parse_repo *repo, *trepo; + int error; + + if ((error = pthread_rwlock_wrlock(&repos_lk)) != 0) + errx(1, "pthread_rwlock_wrlock: %s", strerror(error)); + RB_FOREACH_SAFE(repo, repo_tree, tree, trepo) { + RB_REMOVE(repo_tree, tree, repo); + free(repo->path); + free(repo->validpath); + free(repo); + } + if ((error = pthread_rwlock_unlock(&repos_lk)) != 0) + errx(1, "pthread_rwlock_unlock: %s", strerror(error)); + if ((error = pthread_rwlock_destroy(&repos_lk)) != 0) + errx(1, "pthread_rwlock_destroy: %s", strerror(error)); +} + /* * Return the issuer by its certificate id, or NULL on failure. * Make sure the AKI is the same as the AKI listed on the Manifest, @@ -1151,26 +1171,6 @@ parse_writer(void *arg) return NULL; } -static void -repo_tree_free(struct repo_tree *tree) -{ - struct parse_repo *repo, *trepo; - int error; - - if ((error = pthread_rwlock_wrlock(&repos_lk)) != 0) - errx(1, "pthread_rwlock_wrlock: %s", strerror(error)); - RB_FOREACH_SAFE(repo, repo_tree, tree, trepo) { - RB_REMOVE(repo_tree, tree, repo); - free(repo->path); - free(repo->validpath); - free(repo); - } - if ((error = pthread_rwlock_unlock(&repos_lk)) != 0) - errx(1, "pthread_rwlock_unlock: %s", strerror(error)); - if ((error = pthread_rwlock_destroy(&repos_lk)) != 0) - errx(1, "pthread_rwlock_destroy: %s", strerror(error)); -} - /* * Process responsible for parsing and validating content. * All this process does is wait to be told about a file to parse, then