From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MM4o1-0005FC-S3 for qemu-devel@nongnu.org; Wed, 01 Jul 2009 14:45:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MM4nx-0005EM-Sw for qemu-devel@nongnu.org; Wed, 01 Jul 2009 14:45:17 -0400 Received: from [199.232.76.173] (port=58273 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MM4nx-0005EJ-R1 for qemu-devel@nongnu.org; Wed, 01 Jul 2009 14:45:13 -0400 Received: from main.gmane.org ([80.91.229.2]:40369 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MM4nx-0004TL-CO for qemu-devel@nongnu.org; Wed, 01 Jul 2009 14:45:13 -0400 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MM4np-0003rx-Ty for qemu-devel@nongnu.org; Wed, 01 Jul 2009 18:45:05 +0000 Received: from 204.147.152.1 ([204.147.152.1]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Jul 2009 18:45:05 +0000 Received: from void by 204.147.152.1 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Jul 2009 18:45:05 +0000 From: Consul Date: Wed, 01 Jul 2009 11:44:54 -0700 Message-ID: References: <4A4B637A.9070804@codemonkey.ws> <1246471305-7108-1-git-send-email-weil@mail.berlios.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit In-Reply-To: <1246471305-7108-1-git-send-email-weil@mail.berlios.de> Sender: news Subject: [Qemu-devel] Re: [PATCH] Win32: Fix build (no strnlen) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Stefan Weil wrote: > strnlen is a GNU extension which is missing in mingw32 > and perhaps other build environments. > > So we should avoid it and replace it by standard functions. > > Signed-off-by: Stefan Weil > --- > block.c | 7 ++++++- > 1 files changed, 6 insertions(+), 1 deletions(-) > > diff --git a/block.c b/block.c > index c66c031..79b3313 100644 > --- a/block.c > +++ b/block.c > @@ -225,9 +225,14 @@ static BlockDriver *find_protocol(const char *filename) > { > BlockDriver *drv1; > char protocol[128]; > - int len = strnlen(filename, 127)+1; > + int len; > const char *p; > > + len = strlen(filename) + 1; > + if (len > sizeof(protocol)) { > + len = sizeof(protocol); > + } > + > #ifdef _WIN32 > if (is_windows_drive(filename) || > is_windows_drive_prefix(filename)) Or something like this? #ifdef __MINGW32__ size_t strnlen (const char *string, size_t maxlen) { const char *end = memchr (string, '\0', maxlen); return end ? (size_t) (end - string) : maxlen; }; #endif