qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Weil <weil@mail.berlios.de>
To: QEMU Developers <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] Win32: Fix build (no strnlen)
Date: Wed,  1 Jul 2009 20:01:45 +0200	[thread overview]
Message-ID: <1246471305-7108-1-git-send-email-weil@mail.berlios.de> (raw)
In-Reply-To: <4A4B637A.9070804@codemonkey.ws>

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 <weil@mail.berlios.de>
---
 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))
-- 
1.5.6.5

  parent reply	other threads:[~2009-07-01 18:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-01 13:04 [Qemu-devel] MINGW: Unable to link multiboot.img + strnlen missing Bartlomiej Celary
2009-07-01 13:24 ` Anthony Liguori
2009-07-01 14:35   ` Alexander Graf
2009-07-01 15:52     ` Anthony Liguori
2009-07-01 15:55       ` Alexander Graf
2009-07-10 15:36         ` Bartlomiej Celary
2009-07-10 16:03           ` Anthony Liguori
2009-07-01 18:01   ` Stefan Weil [this message]
2009-07-01 18:44     ` [Qemu-devel] Re: [PATCH] Win32: Fix build (no strnlen) Consul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1246471305-7108-1-git-send-email-weil@mail.berlios.de \
    --to=weil@mail.berlios.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).