aboutsummaryrefslogtreecommitdiff
path: root/gdb/target-descriptions.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2016-03-15 12:57:06 -0700
committerDoug Evans <dje@google.com>2016-03-15 12:57:06 -0700
commit54157a25aa28ba78e1da1dfa06e6c988d75e88f1 (patch)
treed8fdb67bace2dca9634c5a3dabf223dcedd5cd0b /gdb/target-descriptions.c
parent73b4f516a037e5fd2e90a3555c59ed42c9578e48 (diff)
downloadfsf-binutils-gdb-54157a25aa28ba78e1da1dfa06e6c988d75e88f1.zip
fsf-binutils-gdb-54157a25aa28ba78e1da1dfa06e6c988d75e88f1.tar.gz
fsf-binutils-gdb-54157a25aa28ba78e1da1dfa06e6c988d75e88f1.tar.bz2
Use int instead of LONGEST in tdesc_type sizes.
gdb/ChangeLog: * target-descriptions.c (struct tdesc_type) <u.u.size>: Change type from LONGEST to int. (struct tdesc_type) <u.f.size>: Ditto. (tdesc_set_struct_size): Change type of "size" arg from LONGEST to int. Add assertion size > 0. (tdesc_create_flags): Ditto. * target-descriptions.h (tdesc_set_struct_size): Update. (tdesc_create_flags): Update. * xml-tdesc.c (MAX_FIELD_SIZE, MAX_FIELD_BITSIZE): New macros. (MAX_VECTOR_SIZE): New macro. (tdesc_start_struct): Catch conversion errors from LONGEST to int. (tdesc_start_flags, tdesc_start_field, tdesc_start_vector): Ditto.
Diffstat (limited to 'gdb/target-descriptions.c')
-rw-r--r--gdb/target-descriptions.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 5ba167f..ac6e3a2 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -150,14 +150,14 @@ typedef struct tdesc_type
struct
{
VEC(tdesc_type_field) *fields;
- LONGEST size;
+ int size;
} u;
/* Flags type. */
struct
{
VEC(tdesc_type_flag) *flags;
- LONGEST size;
+ int size;
} f;
} u;
} *tdesc_type_p;
@@ -1340,9 +1340,10 @@ tdesc_create_struct (struct tdesc_feature *feature, const char *name)
suffice. */
void
-tdesc_set_struct_size (struct tdesc_type *type, LONGEST size)
+tdesc_set_struct_size (struct tdesc_type *type, int size)
{
gdb_assert (type->kind == TDESC_TYPE_STRUCT);
+ gdb_assert (size > 0);
type->u.u.size = size;
}
@@ -1360,10 +1361,12 @@ tdesc_create_union (struct tdesc_feature *feature, const char *name)
struct tdesc_type *
tdesc_create_flags (struct tdesc_feature *feature, const char *name,
- LONGEST size)
+ int size)
{
struct tdesc_type *type = XCNEW (struct tdesc_type);
+ gdb_assert (size > 0);
+
type->name = xstrdup (name);
type->kind = TDESC_TYPE_FLAGS;
type->u.f.size = size;