From owner-dev-commits-src-all@freebsd.org Thu Sep 23 01:03:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C5DA367643A; Thu, 23 Sep 2021 01:03:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HFH3x3Xvwz3wNg; Thu, 23 Sep 2021 01:03:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5990C21957; Thu, 23 Sep 2021 01:03:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18N13v4C073861; Thu, 23 Sep 2021 01:03:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18N13vdE073860; Thu, 23 Sep 2021 01:03:57 GMT (envelope-from git) Date: Thu, 23 Sep 2021 01:03:57 GMT Message-Id: <202109230103.18N13vdE073860@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 7683f19cbf40 - stable/13 - hkbd(4): Reduce diff with ukbd(4) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7683f19cbf40cd757bf514617a9dcbe938f2989a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2021 01:03:57 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=7683f19cbf40cd757bf514617a9dcbe938f2989a commit 7683f19cbf40cd757bf514617a9dcbe938f2989a Author: Vladimir Kondratyev AuthorDate: 2021-09-09 21:39:05 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-09-23 00:57:34 +0000 hkbd(4): Reduce diff with ukbd(4) (cherry picked from commit 3ef9023f935ff721f72ed44cf26911b9af72dba1) --- sys/dev/hid/hkbd.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sys/dev/hid/hkbd.c b/sys/dev/hid/hkbd.c index 55eba6d321ea..729602b12f3a 100644 --- a/sys/dev/hid/hkbd.c +++ b/sys/dev/hid/hkbd.c @@ -657,7 +657,6 @@ hkbd_intr_callback(void *context, void *data, hid_size_t len) uint32_t i; uint8_t id = 0; uint8_t modifiers; - int offset; HKBD_LOCK_ASSERT(sc); @@ -709,13 +708,15 @@ hkbd_intr_callback(void *context, void *data, hid_size_t len) } else if (id != sc->sc_id_loc_key[i]) { continue; /* invalid HID ID */ } else if (i == 0) { - offset = sc->sc_loc_key[0].count; - if (offset < 0 || offset > len) - offset = len; - while (offset--) { + struct hid_location tmp_loc = sc->sc_loc_key[0]; + /* range check array size */ + if (tmp_loc.count > HKBD_NKEYCODE) + tmp_loc.count = HKBD_NKEYCODE; + while (tmp_loc.count--) { uint32_t key = - hid_get_data(buf + offset, len - offset, - &sc->sc_loc_key[i]); + hid_get_udata(buf, len, &tmp_loc); + /* advance to next location */ + tmp_loc.pos += tmp_loc.size; if (key == KEY_ERROR) { DPRINTF("KEY_ERROR\n"); sc->sc_ndata = sc->sc_odata;