mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-24 07:40:52 +00:00
moused: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Pull Request: https://github.com/freebsd/freebsd-src/pull/888 Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
This commit is contained in:
parent
338d9c35d5
commit
83409a9357
@ -1033,7 +1033,7 @@ moused(void)
|
||||
bstate[i].count = 0;
|
||||
bstate[i].ts = mouse_button_state_ts;
|
||||
}
|
||||
for (i = 0; i < (int)(sizeof(zstate) / sizeof(zstate[0])); ++i) {
|
||||
for (i = 0; i < (int)nitems(zstate); ++i) {
|
||||
zstate[i].count = 0;
|
||||
zstate[i].ts = mouse_button_state_ts;
|
||||
}
|
||||
@ -1489,7 +1489,7 @@ r_identify(void)
|
||||
rodent.mode.level = 0;
|
||||
if (ioctl(rodent.mfd, MOUSE_GETMODE, &rodent.mode) == 0) {
|
||||
if (rodent.mode.protocol == MOUSE_PROTO_UNKNOWN ||
|
||||
rodent.mode.protocol >= (int)(sizeof(proto) / sizeof(proto[0]))) {
|
||||
rodent.mode.protocol >= (int)nitems(proto)) {
|
||||
logwarnx("unknown mouse protocol (%d)", rodent.mode.protocol);
|
||||
return (MOUSE_PROTO_UNKNOWN);
|
||||
} else {
|
||||
@ -1564,8 +1564,7 @@ r_name(int type)
|
||||
{
|
||||
const char *unknown = "unknown";
|
||||
|
||||
return (type == MOUSE_PROTO_UNKNOWN ||
|
||||
type >= (int)(sizeof(rnames) / sizeof(rnames[0])) ?
|
||||
return (type == MOUSE_PROTO_UNKNOWN || type >= (int)nitems(rnames) ?
|
||||
unknown : rnames[type]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user