From nobody Thu Jan 26 19:48:01 2023 X-Original-To: dev-commits-src-branches@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 4P2rpn4pVPz3bnXL; Thu, 26 Jan 2023 19:48:01 +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 4P2rpn2nScz3DP7; Thu, 26 Jan 2023 19:48:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674762481; 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=ua7muQFN5Hs+vzRHmztwfXQGo61/spwblaqFSb36N2g=; b=hPHaUFT2v5hSNz2MIMNjtCrnNjQAoq9PGWrnJghwFUlBkq7/I9SKQ3LuAaf4kOEYPoRLga l7CECeaS0biHMchit2B5VNxYUaosawzwvKVHZz/9L8GD6q6GLIsDGVwcNgNkejhA5O1Und VkmGjdVPIbIeK0q33R1NQ9MbWbnNknACuLvmmhV1UfbjpmsH8uY2xoZG1IBtQQuWy5tYHb 8u1xXa7FPmzDmgRFDMDywBVQnHdbEBLYF/5x3zwlzU5wTQdIQywW6kf5XnXx/UQBzzcWj0 vw5ozzsTkl6AXp4+YZulRy3AsDenpugxvaq8srTxiStfDMDUGgcU5JxE1BqTHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674762481; 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=ua7muQFN5Hs+vzRHmztwfXQGo61/spwblaqFSb36N2g=; b=LeyGf000WHh5ubWybqst32FHmZa3knX7ltN935FWEGvpseQNuWvZTASd8JgVr92Rey3znG SqjDxnr6d9QkWjNZM7tKhfThRl2AXwhUX2LAWgCLvOa0hxQDBklRzKaaOoDmy/p/MgPx77 xYZEW61M4hHOCVpOoqPt50jybuJCakOtopqVKEEsu6VfkBR1I6JmdS7A0paeU0mAcBmrSs pRjxxKAKvA/0sKuq1Ecaej7QtUu3YITAbyXJSodh5ixjqYZ3Gc6WjAMZQcdAS8sw6uiraq Aik4tglw58pmgwSVAA9g/ogZgnD+emP027H/qM7Z+wemDtdom3LISNmHcAnFGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674762481; a=rsa-sha256; cv=none; b=tCBwwmcTCR33nel7OsZJaDMq+/+q9M3zv3E4G3Q5ZrhUNUN5dTap+8RwoC9Mr8zTKEb7ww 7sAGgM4EIHZRCVh2DSGogx0HZF9CEe/s1YA2+DePLjyy+7kT7WgTtkUKmHWu1/zN4wBO8z ouMGgqAzztxptBCwizajp5NgPInORyPxMQfrEQLq7O65tOrk2fS8zxHNdywlat3fibjOsv QA5706r+Mg7zvwrjCbho/6WN6PVyMXpXdjdihKqsaKdEWZtgEojH30OM2dZSFp6EEntn3k Z8FbaCLrTKqrfn7bu00OiUNY0ds/DBhxlFOOF34YpwFDBrejuf/jPTpqjMp9wg== 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 4P2rpn1HqTzhWg; Thu, 26 Jan 2023 19:48:01 +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 30QJm1uH007400; Thu, 26 Jan 2023 19:48:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30QJm1lX007398; Thu, 26 Jan 2023 19:48:01 GMT (envelope-from git) Date: Thu, 26 Jan 2023 19:48:01 GMT Message-Id: <202301261948.30QJm1lX007398@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: a48715b58c5a - stable/13 - bhyve: Address some signed/unsigned comparison warnings List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: a48715b58c5adb009649fc64222c18328425b957 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a48715b58c5adb009649fc64222c18328425b957 commit a48715b58c5adb009649fc64222c18328425b957 Author: Mark Johnston AuthorDate: 2022-10-23 14:32:45 +0000 Commit: John Baldwin CommitDate: 2023-01-26 19:43:04 +0000 bhyve: Address some signed/unsigned comparison warnings MFC after: 1 week (cherry picked from commit ed7216843133c9d6748251b5e180ee90410131f0) --- sys/amd64/vmm/vmm_instruction_emul.c | 4 ++-- usr.sbin/bhyve/bhyverun.c | 2 +- usr.sbin/bhyve/block_if.c | 6 ++--- usr.sbin/bhyve/fwctl.c | 4 ++-- usr.sbin/bhyve/gdb.c | 10 ++++---- usr.sbin/bhyve/net_backends.c | 6 ++--- usr.sbin/bhyve/pci_e82545.c | 2 +- usr.sbin/bhyve/pci_emul.c | 9 +++++--- usr.sbin/bhyve/pci_hda.c | 5 ++-- usr.sbin/bhyve/pci_irq.c | 44 ++++++++++++++++++++---------------- usr.sbin/bhyve/pci_nvme.c | 2 +- usr.sbin/bhyve/pci_passthru.c | 4 ++-- usr.sbin/bhyve/pci_virtio_input.c | 2 +- usr.sbin/bhyve/pci_xhci.c | 5 ++-- usr.sbin/bhyve/snapshot.c | 13 +++++++---- usr.sbin/bhyve/task_switch.c | 2 +- usr.sbin/bhyve/uart_emul.c | 2 +- usr.sbin/bhyve/virtio.c | 2 +- 18 files changed, 68 insertions(+), 56 deletions(-) diff --git a/sys/amd64/vmm/vmm_instruction_emul.c b/sys/amd64/vmm/vmm_instruction_emul.c index 0474147e68ff..3b48eee2d8ed 100644 --- a/sys/amd64/vmm/vmm_instruction_emul.c +++ b/sys/amd64/vmm/vmm_instruction_emul.c @@ -1330,8 +1330,8 @@ emulate_bextr(void *vm, int vcpuid, uint64_t gpa, struct vie *vie, mem_region_write_t memwrite __unused, void *arg) { uint64_t src1, src2, dst, rflags; - unsigned start, len; - int error, size; + unsigned start, len, size; + int error; size = vie->opsize; error = EINVAL; diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 6b0b61cc897c..4abdf8fe301e 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -372,7 +372,7 @@ calc_topology(void) (uintmax_t)ncpus); if (explicit_cpus) { - if (guest_ncpus != ncpus) + if (guest_ncpus != (int)ncpus) errx(4, "Topology (%d sockets, %d cores, %d threads) " "does not match %d vCPUs", cpu_sockets, cpu_cores, cpu_threads, diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c index a13f7f0744c6..f2e60f865f78 100644 --- a/usr.sbin/bhyve/block_if.c +++ b/usr.sbin/bhyve/block_if.c @@ -900,10 +900,10 @@ blockif_chs(struct blockif_ctxt *bc, uint16_t *c, uint8_t *h, uint8_t *s) sectors = bc->bc_size / bc->bc_sectsz; /* Clamp the size to the largest possible with CHS */ - if (sectors > 65535UL*16*255) - sectors = 65535UL*16*255; + if (sectors > 65535L * 16 * 255) + sectors = 65535L * 16 * 255; - if (sectors >= 65536UL*16*63) { + if (sectors >= 65536L * 16 * 63) { secpt = 255; heads = 16; hcyl = sectors / secpt; diff --git a/usr.sbin/bhyve/fwctl.c b/usr.sbin/bhyve/fwctl.c index b4bfecb2bedd..46010513b66a 100644 --- a/usr.sbin/bhyve/fwctl.c +++ b/usr.sbin/bhyve/fwctl.c @@ -95,7 +95,7 @@ fwctl_send_rest(uint32_t *data, size_t len) uint32_t w; } u; uint8_t *cdata; - int i; + size_t i; cdata = (uint8_t *) data; u.w = 0; @@ -427,7 +427,7 @@ fwctl_response(uint32_t *retval) remlen = rinfo.resp_size - rinfo.resp_off; dp = (uint32_t *) ((uint8_t *)rinfo.resp_biov->iov_base + rinfo.resp_off); - if (remlen >= sizeof(uint32_t)) { + if (remlen >= (ssize_t)sizeof(uint32_t)) { *retval = *dp; } else if (remlen > 0) { *retval = fwctl_send_rest(dp, remlen); diff --git a/usr.sbin/bhyve/gdb.c b/usr.sbin/bhyve/gdb.c index cf0d5995a5d3..6368d5cc79a9 100644 --- a/usr.sbin/bhyve/gdb.c +++ b/usr.sbin/bhyve/gdb.c @@ -958,7 +958,6 @@ static void gdb_read_regs(void) { uint64_t regvals[nitems(gdb_regset)]; - int i; if (vm_get_register_set(ctx, cur_vcpu, nitems(gdb_regset), gdb_regset, regvals) == -1) { @@ -966,7 +965,7 @@ gdb_read_regs(void) return; } start_packet(); - for (i = 0; i < nitems(regvals); i++) + for (size_t i = 0; i < nitems(regvals); i++) append_unsigned_native(regvals[i], gdb_regsize[i]); finish_packet(); } @@ -1706,13 +1705,16 @@ check_command(int fd) static void gdb_readable(int fd, enum ev_type event __unused, void *arg __unused) { + size_t pending; ssize_t nread; - int pending; + int n; - if (ioctl(fd, FIONREAD, &pending) == -1) { + if (ioctl(fd, FIONREAD, &n) == -1) { warn("FIONREAD on GDB socket"); return; } + assert(n >= 0); + pending = n; /* * 'pending' might be zero due to EOF. We need to call read diff --git a/usr.sbin/bhyve/net_backends.c b/usr.sbin/bhyve/net_backends.c index d974936d9292..5dd5f8a17d66 100644 --- a/usr.sbin/bhyve/net_backends.c +++ b/usr.sbin/bhyve/net_backends.c @@ -229,7 +229,7 @@ tap_init(struct net_backend *be, const char *devname, int opt = 1; #if defined(INET6) || defined(INET) struct ifreq ifrq; - int i, s; + int s; #endif #ifndef WITHOUT_CAPSICUM cap_rights_t rights; @@ -270,7 +270,7 @@ tap_init(struct net_backend *be, const char *devname, } s = -1; - for (i = 0; s == -1 && i < nitems(pf_list); i++) + for (size_t i = 0; s == -1 && i < nitems(pf_list); i++) s = socket(pf_list[i], SOCK_DGRAM, 0); if (s == -1) { WPRINTF(("Could open socket")); @@ -651,7 +651,7 @@ netmap_set_vnet_hdr_len(struct net_backend *be, int vnet_hdr_len) static int netmap_has_vnet_hdr_len(struct net_backend *be, unsigned vnet_hdr_len) { - int prev_hdr_len = be->be_vnet_hdr_len; + unsigned prev_hdr_len = be->be_vnet_hdr_len; int ret; if (vnet_hdr_len == prev_hdr_len) { diff --git a/usr.sbin/bhyve/pci_e82545.c b/usr.sbin/bhyve/pci_e82545.c index 22127eb2208a..21e01b22ec4b 100644 --- a/usr.sbin/bhyve/pci_e82545.c +++ b/usr.sbin/bhyve/pci_e82545.c @@ -2442,7 +2442,7 @@ e82545_snapshot(struct vm_snapshot_meta *meta) true, meta, ret, done); /* L2 frame acceptance */ - for (i = 0; i < nitems(sc->esc_uni); i++) { + for (i = 0; i < (int)nitems(sc->esc_uni); i++) { SNAPSHOT_VAR_OR_LEAVE(sc->esc_uni[i].eu_valid, meta, ret, done); SNAPSHOT_VAR_OR_LEAVE(sc->esc_uni[i].eu_addrsel, meta, ret, done); SNAPSHOT_VAR_OR_LEAVE(sc->esc_uni[i].eu_eth, meta, ret, done); diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index 6e584d0b6626..b22238ab37fd 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -455,10 +455,13 @@ pci_emul_io_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, uint64_t offset; int i; + assert(port >= 0); + for (i = 0; i <= PCI_BARMAX; i++) { if (pdi->pi_bar[i].type == PCIBAR_IO && - port >= pdi->pi_bar[i].addr && - port + bytes <= pdi->pi_bar[i].addr + pdi->pi_bar[i].size) { + (uint64_t)port >= pdi->pi_bar[i].addr && + (uint64_t)port + bytes <= + pdi->pi_bar[i].addr + pdi->pi_bar[i].size) { offset = port - pdi->pi_bar[i].addr; if (in) *eax = (*pe->pe_barread)(ctx, vcpu, pdi, i, @@ -2298,7 +2301,7 @@ pci_snapshot_pci_dev(struct vm_snapshot_meta *meta) SNAPSHOT_BUF_OR_LEAVE(pi->pi_cfgdata, sizeof(pi->pi_cfgdata), meta, ret, done); - for (i = 0; i < nitems(pi->pi_bar); i++) { + for (i = 0; i < (int)nitems(pi->pi_bar); i++) { SNAPSHOT_VAR_OR_LEAVE(pi->pi_bar[i].type, meta, ret, done); SNAPSHOT_VAR_OR_LEAVE(pi->pi_bar[i].size, meta, ret, done); SNAPSHOT_VAR_OR_LEAVE(pi->pi_bar[i].addr, meta, ret, done); diff --git a/usr.sbin/bhyve/pci_hda.c b/usr.sbin/bhyve/pci_hda.c index dc6493868093..e6e4ae4ca27d 100644 --- a/usr.sbin/bhyve/pci_hda.c +++ b/usr.sbin/bhyve/pci_hda.c @@ -615,7 +615,6 @@ hda_stream_start(struct hda_softc *sc, uint8_t stream_ind) uint32_t sdctl = 0; uint8_t strm = 0; uint8_t dir = 0; - int i; assert(!st->run); @@ -640,7 +639,7 @@ hda_stream_start(struct hda_softc *sc, uint8_t stream_ind) st->bdl_cnt = bdl_cnt; bdle = (struct hda_bdle *)bdl_vaddr; - for (i = 0; i < bdl_cnt; i++, bdle++) { + for (size_t i = 0; i < bdl_cnt; i++, bdle++) { bdle_sz = bdle->len; assert(!(bdle_sz % HDA_DMA_ACCESS_LEN)); @@ -659,7 +658,7 @@ hda_stream_start(struct hda_softc *sc, uint8_t stream_ind) bdle_desc->len = bdle_sz; bdle_desc->ioc = bdle->ioc; - DPRINTF("bdle: 0x%x bdle_sz: 0x%x", i, bdle_sz); + DPRINTF("bdle: 0x%zx bdle_sz: 0x%x", i, bdle_sz); } sdctl = hda_get_reg_by_offset(sc, off + HDAC_SDCTL0); diff --git a/usr.sbin/bhyve/pci_irq.c b/usr.sbin/bhyve/pci_irq.c index ff41f6ec88dc..2ce962cdec44 100644 --- a/usr.sbin/bhyve/pci_irq.c +++ b/usr.sbin/bhyve/pci_irq.c @@ -63,14 +63,16 @@ __FBSDID("$FreeBSD$"); /* IRQ count to disable an IRQ. */ #define IRQ_DISABLED 0xff +#define NPIRQS 8 static struct pirq { uint8_t reg; int use_count; int active_count; pthread_mutex_t lock; -} pirqs[8]; +} pirqs[NPIRQS]; -static u_char irq_counts[16]; +#define NIRQ_COUNTS 16 +static u_char irq_counts[NIRQ_COUNTS]; static int pirq_cold = 1; /* @@ -91,7 +93,7 @@ uint8_t pirq_read(int pin) { - assert(pin > 0 && pin <= nitems(pirqs)); + assert(pin > 0 && pin <= NPIRQS); return (pirqs[pin - 1].reg); } @@ -100,7 +102,7 @@ pirq_write(struct vmctx *ctx, int pin, uint8_t val) { struct pirq *pirq; - assert(pin > 0 && pin <= nitems(pirqs)); + assert(pin > 0 && pin <= NPIRQS); pirq = &pirqs[pin - 1]; pthread_mutex_lock(&pirq->lock); if (pirq->reg != (val & (PIRQ_DIS | PIRQ_IRQ))) { @@ -117,7 +119,7 @@ void pci_irq_reserve(int irq) { - assert(irq >= 0 && irq < nitems(irq_counts)); + assert(irq >= 0 && irq < NIRQ_COUNTS); assert(pirq_cold); assert(irq_counts[irq] == 0 || irq_counts[irq] == IRQ_DISABLED); irq_counts[irq] = IRQ_DISABLED; @@ -127,7 +129,7 @@ void pci_irq_use(int irq) { - assert(irq >= 0 && irq < nitems(irq_counts)); + assert(irq >= 0 && irq < NIRQ_COUNTS); assert(pirq_cold); assert(irq_counts[irq] != IRQ_DISABLED); irq_counts[irq]++; @@ -138,13 +140,13 @@ pci_irq_init(struct vmctx *ctx __unused) { int i; - for (i = 0; i < nitems(pirqs); i++) { + for (i = 0; i < NPIRQS; i++) { pirqs[i].reg = PIRQ_DIS; pirqs[i].use_count = 0; pirqs[i].active_count = 0; pthread_mutex_init(&pirqs[i].lock, NULL); } - for (i = 0; i < nitems(irq_counts); i++) { + for (i = 0; i < NIRQ_COUNTS; i++) { if (IRQ_PERMITTED(i)) irq_counts[i] = 0; else @@ -156,10 +158,12 @@ void pci_irq_assert(struct pci_devinst *pi) { struct pirq *pirq; + int pin; - if (pi->pi_lintr.pirq_pin > 0) { - assert(pi->pi_lintr.pirq_pin <= nitems(pirqs)); - pirq = &pirqs[pi->pi_lintr.pirq_pin - 1]; + pin = pi->pi_lintr.pirq_pin; + if (pin > 0) { + assert(pin <= NPIRQS); + pirq = &pirqs[pin - 1]; pthread_mutex_lock(&pirq->lock); pirq->active_count++; if (pirq->active_count == 1 && pirq_valid_irq(pirq->reg)) { @@ -177,10 +181,12 @@ void pci_irq_deassert(struct pci_devinst *pi) { struct pirq *pirq; + int pin; - if (pi->pi_lintr.pirq_pin > 0) { - assert(pi->pi_lintr.pirq_pin <= nitems(pirqs)); - pirq = &pirqs[pi->pi_lintr.pirq_pin - 1]; + pin = pi->pi_lintr.pirq_pin; + if (pin > 0) { + assert(pin <= NPIRQS); + pirq = &pirqs[pin - 1]; pthread_mutex_lock(&pirq->lock); pirq->active_count--; if (pirq->active_count == 0 && pirq_valid_irq(pirq->reg)) { @@ -209,7 +215,7 @@ pirq_alloc_pin(struct pci_devinst *pi) /* Find the least-used PIRQ pin. */ best_pin = 0; best_count = pirqs[0].use_count; - for (pin = 1; pin < nitems(pirqs); pin++) { + for (pin = 1; pin < NPIRQS; pin++) { if (pirqs[pin].use_count < best_count) { best_pin = pin; best_count = pirqs[pin].use_count; @@ -222,7 +228,7 @@ pirq_alloc_pin(struct pci_devinst *pi) if (pirqs[best_pin].reg == PIRQ_DIS) { best_irq = -1; best_count = 0; - for (irq = 0; irq < nitems(irq_counts); irq++) { + for (irq = 0; irq < NIRQ_COUNTS; irq++) { if (irq_counts[irq] == IRQ_DISABLED) continue; if (best_irq == -1 || irq_counts[irq] < best_count) { @@ -242,7 +248,7 @@ pirq_alloc_pin(struct pci_devinst *pi) int pirq_irq(int pin) { - assert(pin > 0 && pin <= nitems(pirqs)); + assert(pin > 0 && pin <= NPIRQS); return (pirqs[pin - 1].reg & PIRQ_IRQ); } @@ -255,7 +261,7 @@ pirq_dsdt(void) int irq, pin; irq_prs = NULL; - for (irq = 0; irq < nitems(irq_counts); irq++) { + for (irq = 0; irq < NIRQ_COUNTS; irq++) { if (!IRQ_PERMITTED(irq)) continue; if (irq_prs == NULL) @@ -294,7 +300,7 @@ pirq_dsdt(void) dsdt_line(" Return (0x01)"); dsdt_line("}"); - for (pin = 0; pin < nitems(pirqs); pin++) { + for (pin = 0; pin < NPIRQS; pin++) { dsdt_line(""); dsdt_line("Device (LNK%c)", 'A' + pin); dsdt_line("{"); diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c index 2bb3f0f8a7d5..0c30f2cb7ff9 100644 --- a/usr.sbin/bhyve/pci_nvme.c +++ b/usr.sbin/bhyve/pci_nvme.c @@ -3292,7 +3292,7 @@ pci_nvme_init(struct vmctx *ctx __unused, struct pci_devinst *pi, nvlist_t *nvl) STAILQ_INIT(&sc->ioreqs_free); sc->ioreqs = calloc(sc->ioslots, sizeof(struct pci_nvme_ioreq)); - for (int i = 0; i < sc->ioslots; i++) { + for (uint32_t i = 0; i < sc->ioslots; i++) { STAILQ_INSERT_TAIL(&sc->ioreqs_free, &sc->ioreqs[i], link); } diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c index c153fe7df224..049b49b67c60 100644 --- a/usr.sbin/bhyve/pci_passthru.c +++ b/usr.sbin/bhyve/pci_passthru.c @@ -183,7 +183,7 @@ write_config(const struct pcisel *sel, long reg, int width, uint32_t data) static int passthru_add_msicap(struct pci_devinst *pi, int msgnum, int nextptr) { - int capoff, i; + int capoff; struct msicap msicap; u_char *capdata; @@ -197,7 +197,7 @@ passthru_add_msicap(struct pci_devinst *pi, int msgnum, int nextptr) */ capoff = 256 - roundup(sizeof(msicap), 4); capdata = (u_char *)&msicap; - for (i = 0; i < sizeof(msicap); i++) + for (size_t i = 0; i < sizeof(msicap); i++) pci_set_cfgdata8(pi, capoff + i, capdata[i]); return (capoff); diff --git a/usr.sbin/bhyve/pci_virtio_input.c b/usr.sbin/bhyve/pci_virtio_input.c index 77cbcf3aa0cf..1e7726dfc101 100644 --- a/usr.sbin/bhyve/pci_virtio_input.c +++ b/usr.sbin/bhyve/pci_virtio_input.c @@ -421,7 +421,7 @@ pci_vtinput_cfgread(void *vsc, int offset, int size, uint32_t *retval) struct pci_vtinput_softc *sc = vsc; /* check for valid offset and size */ - if (offset + size > sizeof(struct vtinput_config)) { + if (offset + size > (int)sizeof(struct vtinput_config)) { WPRINTF(("%s: read to invalid offset/size %d/%d", __func__, offset, size)); memset(retval, 0, size); diff --git a/usr.sbin/bhyve/pci_xhci.c b/usr.sbin/bhyve/pci_xhci.c index 71ef0b03f192..1f3d78a4cfea 100644 --- a/usr.sbin/bhyve/pci_xhci.c +++ b/usr.sbin/bhyve/pci_xhci.c @@ -650,8 +650,7 @@ pci_xhci_init_ep(struct pci_xhci_dev_emu *dev, int epid) struct xhci_dev_ctx *dev_ctx; struct pci_xhci_dev_ep *devep; struct xhci_endp_ctx *ep_ctx; - uint32_t pstreams; - int i; + uint32_t i, pstreams; dev_ctx = dev->dev_ctx; ep_ctx = &dev_ctx->ctx_ep[epid]; @@ -2102,7 +2101,7 @@ pci_xhci_rtsregs_write(struct pci_xhci_softc *sc, uint64_t offset, if (rts->er_events_cnt > 0) { uint64_t erdp; - uint32_t erdp_i; + int erdp_i; erdp = rts->intrreg.erdp & ~0xF; erdp_i = (erdp - rts->erstba_p->qwEvrsTablePtr) / diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index 7c2372a290c6..6f4e3c1f91a2 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -450,7 +450,8 @@ lookup_struct(enum snapshot_req struct_id, struct restore_state *rstate, JSON_GET_INT_OR_RETURN(JSON_FILE_OFFSET_KEY, obj, &file_offset, NULL); assert(file_offset >= 0); - assert(file_offset + size <= rstate->kdata_len); + assert((uint64_t)file_offset + size <= + rstate->kdata_len); *struct_size = (size_t)size; return ((uint8_t *)rstate->kdata_map + file_offset); @@ -479,7 +480,7 @@ lookup_check_dev(const char *dev_name, struct restore_state *rstate, JSON_GET_INT_OR_RETURN(JSON_FILE_OFFSET_KEY, obj, &file_offset, NULL); assert(file_offset >= 0); - assert(file_offset + size <= rstate->kdata_len); + assert((uint64_t)file_offset + size <= rstate->kdata_len); *data_size = (size_t)size; return ((uint8_t *)rstate->kdata_map + file_offset); @@ -1046,8 +1047,9 @@ vm_snapshot_kern_struct(int data_fd, xo_handle_t *xop, const char *array_key, data_size = vm_get_snapshot_size(meta); + /* XXX-MJ no handling for short writes. */ write_cnt = write(data_fd, meta->buffer.buf_start, data_size); - if (write_cnt != data_size) { + if (write_cnt < 0 || (size_t)write_cnt != data_size) { perror("Failed to write all snapshotted data."); ret = -1; goto done; @@ -1138,13 +1140,14 @@ static int vm_snapshot_dev_write_data(int data_fd, xo_handle_t *xop, const char *array_key, struct vm_snapshot_meta *meta, off_t *offset) { - int ret; + ssize_t ret; size_t data_size; data_size = vm_get_snapshot_size(meta); + /* XXX-MJ no handling for short writes. */ ret = write(data_fd, meta->buffer.buf_start, data_size); - if (ret != data_size) { + if (ret < 0 || (size_t)ret != data_size) { perror("Failed to write all snapshotted data."); return (-1); } diff --git a/usr.sbin/bhyve/task_switch.c b/usr.sbin/bhyve/task_switch.c index f1b564d560c5..78dfb8190e48 100644 --- a/usr.sbin/bhyve/task_switch.c +++ b/usr.sbin/bhyve/task_switch.c @@ -774,7 +774,7 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) minlimit = 0; assert(minlimit > 0); - if (nt.limit < minlimit) { + if (nt.limit < (unsigned int)minlimit) { sel_exception(ctx, vcpu, IDT_TS, nt_sel, ext); goto done; } diff --git a/usr.sbin/bhyve/uart_emul.c b/usr.sbin/bhyve/uart_emul.c index 725a789a5898..1539c7ffa135 100644 --- a/usr.sbin/bhyve/uart_emul.c +++ b/usr.sbin/bhyve/uart_emul.c @@ -616,7 +616,7 @@ int uart_legacy_alloc(int which, int *baseaddr, int *irq) { - if (which < 0 || which >= UART_NLDEVS || uart_lres[which].inuse) + if (which < 0 || which >= (int)UART_NLDEVS || uart_lres[which].inuse) return (-1); uart_lres[which].inuse = true; diff --git a/usr.sbin/bhyve/virtio.c b/usr.sbin/bhyve/virtio.c index 436ad0bf53aa..dc3a2d10d5b5 100644 --- a/usr.sbin/bhyve/virtio.c +++ b/usr.sbin/bhyve/virtio.c @@ -772,7 +772,7 @@ bad: vs->vs_curq = value; break; case VIRTIO_PCI_QUEUE_NOTIFY: - if (value >= vc->vc_nvq) { + if (value >= (unsigned int)vc->vc_nvq) { EPRINTLN("%s: queue %d notify out of range", name, (int)value); goto done;