The msg_bufl field of struct msgbuf is written but never read. The value was used by kernfs which is no longer present, so the code could be cleaned up a little by removing the field.
On some systems the message buffer data are preserved across a reboot. However, the preservation is best-effort only, and initmsgbuf() refuses to use the old data if the struct's size has changed. Changing the struct affects at least dmesg(8). The program has to be recompiled. OK? Index: kern/subr_log.c =================================================================== RCS file: src/sys/kern/subr_log.c,v retrieving revision 1.66 diff -u -p -r1.66 subr_log.c --- kern/subr_log.c 7 Apr 2020 13:27:51 -0000 1.66 +++ kern/subr_log.c 16 Aug 2020 10:57:59 -0000 @@ -151,7 +151,6 @@ msgbuf_putchar(struct msgbuf *mbp, const s = splhigh(); mbp->msg_bufc[mbp->msg_bufx++] = c; - mbp->msg_bufl = lmin(mbp->msg_bufl+1, mbp->msg_bufs); if (mbp->msg_bufx < 0 || mbp->msg_bufx >= mbp->msg_bufs) mbp->msg_bufx = 0; /* If the buffer is full, keep the most recent data. */ Index: sys/msgbuf.h =================================================================== RCS file: src/sys/sys/msgbuf.h,v retrieving revision 1.11 diff -u -p -r1.11 msgbuf.h --- sys/msgbuf.h 23 Jun 2016 13:15:21 -0000 1.11 +++ sys/msgbuf.h 16 Aug 2020 10:57:59 -0000 @@ -38,7 +38,6 @@ struct msgbuf { long msg_bufx; /* write pointer */ long msg_bufr; /* read pointer */ long msg_bufs; /* real msg_bufc size (bytes) */ - long msg_bufl; /* # chars, <= msg_bufs */ long msg_bufd; /* number of dropped bytes */ char msg_bufc[1]; /* buffer */ };