git: 94267fc90774 - main - vfs: use designated initializers for the typename array
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 26 Dec 2022 18:29:18 UTC
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=94267fc9077497bc2d70466f9e91d5b6eabb37a2 commit 94267fc9077497bc2d70466f9e91d5b6eabb37a2 Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2022-12-22 13:37:17 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2022-12-26 17:34:41 +0000 vfs: use designated initializers for the typename array While here prefix with v for better consistency with the vnode stuff. Reviewed by: kib (previous version) Differential Revision: https://reviews.freebsd.org/D37759 --- sys/kern/vfs_subr.c | 19 +++++++++++++++---- sys/sys/vnode.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 63a30cbbdb3d..3c9db6763c6b 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -4145,9 +4145,20 @@ vgonel(struct vnode *vp) /* * Print out a description of a vnode. */ -static const char * const typename[] = -{"VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD", - "VMARKER"}; +static const char *const vtypename[] = { + [VNON] = "VNON", + [VREG] = "VREG", + [VDIR] = "VDIR", + [VBLK] = "VBLK", + [VCHR] = "VCHR", + [VLNK] = "VLNK", + [VSOCK] = "VSOCK", + [VFIFO] = "VFIFO", + [VBAD] = "VBAD", + [VMARKER] = "VMARKER", +}; +_Static_assert(nitems(vtypename) == VLASTTYPE + 1, + "vnode type name not added to vtypename"); _Static_assert((VHOLD_ALL_FLAGS & ~VHOLD_NO_SMR) == 0, "new hold count flag not added to vn_printf"); @@ -4165,7 +4176,7 @@ vn_printf(struct vnode *vp, const char *fmt, ...) vprintf(fmt, ap); va_end(ap); printf("%p: ", (void *)vp); - printf("type %s\n", typename[vp->v_type]); + printf("type %s\n", vtypename[vp->v_type]); holdcnt = atomic_load_int(&vp->v_holdcnt); printf(" usecount %d, writecount %d, refcount %d seqc users %d", vp->v_usecount, vp->v_writecount, holdcnt & ~VHOLD_ALL_FLAGS, diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 89784dd4e455..5e609f810b8d 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -58,6 +58,7 @@ */ enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD, VMARKER }; +#define VLASTTYPE VMARKER enum vgetstate { VGET_NONE, VGET_HOLDCNT, VGET_USECOUNT }; /*