From: Joel Brobecker Date: Wed, 3 Nov 2010 23:20:33 +0000 (+0000) Subject: [Ada] move some variables to scope where they are used X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9addb3b96c4124014e469442d5f2e688ac34e2eb;p=binutils-gdb.git [Ada] move some variables to scope where they are used I noticed that some variables are only used inside one side of an if/else blob. So I moved these variables inside that block for better clarity. gdb/ChangeLog: * ada-valprint.c (ada_val_print_array): Move variables `eltlen' and `len' declaration and computation inside block where they are being used. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 221868b0caf..baedb0babc0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2010-11-03 Joel Brobecker + + * ada-valprint.c (ada_val_print_array): Move variables `eltlen' + and `len' declaration and computation inside block where they + are being used. + 2010-11-03 Joel Brobecker * valprint.c (val_print_array_elements): Put back handling of diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 2ab2ba2f3de..ae2a47d7d86 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -603,23 +603,24 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr, { enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); struct type *elttype = TYPE_TARGET_TYPE (type); - unsigned int eltlen; - unsigned int len; int result = 0; - if (elttype == NULL) - eltlen = 0; - else - eltlen = TYPE_LENGTH (elttype); - if (eltlen == 0) - len = 0; - else - len = TYPE_LENGTH (type) / eltlen; - /* For an array of chars, print with string syntax. */ if (ada_is_string_type (type) && (options->format == 0 || options->format == 's')) { + unsigned int eltlen; + unsigned int len; + + if (elttype == NULL) + eltlen = 0; + else + eltlen = TYPE_LENGTH (elttype); + if (eltlen == 0) + len = 0; + else + len = TYPE_LENGTH (type) / eltlen; + if (options->prettyprint_arrays) print_spaces_filtered (2 + 2 * recurse, stream);