(no subject)
Quoted 37 lines
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))
Quoted 8 lines
Or something like this?
#ifdef__MINGW32__size_tstrnlen (const char *string,size_tmaxlen) {
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.
[Qemu-devel] Re: [PATCH] Win32: Fix build (no strnlen)
Quoted 37 lines · 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 <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))
Quoted 8 lines
Or something like this?
#ifdef__MINGW32__size_tstrnlen (const char *string,size_tmaxlen) {
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.