diff options
author | Alan Modra <amodra@gmail.com> | 2021-03-29 09:52:56 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-03-29 11:22:22 +1030 |
commit | 63b4cc53dc41c755f8b30d85edf29c153f76eba3 (patch) | |
tree | 8a43529c805f57a538e4a13333016edabca9b7ca /bfd | |
parent | 854f1e4be9172c835d1b89973d29ce66f9e65479 (diff) | |
download | fsf-binutils-gdb-63b4cc53dc41c755f8b30d85edf29c153f76eba3.zip fsf-binutils-gdb-63b4cc53dc41c755f8b30d85edf29c153f76eba3.tar.gz fsf-binutils-gdb-63b4cc53dc41c755f8b30d85edf29c153f76eba3.tar.bz2 |
TRUE/FALSE simplification
There is really no need to write code like "foo != 0 ? TRUE : FALSE"
unless we had stupidly defined FALSE as something other than 0 or TRUE
as something other than 1. The simpler "foo != 0" does just as well.
Similarly "(condition == TRUE)" or "(condition == FALSE) can be
simplified to "(condition)" and "(!condition)" respectively.
I'll note that there is reason to use "integer_expression != 0" when
assigning a bfd_boolean rather than the simpler "integer_expression",
if you expect the variable to have 0 or 1 value. It's probably even a
good idea to not rely on implicit conversion if bfd_boolean were _Bool.
bfd/
* aoutx.h (aout_link_write_symbols): Don't cast boolean expression
to bfd_boolean.
* elf32-or1k.c (or1k_set_got_and_rela_sizes): Dont compare booleans
against FALSE.
* elf32-arc.c (name_for_global_symbol): Don't compare boolean to TRUE.
(is_reloc_PC_relative): Don't use "boolean_condition ? TRUE : FALSE".
(is_reloc_SDA_relative, is_reloc_for_GOT): Likewise.
(is_reloc_for_PLT, is_reloc_for_TLS): Likewise.
* elf32-arm.c (stm32l4xx_need_create_replacing_stub): Likewise.
* elf32-nds32.c (insert_nds32_elf_blank): Likewise.
* elf32-rx.c (rx_set_section_contents): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
* elfxx-mips.c (_bfd_mips_elf_ignore_undef_symbol): Likewise.
* mach-o.c (bfd_mach_o_read_command): Likewise.
* targets.c (bfd_get_target_info): Likewise.
binutils/
* dlltool.c (main): Don't use "boolean_condition ? TRUE : FALSE".
* dwarf.c (read_and_display_attr_value): Likewise.
(display_debug_str_offsets): Likewise.
* objdump.c (dump_bfd): Likewise.
* readelf.c (dump_section_as_strings): Likewise.
(dump_section_as_bytes): Likewise.
gas/
* atof-generic.c (FALSE, TRUE): Don't define.
* config/obj-elf.h (FALSE, TRUE): Don't define.
* config/obj-som.h (FALSE, TRUE): Don't define.
* config/tc-hppa.h (FALSE, TRUE): Don't define.
* config/tc-pdp11.c (FALSE, TRUE): Don't define.
* config/tc-iq2000.h (obj_fix_adjustable): Delete.
* config/tc-m32r.h (TC_FIX_ADJUSTABLE): Delete.
* config/tc-mt.h (obj_fix_adjustable): Delete.
* config/tc-nds32.h (TC_FIX_ADJUSTABLE): Delete.
* config/tc-arc.c (parse_opcode_flags): Simplify boolean expression.
(relaxable_flag, relaxable_operand, assemble_insn): Likewise.
(tokenize_extregister): Likewise.
* config/tc-csky.c (parse_opcode, get_operand_value): Likewise.
(parse_operands_op, parse_operands, md_assemble): Likewise.
* config/tc-d10v.c (build_insn): Likewise.
* config/tc-score.c (s3_gen_insn_frag): Likewise.
* config/tc-score7.c (s7_gen_insn_frag, s7_relax_frag): Likewise.
* config/tc-tic6x.c (tic6x_update_features, md_assemble): Likewise.
* config/tc-z80.c (emit_byte): Likewise.
include/
* opcode/aarch64.h (alias_opcode_p): Simplify boolean expression.
(opcode_has_alias, pseudo_opcode_p, optional_operand_p): Likewise.
(opcode_has_special_coder): Likewise.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_before_allocation): Simplify
boolean expression.
* lexsup.c (parse_args): Likewise.
* pe-dll.c (pe_dll_id_target): Likewise.
opcodes/
* aarch64-opc.c (vector_qualifier_p): Simplify boolean expression.
(fp_qualifier_p, get_data_pattern): Likewise.
(aarch64_get_operand_modifier_from_value): Likewise.
(aarch64_extend_operator_p, aarch64_shift_operator_p): Likewise.
(operand_variant_qualifier_p): Likewise.
(qualifier_value_in_range_constraint_p): Likewise.
(aarch64_get_qualifier_esize): Likewise.
(aarch64_get_qualifier_nelem): Likewise.
(aarch64_get_qualifier_standard_value): Likewise.
(get_lower_bound, get_upper_bound): Likewise.
(aarch64_find_best_match, match_operands_qualifier): Likewise.
(aarch64_print_operand): Likewise.
* aarch64-opc.h (operand_has_inserter, operand_has_extractor): Likewise.
(operand_need_sign_extension, operand_need_shift_by_two): Likewise.
(operand_need_shift_by_four, operand_maybe_stack_pointer): Likewise.
* arm-dis.c (print_insn_mve, print_insn_thumb32): Likewise.
* tic6x-dis.c (tic6x_check_fetch_packet_header): Likewise.
(print_insn_tic6x): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 18 | ||||
-rw-r--r-- | bfd/aoutx.h | 2 | ||||
-rw-r--r-- | bfd/elf32-arc.c | 12 | ||||
-rw-r--r-- | bfd/elf32-arm.c | 6 | ||||
-rw-r--r-- | bfd/elf32-nds32.c | 2 | ||||
-rw-r--r-- | bfd/elf32-or1k.c | 4 | ||||
-rw-r--r-- | bfd/elf32-rx.c | 4 | ||||
-rw-r--r-- | bfd/elfnn-aarch64.c | 2 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 2 | ||||
-rw-r--r-- | bfd/mach-o.c | 2 | ||||
-rw-r--r-- | bfd/targets.c | 3 |
11 files changed, 37 insertions, 20 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index fbfc4db..6d361d5 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,23 @@ 2021-03-29 Alan Modra <amodra@gmail.com> + * aoutx.h (aout_link_write_symbols): Don't cast boolean expression + to bfd_boolean. + * elf32-or1k.c (or1k_set_got_and_rela_sizes): Dont compare booleans + against FALSE. + * elf32-arc.c (name_for_global_symbol): Don't compare boolean to TRUE. + (is_reloc_PC_relative): Don't use "boolean_condition ? TRUE : FALSE". + (is_reloc_SDA_relative, is_reloc_for_GOT): Likewise. + (is_reloc_for_PLT, is_reloc_for_TLS): Likewise. + * elf32-arm.c (stm32l4xx_need_create_replacing_stub): Likewise. + * elf32-nds32.c (insert_nds32_elf_blank): Likewise. + * elf32-rx.c (rx_set_section_contents): Likewise. + * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise. + * elfxx-mips.c (_bfd_mips_elf_ignore_undef_symbol): Likewise. + * mach-o.c (bfd_mach_o_read_command): Likewise. + * targets.c (bfd_get_target_info): Likewise. + +2021-03-29 Alan Modra <amodra@gmail.com> + * coff-z80.c (z80_is_local_label_name): Return bfd_boolean. * elf32-z80.c (z80_is_local_label_name): Likewise. * elf32-spu.c (spu_elf_modify_headers): Likewise. diff --git a/bfd/aoutx.h b/bfd/aoutx.h index 8025b8c..8761a6a 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -5209,7 +5209,7 @@ aout_link_write_symbols (struct aout_final_link_info *flaginfo, bfd *input_bfd) /* If we have already included a header file with the same value, then replace this one with an N_EXCL symbol. */ - copy = (bfd_boolean) (! flaginfo->info->keep_memory); + copy = !flaginfo->info->keep_memory; incl_entry = aout_link_includes_lookup (&flaginfo->includes, name, TRUE, copy); if (incl_entry == NULL) diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index 32096fe..c796104 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -55,7 +55,7 @@ name_for_global_symbol (struct elf_link_hash_entry *h) Elf_Internal_Rela _rel; \ bfd_byte * _loc; \ \ - if (_htab->dynamic_sections_created == TRUE) \ + if (_htab->dynamic_sections_created) \ { \ BFD_ASSERT (_htab->srel##SECTION &&_htab->srel##SECTION->contents); \ _loc = _htab->srel##SECTION->contents \ @@ -128,13 +128,13 @@ bfd_put_32_me (bfd *abfd, bfd_vma value,unsigned char *data) static ATTRIBUTE_UNUSED bfd_boolean is_reloc_PC_relative (reloc_howto_type *howto) { - return (strstr (howto->name, "PC") != NULL) ? TRUE : FALSE; + return strstr (howto->name, "PC") != NULL; } static bfd_boolean is_reloc_SDA_relative (reloc_howto_type *howto) { - return (strstr (howto->name, "SDA") != NULL) ? TRUE : FALSE; + return strstr (howto->name, "SDA") != NULL; } static bfd_boolean @@ -142,19 +142,19 @@ is_reloc_for_GOT (reloc_howto_type * howto) { if (strstr (howto->name, "TLS") != NULL) return FALSE; - return (strstr (howto->name, "GOT") != NULL) ? TRUE : FALSE; + return strstr (howto->name, "GOT") != NULL; } static bfd_boolean is_reloc_for_PLT (reloc_howto_type * howto) { - return (strstr (howto->name, "PLT") != NULL) ? TRUE : FALSE; + return strstr (howto->name, "PLT") != NULL; } static bfd_boolean is_reloc_for_TLS (reloc_howto_type *howto) { - return (strstr (howto->name, "TLS") != NULL) ? TRUE : FALSE; + return strstr (howto->name, "TLS") != NULL; } struct arc_relocation_data diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index d70529d..7d7c3ed 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -8796,9 +8796,9 @@ stm32l4xx_need_create_replacing_stub (const insn32 insn, /* DEFAULT mode accounts for the real bug condition situation, ALL mode inserts stubs for each LDM/VLDM instruction (testing). */ - return - (stm32l4xx_fix == BFD_ARM_STM32L4XX_FIX_DEFAULT) ? nb_words > 8 : - (stm32l4xx_fix == BFD_ARM_STM32L4XX_FIX_ALL) ? TRUE : FALSE; + return (stm32l4xx_fix == BFD_ARM_STM32L4XX_FIX_DEFAULT + ? nb_words > 8 + : stm32l4xx_fix == BFD_ARM_STM32L4XX_FIX_ALL); } /* Look for potentially-troublesome code sequences which might trigger diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index f6a89a7..61a52af 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -9038,7 +9038,7 @@ insert_nds32_elf_blank (nds32_elf_blank_t **blank_p, bfd_vma addr, bfd_vma len) if (!*blank_p) { *blank_p = create_nds32_elf_blank (addr, len); - return *blank_p ? TRUE : FALSE; + return *blank_p != NULL; } blank_t = search_nds32_elf_blank (*blank_p, addr); diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index 5f9d26c..1804854 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -2698,7 +2698,7 @@ or1k_set_got_and_rela_sizes (const unsigned char tls_type, is_tls_entry = TRUE; } - if (is_tls_entry == FALSE) + if (!is_tls_entry) *got_size += 4; if (dynamic) @@ -2709,7 +2709,7 @@ or1k_set_got_and_rela_sizes (const unsigned char tls_type, if ((tls_type & TLS_IE) != 0) *rela_size += sizeof (Elf32_External_Rela); - if (is_tls_entry == FALSE) + if (!is_tls_entry) *rela_size += sizeof (Elf32_External_Rela); } } diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index 7b6cf9a..cd0bc00 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -3541,8 +3541,8 @@ rx_set_section_contents (bfd * abfd, file_ptr offset, bfd_size_type count) { - bfd_boolean exec = (abfd->flags & EXEC_P) ? TRUE : FALSE; - bfd_boolean s_code = (section->flags & SEC_CODE) ? TRUE : FALSE; + bfd_boolean exec = (abfd->flags & EXEC_P) != 0; + bfd_boolean s_code = (section->flags & SEC_CODE) != 0; bfd_boolean rv; char * swapped_data = NULL; bfd_size_type i; diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 3ec0983..86130b4 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -5769,7 +5769,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, relocate the text and data segments independently, so the symbol does not matter. */ symbol = 0; - relocate = globals->no_apply_dynamic_relocs ? FALSE : TRUE; + relocate = !globals->no_apply_dynamic_relocs; outrel.r_info = ELFNN_R_INFO (symbol, AARCH64_R (RELATIVE)); outrel.r_addend += value; } diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 07a233f..bd4140c 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -16395,7 +16395,7 @@ _bfd_mips_elf_merge_symbol_attribute (struct elf_link_hash_entry *h, bfd_boolean _bfd_mips_elf_ignore_undef_symbol (struct elf_link_hash_entry *h) { - return ELF_MIPS_IS_OPTIONAL (h->other) ? TRUE : FALSE; + return ELF_MIPS_IS_OPTIONAL (h->other) != 0; } bfd_boolean diff --git a/bfd/mach-o.c b/bfd/mach-o.c index f853783..695b158 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -4930,7 +4930,7 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command, cmd = bfd_h_get_32 (abfd, raw.cmd); command->type = cmd & ~BFD_MACH_O_LC_REQ_DYLD; - command->type_required = cmd & BFD_MACH_O_LC_REQ_DYLD ? TRUE : FALSE; + command->type_required = (cmd & BFD_MACH_O_LC_REQ_DYLD) != 0; command->len = bfd_h_get_32 (abfd, raw.cmdsize); if (command->len < 8 || command->len % 4 != 0) return FALSE; diff --git a/bfd/targets.c b/bfd/targets.c index dcd4263..372a9c3 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -1654,8 +1654,7 @@ bfd_get_target_info (const char *target_name, bfd *abfd, if (! target_vec) return NULL; if (is_bigendian) - *is_bigendian = ((target_vec->byteorder == BFD_ENDIAN_BIG) ? TRUE - : FALSE); + *is_bigendian = target_vec->byteorder == BFD_ENDIAN_BIG; if (underscoring) *underscoring = ((int) target_vec->symbol_leading_char) & 0xff; |