PERFORCE change 129640 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Tue Nov 27 09:36:40 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=129640
Change 129640 by hselasky at 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);
More information about the p4-projects
mailing list