From owner-p4-projects@FreeBSD.ORG Tue Nov 27 17:36:40 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8B26D16A46C; Tue, 27 Nov 2007 17:36:40 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E82716A419 for ; Tue, 27 Nov 2007 17:36:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 2E49E13C4CC for ; Tue, 27 Nov 2007 17:36:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id lARHaeVq079375 for ; Tue, 27 Nov 2007 17:36:40 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id lARHaex5079372 for perforce@freebsd.org; Tue, 27 Nov 2007 17:36:40 GMT (envelope-from hselasky@FreeBSD.org) Date: Tue, 27 Nov 2007 17:36:40 GMT Message-Id: <200711271736.lARHaex5079372@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 129640 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Nov 2007 17:36:40 -0000 http://perforce.freebsd.org/chv.cgi?CH=129640 Change 129640 by hselasky@hselasky_laptop001 on 2007/11/27 17:35:57 Improve bugfix. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/ulpt.c#31 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/ulpt.c#31 (text+ko) ==== @@ -660,6 +660,28 @@ #if 0 /* XXX This does not belong here. */ + +/* + * Compare two strings until the second ends. + */ + +static uint8_t +ieee1284_compare(const char *a, const char *b) +{ + while (1) { + + if (*b == 0) { + break; + } + if (*a != *b) { + return 1; + } + b++; + a++; + } + return 0; +} + /* * Print select parts of an IEEE 1284 device ID. */ @@ -670,10 +692,10 @@ for (p = str - 1; p; p = strchr(p, ';')) { p++; /* skip ';' */ - if (strncmp(p, "MFG:", 4) == 0 || - strncmp(p, "MANUFACTURER:", 13) == 0 || - strncmp(p, "MDL:", 4) == 0 || - strncmp(p, "MODEL:", 6) == 0) { + if (ieee1284_compare(p, "MFG:") == 0 || + ieee1284_compare(p, "MANUFACTURER:") == 0 || + ieee1284_compare(p, "MDL:") == 0 || + ieee1284_compare(p, "MODEL:") == 0) { q = strchr(p, ';'); if (q) printf("%.*s", (int)(q - p + 1), p);