git: e7cd5ffff88f - main - bhyve: Fix sign compare warnings in the e1000 device model.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 29 Nov 2022 01:10:54 UTC
The branch main has been updated by jhb:

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

commit e7cd5ffff88f1f4dfba2693041cc78fcf3613fba
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-11-29 01:08:09 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-11-29 01:08:09 +0000

    bhyve: Fix sign compare warnings in the e1000 device model.
    
    Adding a bare constant to a uint16_t promotes to a signed int which
    triggers these warnings.  Changing the constant to be explicitly
    unsigned instead promotes the expression to unsigned int.
    
    Reviewed by:    corvink, markj
    Differential Revision:  https://reviews.freebsd.org/D37485
---
 usr.sbin/bhyve/pci_e82545.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/usr.sbin/bhyve/pci_e82545.c b/usr.sbin/bhyve/pci_e82545.c
index 21e01b22ec4b..9d991b124965 100644
--- a/usr.sbin/bhyve/pci_e82545.c
+++ b/usr.sbin/bhyve/pci_e82545.c
@@ -1045,7 +1045,7 @@ e82545_transmit_checksum(struct iovec *iov, int iovcnt, struct ck_info *ck)
 
 	DPRINTF("tx cksum: iovcnt/s/off/len %d/%d/%d/%d",
 	    iovcnt, ck->ck_start, ck->ck_off, ck->ck_len);
-	cklen = ck->ck_len ? ck->ck_len - ck->ck_start + 1 : UINT_MAX;
+	cklen = ck->ck_len ? ck->ck_len - ck->ck_start + 1U : UINT_MAX;
 	cksum = e82545_iov_checksum(iov, iovcnt, ck->ck_start, cklen);
 	*(uint16_t *)((uint8_t *)iov[0].iov_base + ck->ck_off) = ~cksum;
 }
@@ -1231,9 +1231,9 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail,
 	if (!tso) {
 		/* Estimate required writable space for checksums. */
 		if (ckinfo[0].ck_valid)
-			hdrlen = MAX(hdrlen, ckinfo[0].ck_off + 2);
+			hdrlen = MAX(hdrlen, ckinfo[0].ck_off + 2U);
 		if (ckinfo[1].ck_valid)
-			hdrlen = MAX(hdrlen, ckinfo[1].ck_off + 2);
+			hdrlen = MAX(hdrlen, ckinfo[1].ck_off + 2U);
 		/* Round up writable space to the first vector. */
 		if (hdrlen != 0 && iov[0].iov_len > hdrlen &&
 		    iov[0].iov_len < hdrlen + 100)
@@ -1282,26 +1282,26 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail,
 		 * TCP    | flags | 13     | 1
 		 * UDP    | len   | 4      | 4
 		 */
-		if (hdrlen < ckinfo[0].ck_start + 6 ||
-		    hdrlen < ckinfo[0].ck_off + 2) {
+		if (hdrlen < ckinfo[0].ck_start + 6U ||
+		    hdrlen < ckinfo[0].ck_off + 2U) {
 			WPRINTF("TSO hdrlen too small for IP fields (%d) "
 			    "-- dropped", hdrlen);
 			goto done;
 		}
 		if (sc->esc_txctx.cmd_and_length & E1000_TXD_CMD_TCP) {
-			if (hdrlen < ckinfo[1].ck_start + 14) {
+			if (hdrlen < ckinfo[1].ck_start + 14U) {
 				WPRINTF("TSO hdrlen too small for TCP fields "
 				    "(%d) -- dropped", hdrlen);
 				goto done;
 			}
 		} else {
-			if (hdrlen < ckinfo[1].ck_start + 8) {
+			if (hdrlen < ckinfo[1].ck_start + 8U) {
 				WPRINTF("TSO hdrlen too small for UDP fields "
 				    "(%d) -- dropped", hdrlen);
 				goto done;
 			}
 		}
-		if (ckinfo[1].ck_valid && hdrlen < ckinfo[1].ck_off + 2) {
+		if (ckinfo[1].ck_valid && hdrlen < ckinfo[1].ck_off + 2U) {
 			WPRINTF("TSO hdrlen too small for TCP/UDP fields "
 			    "(%d) -- dropped", hdrlen);
 			goto done;