# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1173537666 0
# Node ID 798a7dc1ac6d39578dc3305dbe574e73f1b883ab
# Parent 6b057bdf0354700176163d12227f487d5c2f8a4e
Fix get_val_as_string so that it does not truncate integers.
Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
tools/libxen/src/xen_common.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff -r 6b057bdf0354 -r 798a7dc1ac6d tools/libxen/src/xen_common.c
--- a/tools/libxen/src/xen_common.c Sat Mar 10 14:16:52 2007 +0000
+++ b/tools/libxen/src/xen_common.c Sat Mar 10 14:41:06 2007 +0000
@@ -110,7 +110,7 @@ static size_t size_of_member(const abstr
static size_t size_of_member(const abstract_type *);
static const char *
-get_val_as_string(const struct abstract_type *, void *, char *);
+get_val_as_string(const struct abstract_type *, void *, char *, size_t);
void
@@ -1185,7 +1185,8 @@ add_struct_value(const struct abstract_t
case INT:
case ENUM:
{
- const char *val_as_string = get_val_as_string(type, value, buf);
+ const char *val_as_string =
+ get_val_as_string(type, value, buf, sizeof(buf));
adder(node, key, "string", val_as_string);
}
break;
@@ -1257,7 +1258,7 @@ add_struct_value(const struct abstract_t
void *r_value = contents + (i * member_size) + r_offset;
const char *l_value_as_string =
- get_val_as_string(l_type, l_value, buf);
+ get_val_as_string(l_type, l_value, buf, sizeof(buf));
add_struct_value(r_type, r_value, add_struct_member,
l_value_as_string, struct_node);
@@ -1273,7 +1274,8 @@ add_struct_value(const struct abstract_t
static const char *
-get_val_as_string(const struct abstract_type *type, void *value, char *buf)
+get_val_as_string(const struct abstract_type *type, void *value, char *buf,
+ size_t bufsize)
{
switch (type->typename)
{
@@ -1307,7 +1309,7 @@ get_val_as_string(const struct abstract_
case INT:
{
int64_t val = *(int64_t *)value;
- snprintf(buf, sizeof(buf), "%"PRId64, val);
+ snprintf(buf, bufsize, "%"PRId64, val);
return buf;
}
break;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|