From 3bc9a699ca7106204ffa97272374313bf04f6cc0 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 8 Aug 2023 01:25:50 +0200 Subject: Homogeneize [gs]et_translator and get_dire[nc]ts into mach_msg_type_number_t This makes netfs_[gs]et_translator use mach_msg_type_number_t like the RPC and diskfs. This also makes the fshelp_fetch_root_callback1_t for fshelp_fetch_root use mach_msg_type_number_t. This also makes procfs_get_translator and the get_translator proc method use mach_msg_type_number_t. This makes diskfs_get_directs use mach_msg_type_number_t like the dir_readdir RPC Also get rid of u_int. This notably fixes _diskfs_translator_callback1_fn's bogus cast of size_t *argz_len into (u_int *). --- hostmux/leaf.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'hostmux/leaf.c') diff --git a/hostmux/leaf.c b/hostmux/leaf.c index ebe9190e..ac32256f 100644 --- a/hostmux/leaf.c +++ b/hostmux/leaf.c @@ -40,7 +40,7 @@ netfs_attempt_readlink (struct iouser *user, struct node *node, char *buf) For hostmux, this creates a new translator string by instantiating the global translator template. */ error_t -netfs_get_translator (struct node *node, char **argz, size_t *argz_len) +netfs_get_translator (struct node *node, char **args, mach_msg_type_number_t *args_len) { if (! node->nn->name) return EINVAL; @@ -49,26 +49,28 @@ netfs_get_translator (struct node *node, char **argz, size_t *argz_len) error_t err = 0; unsigned replace_count = 0; struct hostmux *mux = node->nn->mux; - - *argz = 0; /* Initialize return value. */ - *argz_len = 0; + char *argz = 0; /* Initialize return value. */ + size_t argz_len = 0; /* Return a copy of MUX's translator template, with occurrences of HOST_PAT replaced by the canonical hostname. */ - err = argz_append (argz, argz_len, + err = argz_append (&argz, &argz_len, mux->trans_template, mux->trans_template_len); if (! err) - err = argz_replace (argz, argz_len, + err = argz_replace (&argz, &argz_len, mux->host_pat, node->nn->name->canon, &replace_count); if (!err && replace_count == 0) /* Default, if no instances of HOST_PAT occur, is to append the hostname. */ - err = argz_add (argz, argz_len, node->nn->name->canon); + err = argz_add (&argz, &argz_len, node->nn->name->canon); + + if (err && argz_len > 0) + free (argz); - if (err && *argz_len > 0) - free (*argz); + *args = argz; + *args_len = argz_len; return err; } -- cgit v1.2.3