ia64/xen-unstable

changeset 19833:f3a909c8e8e6

blktap2: A final few NetBSD fixes

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jun 24 15:24:53 2009 +0100 (2009-06-24)
parents f1fec38c8228
children edd603e77be4
files tools/blktap2/include/blk_uuid.h tools/blktap2/vhd/lib/libvhd.c tools/blktap2/vhd/lib/vhd-util-read.c
line diff
     1.1 --- a/tools/blktap2/include/blk_uuid.h	Wed Jun 24 14:03:20 2009 +0100
     1.2 +++ b/tools/blktap2/include/blk_uuid.h	Wed Jun 24 15:24:53 2009 +0100
     1.3 @@ -45,7 +45,7 @@ static inline void blk_uuid_generate(blk
     1.4  	uuid_generate(uuid->uuid);
     1.5  }
     1.6  
     1.7 -static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out)
     1.8 +static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out, size_t size)
     1.9  {
    1.10  	uuid_unparse(uuid->uuid, out);
    1.11  }
    1.12 @@ -74,6 +74,7 @@ static inline int blk_uuid_compare(blk_u
    1.13  
    1.14  #include <uuid.h>
    1.15  #include <string.h>
    1.16 +#include <stdlib.h>
    1.17  
    1.18  typedef uuid_t blk_uuid_t;
    1.19  
    1.20 @@ -89,10 +90,13 @@ static inline void blk_uuid_generate(blk
    1.21  	uuid_create((uuid_t *)uuid, &status);
    1.22  }
    1.23  
    1.24 -static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out)
    1.25 +static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out, size_t size)
    1.26  {
    1.27  	uint32_t status;
    1.28 -	uuid_to_string((uuid_t *)uuid, &out, &status);
    1.29 +	char *_out = NULL;
    1.30 +	uuid_to_string((uuid_t *)uuid, &_out, &status);
    1.31 +	strlcpy(out, _out, size);
    1.32 +	free(_out);
    1.33  }
    1.34  
    1.35  static inline void blk_uuid_from_string(blk_uuid_t *uuid, const char *in)
     2.1 --- a/tools/blktap2/vhd/lib/libvhd.c	Wed Jun 24 14:03:20 2009 +0100
     2.2 +++ b/tools/blktap2/vhd/lib/libvhd.c	Wed Jun 24 15:24:53 2009 +0100
     2.3 @@ -1335,7 +1335,7 @@ vhd_macx_encode_location(char *name, cha
     2.4  	snprintf(uri, ibl+1, "file://%s", name);
     2.5  
     2.6  	if (iconv(cd,
     2.7 -#if defined(__linux__) || (__Linux__)
     2.8 +#if defined(__linux__) || defined(__Linux__)
     2.9  	    (char **)
    2.10  #endif
    2.11  	    &urip, &ibl, &uri_utf8p, &obl) == (size_t)-1 ||
    2.12 @@ -1425,7 +1425,7 @@ vhd_w2u_encode_location(char *name, char
    2.13  	}
    2.14  
    2.15  	if (iconv(cd,
    2.16 -#if defined(__linux__) || (__Linux__)
    2.17 +#if defined(__linux__) || defined(__Linux__)
    2.18  	    (char **)
    2.19  #endif
    2.20  	    &urip, &ibl, &uri_utf16p, &obl) == (size_t)-1 ||
     3.1 --- a/tools/blktap2/vhd/lib/vhd-util-read.c	Wed Jun 24 14:03:20 2009 +0100
     3.2 +++ b/tools/blktap2/vhd/lib/vhd-util-read.c	Wed Jun 24 15:24:53 2009 +0100
     3.3 @@ -78,7 +78,7 @@ vhd_print_header(vhd_context_t *vhd, vhd
     3.4  	       (err ? "failed to read name" : name));
     3.5  	free(name);
     3.6  
     3.7 -	blk_uuid_to_string(&h->prt_uuid, uuid);
     3.8 +	blk_uuid_to_string(&h->prt_uuid, uuid, sizeof(uuid));
     3.9  	printf("Parent UUID         : %s\n", uuid);
    3.10      
    3.11  	vhd_time_to_string(h->prt_ts, time_str);
    3.12 @@ -153,7 +153,7 @@ vhd_print_footer(vhd_footer_t *f, int he
    3.13  	printf("Checksum            : 0x%x|0x%x (%s)\n", f->checksum, cksm,
    3.14  		f->checksum == cksm ? "Good!" : "Bad!");
    3.15  
    3.16 -	blk_uuid_to_string(&f->uuid, uuid);
    3.17 +	blk_uuid_to_string(&f->uuid, uuid, sizeof(uuid));
    3.18  	printf("UUID                : %s\n", uuid);
    3.19  
    3.20  	printf("Saved state         : %s\n", f->saved == 0 ? "No" : "Yes");