From owner-p4-projects@FreeBSD.ORG Tue Nov 27 18:34:36 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 83AF616A46E; Tue, 27 Nov 2007 18:34:36 +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 27B7716A41A for ; Tue, 27 Nov 2007 18:34:36 +0000 (UTC) (envelope-from hselasky@freebsd.org) Received: from swip.net (mailfe12.swip.net [212.247.155.97]) by mx1.freebsd.org (Postfix) with ESMTP id AA89C13C4F3 for ; Tue, 27 Nov 2007 18:34:35 +0000 (UTC) (envelope-from hselasky@freebsd.org) X-Cloudmark-Score: 0.000000 [] Received: from [85.19.218.45] (account mc467741@c2i.net [85.19.218.45] verified) by mailfe12.swip.net (CommuniGate Pro SMTP 5.1.13) with ESMTPA id 533638497; Tue, 27 Nov 2007 18:19:31 +0100 From: Hans Petter Selasky To: Alfred Perlstein Date: Tue, 27 Nov 2007 18:20:04 +0100 User-Agent: KMail/1.9.7 References: <200711262025.lAQKPO3b036323@repoman.freebsd.org> <20071127073825.GV71382@elvis.mu.org> In-Reply-To: <20071127073825.GV71382@elvis.mu.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200711271820.05134.hselasky@freebsd.org> Cc: Perforce Change Reviews Subject: Re: PERFORCE change 129580 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 18:34:36 -0000 Hi, I will make a wrapper function that uses "strlen()". This is not time critical code. --HPS On Tuesday 27 November 2007, Alfred Perlstein wrote: > * Hans Petter Selasky [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().