qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] (no subject)


From: G 3
Subject: [Qemu-devel] (no subject)
Date: Wed, 1 Jul 2009 17:26:43 -0400

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 <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))


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.





reply via email to

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