From nobody Thu Jan 26 19:48:05 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P2rpt1dvbz3bnXV; Thu, 26 Jan 2023 19:48:06 +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 4P2rps72N1z3DSq; Thu, 26 Jan 2023 19:48:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674762486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WLfAKY1CAsULtqb1MYSmPMIjPdJjGT8lSQ0Wz2ui9gw=; b=Q/tlKp1+3PjfaxjK+H/qPodBoHlzb1K7SnFum6uxJi+z7Q06FSboPRTzh9rkHQRC2EibZF GhnJYEaCxSvmoGc2C07FcJUBs03iGuUNexZbuwWDsWpcdz8U+dquj50OgMeYa1fcu/sWG4 k36DV3dlQD161ZFm3uImhhLIopZ6/dBQ5aQvqE86r2K+b0WWTCJ6HKoi+hJzbzIXYxmKVE l5IsbwzzTyEdP4kEbcViW/xg4BGBUNluDkfH83Ikyvwbxyd9X+4DiqdyY0+Gz5IgY3OQ+5 1kyuYgwlf71ZNRRFI8QQGHD3Wus45g+GTrXZcYLNVdWLLjFZ8SmsmCzOcuIyYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674762486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WLfAKY1CAsULtqb1MYSmPMIjPdJjGT8lSQ0Wz2ui9gw=; b=wpEED7EHeYyUPAqW3acK7WRXF33G/uGW6yDXXU7dFhPHUQu3Ez+dhCU2dUruNI/XbpLZt0 1EQpyp8YmNDKMOXN1YoEBcgKfwiw0YC2zpo7WMMXLjz25Mc3YkH/WxmtMppM+tGriWSOg2 OnwzkpGjBGtsxutTiv7nQzKpxtP6uxTgcfD79BBR5MAkSSKoaGiHqI3VUPZcixEx1KNtke NFucLJrJmG4lQk6U/0PR/99f9QqdiHe7yeT8P9b/VmpeTLpW69CymaAdJiABUBtbpoMOw6 tlExX/4XTa2ukP8QylExeqOpOe5Xpybqwpwhf5ibENXloS5oXWJrsM0pTfksIA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674762486; a=rsa-sha256; cv=none; b=tS9FZPum8QfpbV1jH9mOoX0+1hCurxy/H9Ulw5eYlpzt8cMkoZb38MY79mRRcEkV8/OXgh 5a++AiWCAa8xODuMpZEfkNGvsRfWGbIyvghRh1CzsubYgoH0IWaqAfovXuMOrhwytToDBt 85UtThH25Cx9Q97qyjjj3GUQjECaGVyGviR5VbF8JC7zogLXZNUYLBat7j9Kk3xffke8Sl UjGOCM0PuhrfJrKkVvetxut8lm5k94hrsE5HJi1LzPMbrBCyuyxGj348kjPl4DMpVnXBhJ QhZYP+vfp+N8zxiZPKnOZKRdeK4CRPrWQUHm3KB8095+rlx0YR7gvUpyS5truA== 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 4P2rps5fvHzhbc; Thu, 26 Jan 2023 19:48:05 +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 30QJm5HY007500; Thu, 26 Jan 2023 19:48:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30QJm5tD007499; Thu, 26 Jan 2023 19:48:05 GMT (envelope-from git) Date: Thu, 26 Jan 2023 19:48:05 GMT Message-Id: <202301261948.30QJm5tD007499@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: b728765f88dd - stable/13 - bhyve: Address warnings about potential unaligned accesses in fwctl.c List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b728765f88dde5b5454fac44dee2f7057d5bd85f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=b728765f88dde5b5454fac44dee2f7057d5bd85f commit b728765f88dde5b5454fac44dee2f7057d5bd85f Author: Mark Johnston AuthorDate: 2022-11-11 15:01:27 +0000 Commit: John Baldwin CommitDate: 2023-01-26 19:43:26 +0000 bhyve: Address warnings about potential unaligned accesses in fwctl.c This silences some warning about potential unaligned accesses. No functional change intended. MFC after: 1 week Reviewed by: corvink, jhb Differential Revision: https://reviews.freebsd.org/D37288 (cherry picked from commit f64f34380925a4ddaf1c140c35f46408b74110ac) --- usr.sbin/bhyve/fwctl.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/usr.sbin/bhyve/fwctl.c b/usr.sbin/bhyve/fwctl.c index 46010513b66a..f74380a426b2 100644 --- a/usr.sbin/bhyve/fwctl.c +++ b/usr.sbin/bhyve/fwctl.c @@ -88,20 +88,17 @@ static struct op_info *ops[OP_MAX+1]; /* Return 0-padded uint32_t */ static uint32_t -fwctl_send_rest(uint32_t *data, size_t len) +fwctl_send_rest(uint8_t *data, size_t len) { union { uint8_t c[4]; uint32_t w; } u; - uint8_t *cdata; size_t i; - cdata = (uint8_t *) data; u.w = 0; - - for (i = 0, u.w = 0; i < len; i++) - u.c[i] = *cdata++; + for (i = 0; i < len; i++) + u.c[i] = *data++; return (u.w); } @@ -203,7 +200,7 @@ static void fget_data(uint32_t data, uint32_t len __unused) { - *((uint32_t *) &fget_str[fget_cnt]) = data; + memcpy(&fget_str[fget_cnt], &data, sizeof(data)); fget_cnt += sizeof(uint32_t); } @@ -401,7 +398,7 @@ fwctl_request(uint32_t value) static int fwctl_response(uint32_t *retval) { - uint32_t *dp; + uint8_t *dp; ssize_t remlen; switch(rinfo.resp_count) { @@ -425,10 +422,9 @@ fwctl_response(uint32_t *retval) break; default: remlen = rinfo.resp_size - rinfo.resp_off; - dp = (uint32_t *) - ((uint8_t *)rinfo.resp_biov->iov_base + rinfo.resp_off); + dp = (uint8_t *)rinfo.resp_biov->iov_base + rinfo.resp_off; if (remlen >= (ssize_t)sizeof(uint32_t)) { - *retval = *dp; + memcpy(retval, dp, sizeof(uint32_t)); } else if (remlen > 0) { *retval = fwctl_send_rest(dp, remlen); }