Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MM7NU-0004Af-JA for qemu-devel@nongnu.org; Wed, 01 Jul 2009 17:30:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MM7NQ-00049d-Ck for qemu-devel@nongnu.org; Wed, 01 Jul 2009 17:30:04 -0400 Received: from [199.232.76.173] (port=45391 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MM7NQ-00049a-8H for qemu-devel@nongnu.org; Wed, 01 Jul 2009 17:30:00 -0400 Received: from mail-ew0-f211.google.com ([209.85.219.211]:61697) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MM7NP-0005aa-R3 for qemu-devel@nongnu.org; Wed, 01 Jul 2009 17:30:00 -0400 Received: by ewy7 with SMTP id 7so1376007ewy.34 for ; Wed, 01 Jul 2009 14:29:59 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v624) In-Reply-To: <022d1985d24fe91131187e956dec0e38@gmail.com> References: <022d1985d24fe91131187e956dec0e38@gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <2e90988f2476e6c5914dab42313c65c5@gmail.com> Content-Transfer-Encoding: 7bit From: G 3 Subject: [Qemu-devel] Re: [PATCH] Win32: Fix build (no strnlen) Date: Wed, 1 Jul 2009 17:29:51 -0400 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Jul 1, 2009, at 5:26 PM, G 3 wrote: > 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 block.c doesn't compile on Mac OS 10.3. I second the notion of removing strnlen. Sorry but I forgot the subject in the last email.