From owner-p4-projects@FreeBSD.ORG Tue Nov 27 07:56:51 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2E05116A475; Tue, 27 Nov 2007 07:56:51 +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 D043216A41B for ; Tue, 27 Nov 2007 07:56:50 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id BD52313C465 for ; Tue, 27 Nov 2007 07:56:50 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id EE5AF1A4D7E; Mon, 26 Nov 2007 23:38:25 -0800 (PST) Date: Mon, 26 Nov 2007 23:38:25 -0800 From: Alfred Perlstein To: Hans Petter Selasky Message-ID: <20071127073825.GV71382@elvis.mu.org> References: <200711262025.lAQKPO3b036323@repoman.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200711262025.lAQKPO3b036323@repoman.freebsd.org> User-Agent: Mutt/1.4.2.3i 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 07:56:51 -0000 * 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(). -- - Alfred Perlstein