From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Subject: Re: [PATCH] Toshiba ACPI Extras 0.16 Date: Sun, 27 Jul 2003 20:14:30 +0100 Sender: acpi-devel-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Message-ID: <20030727191430.GS1485@parcelfarce.linux.theplanet.co.uk> References: <3F21BD11.8060405@prairienet.org> <20030726052012.GO1485@parcelfarce.linux.theplanet.co.uk> <3F22F1B0.9080607@prairienet.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <3F22F1B0.9080607-ZFKsivP1bGvOQU1ULcgDhA@public.gmane.org> Errors-To: acpi-devel-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: To: John Belmonte Cc: acpi-devel List-Id: linux-acpi@vger.kernel.org On Sat, Jul 26, 2003 at 05:25:04PM -0400, John Belmonte wrote: > Matthew Wilcox wrote: > >seems to me you'd be better off doing ... > > > > len = strlen(str); > > if (len > n) > > len = n; > > memcpy(str2, str, n); > > str2[n] = '\0'; > > > >i wrote a short note entitled "strncpy Considered Harmful" a few years ago. > >unfortunately, it seems lost in time. > > Since you have that experience then I would expect you to consider > whether str is zero-terminated before suggesting that I change my code. ok, you want strnlen there then. my original note was in the context of how completely useless strncpy was for C strings. -- "It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01