qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Consul <void@aleksoft.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] Win32: Fix build (no strnlen)
Date: Wed, 01 Jul 2009 11:44:54 -0700	[thread overview]
Message-ID: <h2gar7$4c8$1@ger.gmane.org> (raw)
In-Reply-To: <1246471305-7108-1-git-send-email-weil@mail.berlios.de>

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

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

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

Thread overview: 10+ 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   ` [Qemu-devel] [PATCH] Win32: Fix build (no strnlen) Stefan Weil
2009-07-01 18:44     ` Consul [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-07-01 21:26 [Qemu-devel] (no subject) G 3
2009-07-01 21:29 ` [Qemu-devel] Re: [PATCH] Win32: Fix build (no strnlen) G 3

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='h2gar7$4c8$1@ger.gmane.org' \
    --to=void@aleksoft.net \
    --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).