direct-io.hg

changeset 14333:798a7dc1ac6d

Fix get_val_as_string so that it does not truncate integers.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Sat Mar 10 14:41:06 2007 +0000 (2007-03-10)
parents 6b057bdf0354
children 7e66858aa811
files tools/libxen/src/xen_common.c
line diff
     1.1 --- a/tools/libxen/src/xen_common.c	Sat Mar 10 14:16:52 2007 +0000
     1.2 +++ b/tools/libxen/src/xen_common.c	Sat Mar 10 14:41:06 2007 +0000
     1.3 @@ -110,7 +110,7 @@ parse_structmap_value(xen_session *, xml
     1.4  static size_t size_of_member(const abstract_type *);
     1.5  
     1.6  static const char *
     1.7 -get_val_as_string(const struct abstract_type *, void *, char *);
     1.8 +get_val_as_string(const struct abstract_type *, void *, char *, size_t);
     1.9  
    1.10  
    1.11  void
    1.12 @@ -1185,7 +1185,8 @@ add_struct_value(const struct abstract_t
    1.13      case INT:
    1.14      case ENUM:
    1.15      {
    1.16 -        const char *val_as_string = get_val_as_string(type, value, buf);
    1.17 +        const char *val_as_string =
    1.18 +            get_val_as_string(type, value, buf, sizeof(buf));
    1.19          adder(node, key, "string", val_as_string);
    1.20      }
    1.21      break;
    1.22 @@ -1257,7 +1258,7 @@ add_struct_value(const struct abstract_t
    1.23                  void *r_value = contents + (i * member_size) + r_offset;
    1.24  
    1.25                  const char *l_value_as_string =
    1.26 -                    get_val_as_string(l_type, l_value, buf);
    1.27 +                    get_val_as_string(l_type, l_value, buf, sizeof(buf));
    1.28  
    1.29                  add_struct_value(r_type, r_value, add_struct_member,
    1.30                                   l_value_as_string, struct_node);
    1.31 @@ -1273,7 +1274,8 @@ add_struct_value(const struct abstract_t
    1.32  
    1.33  
    1.34  static const char *
    1.35 -get_val_as_string(const struct abstract_type *type, void *value, char *buf)
    1.36 +get_val_as_string(const struct abstract_type *type, void *value, char *buf,
    1.37 +                  size_t bufsize)
    1.38  {
    1.39      switch (type->typename)
    1.40      {
    1.41 @@ -1307,7 +1309,7 @@ get_val_as_string(const struct abstract_
    1.42      case INT:
    1.43      {
    1.44          int64_t val = *(int64_t *)value;
    1.45 -        snprintf(buf, sizeof(buf), "%"PRId64, val);
    1.46 +        snprintf(buf, bufsize, "%"PRId64, val);
    1.47          return buf;
    1.48      }
    1.49      break;