git: 2a21cfe60fcf - main - pctrie: avoid typecast

From: Doug Moore <dougm_at_FreeBSD.org>
Date: Fri, 14 Jun 2024 07:20:04 UTC
The branch main has been updated by dougm:

URL: https://cgit.FreeBSD.org/src/commit/?id=2a21cfe60fcf8e49dad60a9a40d2fc9e62cda563

commit 2a21cfe60fcf8e49dad60a9a40d2fc9e62cda563
Author:     Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2024-06-14 07:19:03 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2024-06-14 07:19:03 +0000

    pctrie: avoid typecast
    
    Have PCTRIE_RECLAIM_CALLBACK typecast one function pointer type to
    another, to relieve the writer of the call back function from having
    to cast its first argument from void* to member type.
    
    Reviewed by:    rlibby
    Differential Revision:  https://reviews.freebsd.org/D45586
---
 sys/kern/subr_rangeset.c | 3 +--
 sys/sys/pctrie.h         | 3 ++-
 sys/vm/swap_pager.c      | 3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/sys/kern/subr_rangeset.c b/sys/kern/subr_rangeset.c
index 94b77a449d22..ddb1839531ea 100644
--- a/sys/kern/subr_rangeset.c
+++ b/sys/kern/subr_rangeset.c
@@ -233,9 +233,8 @@ rangeset_remove(struct rangeset *rs, uint64_t start, uint64_t end)
 }
 
 static void
-rangeset_remove_leaf(void *rv, void *rsv)
+rangeset_remove_leaf(struct rs_el *r, void *rsv)
 {
-	struct rs_el *r = rv;
 	struct rangeset *rs = rsv;
 
 	rs->rs_free_data(rs->rs_data_ctx, r);
diff --git a/sys/sys/pctrie.h b/sys/sys/pctrie.h
index 4e1d8c7f8617..d06b533a54b7 100644
--- a/sys/sys/pctrie.h
+++ b/sys/sys/pctrie.h
@@ -226,9 +226,10 @@ name##_PCTRIE_RECLAIM(struct pctrie *ptree)				\
  */									\
 static __inline __unused void						\
 name##_PCTRIE_RECLAIM_CALLBACK(struct pctrie *ptree,			\
-    pctrie_cb_t callback, void *arg)					\
+    void (*typed_cb)(struct type *, void *), void *arg)			\
 {									\
 	struct pctrie_node *freenode, *node;				\
+	pctrie_cb_t callback = (pctrie_cb_t)typed_cb;			\
 									\
 	for (freenode = pctrie_reclaim_begin_cb(&node, ptree,		\
 	    callback, __offsetof(struct type, field), arg);		\
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index c339f70ddea1..455c39ab6fd7 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -2220,9 +2220,8 @@ swp_pager_meta_free(vm_object_t object, vm_pindex_t pindex, vm_pindex_t count,
 }
 
 static void
-swp_pager_meta_free_block(void *sbv, void *rangev)
+swp_pager_meta_free_block(struct swblk *sb, void *rangev)
 {
-	struct swblk *sb = sbv;
 	struct page_range *range = rangev;
 
 	for (int i = 0; i < SWAP_META_PAGES; i++) {