Date: Tue, 27 Nov 2007 17:36:40 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 129640 for review Message-ID: <200711271736.lARHaex5079372@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200711271736.lARHaex5079372>