git: 03f7ccab3207 - main - bhyve: Avoid arithmetic on void pointers

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 25 Oct 2022 15:17:05 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=03f7ccab32078467ff0df14c7996747269a1962c

commit 03f7ccab32078467ff0df14c7996747269a1962c
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-10-25 13:07:14 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-10-25 15:16:56 +0000

    bhyve: Avoid arithmetic on void pointers
    
    No functional change intended.
    
    MFC after:      1 week
---
 usr.sbin/bhyve/block_if.c     |  5 +++--
 usr.sbin/bhyve/net_backends.c |  2 +-
 usr.sbin/bhyve/pci_ahci.c     | 10 ++++------
 usr.sbin/bhyve/pci_e82545.c   |  3 ++-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c
index 84877927b53e..b22ca140a80e 100644
--- a/usr.sbin/bhyve/block_if.c
+++ b/usr.sbin/bhyve/block_if.c
@@ -266,7 +266,7 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf)
 			do {
 				clen = MIN(len - boff, br->br_iov[i].iov_len -
 				    voff);
-				memcpy(br->br_iov[i].iov_base + voff,
+				memcpy((uint8_t *)br->br_iov[i].iov_base + voff,
 				    buf + boff, clen);
 				if (clen < br->br_iov[i].iov_len - voff)
 					voff += clen;
@@ -302,7 +302,8 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf)
 				clen = MIN(len - boff, br->br_iov[i].iov_len -
 				    voff);
 				memcpy(buf + boff,
-				    br->br_iov[i].iov_base + voff, clen);
+				    (uint8_t *)br->br_iov[i].iov_base + voff,
+				    clen);
 				if (clen < br->br_iov[i].iov_len - voff)
 					voff += clen;
 				else {
diff --git a/usr.sbin/bhyve/net_backends.c b/usr.sbin/bhyve/net_backends.c
index 8c6b226a455d..b5d320187088 100644
--- a/usr.sbin/bhyve/net_backends.c
+++ b/usr.sbin/bhyve/net_backends.c
@@ -738,7 +738,7 @@ netmap_send(struct net_backend *be, const struct iovec *iov,
 	int nm_buf_size;
 	int nm_buf_len;
 	uint32_t head;
-	void *nm_buf;
+	uint8_t *nm_buf;
 	int j;
 
 	ring = priv->tx;
diff --git a/usr.sbin/bhyve/pci_ahci.c b/usr.sbin/bhyve/pci_ahci.c
index 0d8cc3995711..d4000b7a63c6 100644
--- a/usr.sbin/bhyve/pci_ahci.c
+++ b/usr.sbin/bhyve/pci_ahci.c
@@ -785,12 +785,11 @@ ahci_handle_flush(struct ahci_port *p, int slot, uint8_t *cfis)
 }
 
 static inline void
-read_prdt(struct ahci_port *p, int slot, uint8_t *cfis,
-		void *buf, int size)
+read_prdt(struct ahci_port *p, int slot, uint8_t *cfis, void *buf, int size)
 {
 	struct ahci_cmd_hdr *hdr;
 	struct ahci_prdt_entry *prdt;
-	void *to;
+	uint8_t *to;
 	int i, len;
 
 	hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE);
@@ -899,12 +898,11 @@ next:
 }
 
 static inline void
-write_prdt(struct ahci_port *p, int slot, uint8_t *cfis,
-		void *buf, int size)
+write_prdt(struct ahci_port *p, int slot, uint8_t *cfis, void *buf, int size)
 {
 	struct ahci_cmd_hdr *hdr;
 	struct ahci_prdt_entry *prdt;
-	void *from;
+	uint8_t *from;
 	int i, len;
 
 	hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE);
diff --git a/usr.sbin/bhyve/pci_e82545.c b/usr.sbin/bhyve/pci_e82545.c
index 5b95b2d8318c..1591136002f6 100644
--- a/usr.sbin/bhyve/pci_e82545.c
+++ b/usr.sbin/bhyve/pci_e82545.c
@@ -1394,7 +1394,8 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail,
 		/* Include respective part of payload IOV. */
 		for (nleft = now; pv < iovcnt && nleft > 0; nleft -= nnow) {
 			nnow = MIN(nleft, iov[pv].iov_len - pvoff);
-			tiov[tiovcnt].iov_base = iov[pv].iov_base + pvoff;
+			tiov[tiovcnt].iov_base = (uint8_t *)iov[pv].iov_base +
+			    pvoff;
 			tiov[tiovcnt++].iov_len = nnow;
 			if (pvoff + nnow == iov[pv].iov_len) {
 				pv++;