Module Name:    src
Committed By:   rin
Date:           Wed Feb  6 22:54:41 UTC 2019

Modified Files:
        src/sys/dev/usb: if_mue.c if_ure.c

Log Message:
Fix sign compare differently; instead of casting from int to unsigned,
casting from sizeof (and friends) to int.

Suggested by joerg@.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/usb/if_mue.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/usb/if_ure.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_mue.c
diff -u src/sys/dev/usb/if_mue.c:1.40 src/sys/dev/usb/if_mue.c:1.41
--- src/sys/dev/usb/if_mue.c:1.40	Wed Feb  6 22:42:11 2019
+++ src/sys/dev/usb/if_mue.c	Wed Feb  6 22:54:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mue.c,v 1.40 2019/02/06 22:42:11 rin Exp $	*/
+/*	$NetBSD: if_mue.c,v 1.41 2019/02/06 22:54:41 rin Exp $	*/
 /*	$OpenBSD: if_mue.c,v 1.3 2018/08/04 16:42:46 jsg Exp $	*/
 
 /*
@@ -20,7 +20,7 @@
 /* Driver for Microchip LAN7500/LAN7800 chipsets. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.40 2019/02/06 22:42:11 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.41 2019/02/06 22:54:41 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1240,8 +1240,7 @@ mue_encap(struct mue_softc *sc, struct m
 		      M_CSUM_TCPv6 | M_CSUM_UDPv6);
 
 	len = m->m_pkthdr.len;
-	if (__predict_false((!tso && 
-				(unsigned)len > MUE_FRAME_LEN(ifp->if_mtu)) ||
+	if (__predict_false((!tso && len > (int)MUE_FRAME_LEN(ifp->if_mtu)) ||
 			    ( tso && len > MUE_TSO_FRAME_LEN))) {
 		MUE_PRINTF(sc, "packet length %d\n too long", len);
 		return EINVAL;
@@ -1306,7 +1305,7 @@ mue_prepare_tso(struct mue_softc *sc, st
 	uint16_t type, len = 0;
 	int off;
 
-	if (__predict_true((unsigned)m->m_len >= sizeof(*eh))) {
+	if (__predict_true(m->m_len >= (int)sizeof(*eh))) {
 		eh = mtod(m, struct ether_header *);
 		type = eh->ether_type;
 	} else
@@ -1329,14 +1328,14 @@ mue_prepare_tso(struct mue_softc *sc, st
 	}
 
 	if (m->m_pkthdr.csum_flags & M_CSUM_TSOv4) {
-		if (__predict_true((unsigned)m->m_len >= off + sizeof(*ip))) {
+		if (__predict_true(m->m_len >= off + (int)sizeof(*ip))) {
 			ip = (void *)(mtod(m, char *) + off);
 			ip->ip_len = 0;
 		} else
 			m_copyback(m, off + offsetof(struct ip, ip_len),
 			    sizeof(len), &len);
 	} else {
-		if (__predict_true((unsigned)m->m_len >= off + sizeof(*ip6))) {
+		if (__predict_true(m->m_len >= off + (int)sizeof(*ip6))) {
 			ip6 = (void *)(mtod(m, char *) + off);
 			ip6->ip6_plen = 0;
 		} else
@@ -1822,7 +1821,7 @@ mue_start(struct ifnet *ifp)
 	}
 
 	idx = cd->mue_tx_prod;
-	while ((unsigned)cd->mue_tx_cnt < sc->mue_tx_list_cnt) {
+	while (cd->mue_tx_cnt < (int)sc->mue_tx_list_cnt) {
 		IFQ_POLL(&ifp->if_snd, m);
 		if (m == NULL)
 			break;
@@ -1842,7 +1841,7 @@ mue_start(struct ifnet *ifp)
 	}
 	cd->mue_tx_prod = idx;
 
-	if ((unsigned)cd->mue_tx_cnt >= sc->mue_tx_list_cnt)
+	if (cd->mue_tx_cnt >= (int)sc->mue_tx_list_cnt)
 		ifp->if_flags |= IFF_OACTIVE;
 
 	/* Set a timeout in case the chip goes out to lunch. */

Index: src/sys/dev/usb/if_ure.c
diff -u src/sys/dev/usb/if_ure.c:1.1 src/sys/dev/usb/if_ure.c:1.2
--- src/sys/dev/usb/if_ure.c:1.1	Wed Feb  6 11:55:06 2019
+++ src/sys/dev/usb/if_ure.c	Wed Feb  6 22:54:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ure.c,v 1.1 2019/02/06 11:55:06 rin Exp $	*/
+/*	$NetBSD: if_ure.c,v 1.2 2019/02/06 22:54:41 rin Exp $	*/
 /*	$OpenBSD: if_ure.c,v 1.10 2018/11/02 21:32:30 jcs Exp $	*/
 /*-
  * Copyright (c) 2015-2016 Kevin Lo <ke...@freebsd.org>
@@ -29,7 +29,7 @@
 /* RealTek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.1 2019/02/06 11:55:06 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.2 2019/02/06 22:54:41 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1608,7 +1608,7 @@ ure_txcsum(struct mbuf *m)
 	if (flags == 0)
 		return 0;
 
-	if (__predict_true((unsigned)m->m_len >= sizeof(*eh))) {
+	if (__predict_true(m->m_len >= (int)sizeof(*eh))) {
 		eh = mtod(m, struct ether_header *);
 		type = eh->ether_type;
 	} else

Reply via email to