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
This commit is contained in:
Mateusz Guzik 2022-12-22 13:37:17 +00:00
parent 4c8a257810
commit 94267fc907
2 changed files with 16 additions and 4 deletions

View File

@ -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,

View File

@ -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 };
/*