qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Win32: Fix build (no strnlen)


From: Stefan Weil
Subject: [Qemu-devel] [PATCH] Win32: Fix build (no strnlen)
Date: Wed, 1 Jul 2009 20:01:45 +0200

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 <address@hidden>
---
 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]