commit 41499e1536a5972223b1e902fad04b7f5f451935 from: smytht via: GitHub date: Tue Aug 08 21:33:34 2023 UTC Update stats.c compiler warnings diff nsh1.2.4/nsh/stats.c nsh1.2.2/nsh/stats.c > 781c781 > < int nmbtypes = sizeof(mbstat.m_mtypes) / sizeof(short); > --- > > int nmbtypes = sizeof(mbstat.m_mtypes) / sizeof(long); Your fix is correct. I would prefer an alternative fix which infers the size of array elements via the sizeof(array[0]) idiom: int nmbtypes = sizeof(mbstat.m_mtypes) / sizeof(mbstat.m_mtypes[0]); The above expression will remain correct regardless of any future element size changes. And since other nsh code is already using the OpenBSD-specific nitems() macro, which is a shorthand for the above idiom, we might as well use it to write the above expression in a more readable way: commit - a0faec76c1ca1d5e829f04d65b45b8c9d032383a commit + 41499e1536a5972223b1e902fad04b7f5f451935 blob - 8fc7ec538398cea9a0d4e2a87d378caf25b7ab6f blob + d339af083a825dd6016a0ddb1fcef2490bde9843 --- stats.c +++ stats.c @@ -778,7 +778,7 @@ mbpr(void) struct mbtypes *mp; size_t size; int page_size = getpagesize(); - int nmbtypes = sizeof(mbstat.m_mtypes) / sizeof(short); + int nmbtypes = nitems(mbstat.m_mtypes); memset(&seen, 0, sizeof(seen));