Date: Mon, 26 Nov 2007 23:38:25 -0800 From: Alfred Perlstein <alfred@freebsd.org> To: Hans Petter Selasky <hselasky@FreeBSD.org> Cc: Perforce Change Reviews <perforce@FreeBSD.org> Subject: Re: PERFORCE change 129580 for review Message-ID: <20071127073825.GV71382@elvis.mu.org> In-Reply-To: <200711262025.lAQKPO3b036323@repoman.freebsd.org> References: <200711262025.lAQKPO3b036323@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
* Hans Petter Selasky <hselasky@FreeBSD.org> [071126 12:25] wrote: > http://perforce.freebsd.org/chv.cgi?CH=129580 > > Change 129580 by hselasky@hselasky_laptop001 on 2007/11/26 20:24:39 > > > Bugfix. > > Affected files ... > > .. //depot/projects/usb/src/sys/dev/usb/ulpt.c#29 edit > > Differences ... > > ==== //depot/projects/usb/src/sys/dev/usb/ulpt.c#29 (text+ko) ==== > > @@ -707,7 +707,7 @@ > for (p = str - 1; p; p = strchr(p, ';')) { > p++; /* skip ';' */ > if (strncmp(p, "MFG:", 4) == 0 || > - strncmp(p, "MANUFACTURER:", 14) == 0 || > + strncmp(p, "MANUFACTURER:", 13) == 0 || > strncmp(p, "MDL:", 4) == 0 || > strncmp(p, "MODEL:", 6) == 0) { > q = strchr(p, ';'); This can be done with the following macro to avoid bugs: /* used as so: CONSTSTRCMP(p, "MFG:") */ #define CONSTSTRCMP(str, cstr) strncmp(str, cstr, sizeof(cstr)) (you may need a -1 after the sizeof, I forget at this hour.) of course this fails, badly if one doesn't use a const string as the second arg. For non time critical code one could replace the sizeof() with strlen(). -- - Alfred Perlstein
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071127073825.GV71382>