diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2015-07-15 14:15:47 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2015-07-15 14:15:47 +0000 |
commit | ff38cdef117670e8307755537aa36200ceb3df6c (patch) | |
tree | a63f3347cbf6da728c696deff2202fe19f73c760 /sys/dev | |
parent | d3a095a9ec9be556ffc04bd4b090f5075efe6c5f (diff) |
Use mallocarray() and unsigned integers.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/hidkbd.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/sys/dev/usb/hidkbd.c b/sys/dev/usb/hidkbd.c index bd216156940..f22583472e4 100644 --- a/sys/dev/usb/hidkbd.c +++ b/sys/dev/usb/hidkbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hidkbd.c,v 1.15 2015/07/15 13:14:17 miod Exp $ */ +/* $OpenBSD: hidkbd.c,v 1.16 2015/07/15 14:15:46 miod Exp $ */ /* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -552,7 +552,7 @@ hidkbd_parse_desc(struct hidkbd *kbd, int id, void *desc, int dlen) { struct hid_data *d; struct hid_item h; - int i, ivar = 0; + unsigned int i, ivar = 0; kbd->sc_nkeycode = 0; @@ -573,9 +573,8 @@ hidkbd_parse_desc(struct hidkbd *kbd, int id, void *desc, int dlen) } kbd->sc_nvar = ivar; - kbd->sc_var = (struct hidkbd_variable *)malloc( - sizeof(struct hidkbd_variable) * ivar, M_DEVBUF, - M_NOWAIT); + kbd->sc_var = (struct hidkbd_variable *)mallocarray(ivar, + sizeof(struct hidkbd_variable), M_DEVBUF, M_NOWAIT); if (!kbd->sc_var) return NULL; @@ -599,7 +598,7 @@ hidkbd_parse_desc(struct hidkbd *kbd, int id, void *desc, int dlen) } /* variable report */ - if (i <= MAXVARS) { + if (i < MAXVARS) { kbd->sc_var[i].loc = h.loc; kbd->sc_var[i].mask = 1 << (i % 8); kbd->sc_var[i].key = HID_GET_USAGE(h.usage); |