Commit Diff
- Commit:
41499e1536a5972223b1e902fad04b7f5f451935
- From:
- smytht <smytht@users.noreply.github.com>
- Via:
- GitHub <noreply@github.com>
- Date:
- Message:
- 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:
- Actions:
- Patch | Tree
--- 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));