diff options
author | Pedro Alves <palves@redhat.com> | 2015-10-13 19:40:50 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-10-13 19:40:50 +0100 |
commit | bfb1c7963b15b31073c9adf2d97ff1cf953ec99c (patch) | |
tree | 2ad7e27016e1ad1f78be1bed8b8fddf9ffcc2a29 /gdb | |
parent | aa5c10ce9b1bd04a7f4a619d5e956c977fcd60d3 (diff) | |
download | gdb-bfb1c7963b15b31073c9adf2d97ff1cf953ec99c.zip gdb-bfb1c7963b15b31073c9adf2d97ff1cf953ec99c.tar.gz gdb-bfb1c7963b15b31073c9adf2d97ff1cf953ec99c.tar.bz2 |
ada-lang.c:ada_value_primitive_packed_val: const correctness
gdb/ChangeLog:
2015-10-13 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_value_primitive_packed_val): Constify
locals. Use value_contents_writeable. Remove casts.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/ada-lang.c | 18 |
2 files changed, 15 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c141fac..63d0560 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2015-10-13 Pedro Alves <palves@redhat.com> + * ada-lang.c (ada_value_primitive_packed_val): Constify + locals. Use value_contents_writeable. Remove casts. + +2015-10-13 Pedro Alves <palves@redhat.com> + * ada-lang.c (ada_value_primitive_packed_val): Add casts to malloc and alloca calls. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 6d1998a..383db99 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2525,7 +2525,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, struct type *type) { struct value *v; - gdb_byte *src; /* First byte containing data to unpack */ + const gdb_byte *src; /* First byte containing data to unpack */ gdb_byte *unpacked; const int is_scalar = is_scalar_type (type); const int is_big_endian = gdbarch_bits_big_endian (get_type_arch (type)); @@ -2536,9 +2536,9 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, type = ada_check_typedef (type); if (obj == NULL) - src = (gdb_byte *) valaddr + offset; + src = valaddr + offset; else - src = (gdb_byte *) value_contents (obj) + offset; + src = value_contents (obj) + offset; if (is_dynamic_type (type)) { @@ -2574,20 +2574,22 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, if (obj == NULL) { v = allocate_value (type); - src = (gdb_byte *) valaddr + offset; + src = valaddr + offset; } else if (VALUE_LVAL (obj) == lval_memory && value_lazy (obj)) { int src_len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8; + gdb_byte *buf; v = value_at (type, value_address (obj) + offset); - src = (gdb_byte *) alloca (src_len); - read_memory (value_address (v), src, src_len); + buf = (gdb_byte *) alloca (src_len); + read_memory (value_address (v), buf, src_len); + src = buf; } else { v = allocate_value (type); - src = (gdb_byte *) value_contents (obj) + offset; + src = value_contents (obj) + offset; } if (obj != NULL) @@ -2610,7 +2612,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, } else set_value_bitsize (v, bit_size); - unpacked = (gdb_byte *) value_contents (v); + unpacked = value_contents_writeable (v); if (bit_size == 0) { |