[binutils-gdb] gdb, gdbserver, gdbsupport: replace many uses of strcmp with streq
Simon Marchi via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b73d92e2c547f29caece9ea0de904d874a6fffab commit b73d92e2c547f29caece9ea0de904d874a6fffab Author: Simon Marchi <[email protected]> Date: Mon Mar 16 11:23:19 2026 -0400 gdb, gdbserver, gdbsupport: replace many uses of strcmp with streq Replace all occurrences of: strcmp (...) == 0 strcmp (...) != 0 !strcmp (...) 0 == strcmp (...) strcmp (...) directly used as a boolean predicate with the equivalent expression using streq. This is for consistency (we already use streq as some places in the testsuite) but also for clarity. I think that streq is clearer on the intent than strcmp. It's also a bit shorter. Change-Id: Ibbf5261b1872c240bc0c982c147f6a5477275a91 Approved-By: Andrew Burgess <[email protected]> Diff: --- gdb/aarch64-tdep.c | 11 ++- gdb/ada-exp.y | 4 +- gdb/ada-lang.c | 91 +++++++++++------------ gdb/amd64-dicos-tdep.c | 3 +- gdb/amd64-gnu-tdep.c | 2 +- gdb/amd64-linux-tdep.c | 2 +- gdb/amd64-obsd-tdep.c | 7 +- gdb/amd64-windows-tdep.c | 4 +- gdb/arch-utils.c | 4 +- gdb/arm-pikeos-tdep.c | 6 +- gdb/arm-tdep.c | 18 ++--- gdb/arm-wince-tdep.c | 4 +- gdb/auto-load.c | 15 ++-- gdb/avr-tdep.c | 2 +- gdb/ax-gdb.c | 6 +- gdb/bfin-tdep.c | 2 +- gdb/break-catch-sig.c | 2 +- gdb/break-cond-parse.c | 4 +- gdb/breakpoint.c | 13 ++-- gdb/bt-utils.c | 2 +- gdb/btrace.c | 10 +-- gdb/c-lang.c | 6 +- gdb/c-typeprint.c | 8 +- gdb/c-valprint.c | 9 +-- gdb/charset.c | 36 ++++----- gdb/cli/cli-cmds.c | 7 +- gdb/cli/cli-decode.c | 9 +-- gdb/cli/cli-dump.c | 4 +- gdb/cli/cli-option.c | 4 +- gdb/cli/cli-script.c | 2 +- gdb/cli/cli-style.c | 6 +- gdb/coff-pe-read.c | 48 ++++++------ gdb/compile/compile-object-load.c | 6 +- gdb/compile/compile.c | 4 +- gdb/completer.c | 4 +- gdb/corelow.c | 4 +- gdb/cp-abi.c | 4 +- gdb/cp-name-parser.y | 2 +- gdb/cp-namespace.c | 14 ++-- gdb/cp-support.c | 24 +++--- gdb/cp-valprint.c | 4 +- gdb/csky-tdep.c | 33 +++------ gdb/ctfread.c | 8 +- gdb/d-namespace.c | 13 ++-- gdb/d-valprint.c | 4 +- gdb/darwin-nat-info.c | 6 +- gdb/dicos-tdep.c | 2 +- gdb/dictionary.c | 2 +- gdb/disasm.c | 4 +- gdb/dtrace-probe.c | 2 +- gdb/dwarf2/cooked-index-shard.c | 2 +- gdb/dwarf2/cooked-index.c | 2 +- gdb/dwarf2/cooked-indexer.c | 2 +- gdb/dwarf2/cu.c | 2 +- gdb/dwarf2/index-write.c | 5 +- gdb/dwarf2/read-gdb-index.c | 2 +- gdb/dwarf2/read.c | 39 +++++----- gdb/dwarf2/sect-names.h | 4 +- gdb/elfread.c | 12 +-- gdb/eval.c | 2 +- gdb/event-top.c | 2 +- gdb/exec.c | 6 +- gdb/extension.c | 2 +- gdb/f-typeprint.c | 2 +- gdb/f-valprint.c | 5 +- gdb/fbsd-nat.c | 2 +- gdb/fbsd-tdep.c | 2 +- gdb/frame.c | 2 +- gdb/frv-tdep.c | 6 +- gdb/ft32-tdep.c | 2 +- gdb/gcore-elf.c | 2 +- gdb/gcore.c | 2 +- gdb/gdb-demangle.c | 5 +- gdb/gdb_bfd.c | 2 +- gdb/gdbtypes.c | 16 ++-- gdb/gnu-nat.c | 8 +- gdb/gnu-v2-abi.c | 9 +-- gdb/go-lang.c | 19 ++--- gdb/go32-nat.c | 6 +- gdb/guile/scm-lazy-string.c | 2 +- gdb/guile/scm-param.c | 2 +- gdb/hppa-bsd-tdep.c | 2 +- gdb/hppa-linux-tdep.c | 2 +- gdb/hppa-tdep.c | 10 +-- gdb/i386-dicos-tdep.c | 3 +- gdb/i386-gnu-tdep.c | 2 +- gdb/i386-go32-tdep.c | 4 +- gdb/i386-linux-tdep.c | 3 +- gdb/i386-obsd-tdep.c | 9 ++- gdb/i386-tdep.c | 39 +++++----- gdb/i386-windows-tdep.c | 2 +- gdb/ia64-tdep.c | 8 +- gdb/infrun.c | 4 +- gdb/interps.c | 8 +- gdb/language.c | 27 ++++--- gdb/linespec.c | 7 +- gdb/linux-tdep.c | 22 +++--- gdb/linux-thread-db.c | 7 +- gdb/m2-typeprint.c | 9 +-- gdb/m32c-tdep.c | 6 +- gdb/m32r-linux-tdep.c | 3 +- gdb/machoread.c | 6 +- gdb/macrocmd.c | 2 +- gdb/macroexp.c | 7 +- gdb/macrotab.c | 4 +- gdb/main.c | 4 +- gdb/memattr.c | 2 +- gdb/mi/mi-cmd-disas.c | 6 +- gdb/mi/mi-cmd-var.c | 14 ++-- gdb/mi/mi-getopt.c | 4 +- gdb/mi/mi-main.c | 46 ++++++------ gdb/mi/mi-parse.c | 33 ++++----- gdb/minsyms.c | 24 +++--- gdb/mips-sde-tdep.c | 5 +- gdb/mips-tdep.c | 12 +-- gdb/namespace.c | 10 +-- gdb/nat/linux-btrace.c | 2 +- gdb/nat/linux-osdata.c | 4 +- gdb/nat/linux-procfs.c | 2 +- gdb/nds32-tdep.c | 2 +- gdb/objc-lang.c | 10 +-- gdb/objfiles.c | 4 +- gdb/opencl-lang.c | 8 +- gdb/osabi.c | 18 ++--- gdb/p-exp.y | 14 ++-- gdb/p-lang.c | 8 +- gdb/p-valprint.c | 9 +-- gdb/ppc-linux-tdep.c | 20 ++--- gdb/ppc64-tdep.c | 2 +- gdb/probe.c | 5 +- gdb/python/py-breakpoint.c | 2 +- gdb/python/py-lazy-string.c | 2 +- gdb/python/py-micmd.c | 5 +- gdb/python/py-param.c | 6 +- gdb/python/py-prettyprint.c | 6 +- gdb/python/py-style.c | 11 ++- gdb/python/python.c | 2 +- gdb/record.c | 16 ++-- gdb/regformats/regdef.h | 2 +- gdb/reggroups.c | 2 +- gdb/remote-fileio.c | 2 +- gdb/remote.c | 114 ++++++++++++++--------------- gdb/riscv-tdep.c | 14 ++-- gdb/rs6000-tdep.c | 16 ++-- gdb/rust-lang.c | 28 +++---- gdb/rust-parse.c | 2 +- gdb/s390-tdep.c | 2 +- gdb/selftest-arch.c | 20 ++--- gdb/serial.c | 2 +- gdb/sh-tdep.c | 2 +- gdb/sol2-tdep.c | 7 +- gdb/solib-aix.c | 10 +-- gdb/solib-darwin.c | 2 +- gdb/solib-dsbt.c | 2 +- gdb/solib-frv.c | 4 +- gdb/solib-svr4.c | 23 +++--- gdb/solib-target.c | 2 +- gdb/solib.c | 4 +- gdb/source.c | 8 +- gdb/sparc64-fbsd-tdep.c | 2 +- gdb/sparc64-obsd-tdep.c | 2 +- gdb/stack.c | 5 +- gdb/stap-probe.c | 3 +- gdb/symfile.c | 30 ++++---- gdb/symmisc.c | 12 +-- gdb/symtab.c | 14 ++-- gdb/target.c | 2 +- gdb/top.c | 4 +- gdb/tracectf.c | 31 ++++---- gdb/tracefile-tfile.c | 2 +- gdb/tracefile.c | 4 +- gdb/tracepoint.c | 6 +- gdb/tui/tui-layout.c | 12 +-- gdb/tui/tui-win.c | 4 +- gdb/tui/tui.c | 2 +- gdb/ui-style.c | 4 +- gdb/unittests/child-path-selftests.c | 2 +- gdb/unittests/cli-utils-selftests.c | 14 ++-- gdb/unittests/copy_bitwise-selftests.c | 2 +- gdb/unittests/environ-selftests.c | 34 ++++----- gdb/unittests/intrusive_list-selftests.c | 4 +- gdb/unittests/lookup_name_info-selftests.c | 2 +- gdb/unittests/scoped_mmap-selftests.c | 2 +- gdb/unittests/unique_xmalloc_ptr_char.c | 4 +- gdb/utils.c | 10 +-- gdb/valops.c | 18 ++--- gdb/varobj.c | 2 +- gdb/windows-tdep.c | 8 +- gdb/x86-tdep.c | 4 +- gdb/xcoffread.c | 11 +-- gdb/xml-support.c | 10 +-- gdb/xml-syscall.c | 8 +- gdb/xml-tdesc.c | 17 ++--- gdb/xstormy16-tdep.c | 6 +- gdbserver/gdbreplay.cc | 2 +- gdbserver/linux-arc-low.cc | 2 +- gdbserver/linux-low.cc | 4 +- gdbserver/linux-x86-low.cc | 2 +- gdbserver/linux-x86-tdesc.cc | 3 +- gdbserver/regcache.cc | 2 +- gdbserver/remote-utils.cc | 6 +- gdbserver/server.cc | 105 +++++++++++++------------- gdbserver/thread-db.cc | 2 +- gdbserver/tracepoint.cc | 26 +++---- gdbsupport/common-exceptions.h | 2 +- gdbsupport/osabi.cc | 2 +- gdbsupport/signals.cc | 3 +- 207 files changed, 923 insertions(+), 984 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index de0d7ddb73b..ce00f518299 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -355,8 +355,7 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, break; if (inst.opcode->iclass == addsub_imm - && (inst.opcode->op == OP_ADD - || strcmp ("sub", inst.opcode->name) == 0)) + && (inst.opcode->op == OP_ADD || streq ("sub", inst.opcode->name))) { unsigned rd = inst.operands[0].reg.regno; unsigned rn = inst.operands[1].reg.regno; @@ -382,7 +381,7 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, seen_stack_set = true; } else if (inst.opcode->iclass == addsub_ext - && strcmp ("sub", inst.opcode->name) == 0) + && streq ("sub", inst.opcode->name)) { unsigned rd = inst.operands[0].reg.regno; unsigned rn = inst.operands[1].reg.regno; @@ -433,7 +432,7 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, << inst.operands[1].shifter.amount); } else if (inst.opcode->iclass == log_shift - && strcmp (inst.opcode->name, "orr") == 0) + && streq (inst.opcode->name, "orr")) { unsigned rd = inst.operands[0].reg.regno; unsigned rn = inst.operands[1].reg.regno; @@ -477,7 +476,7 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, else if ((inst.opcode->iclass == ldstpair_off || (inst.opcode->iclass == ldstpair_indexed && inst.operands[2].addr.preind)) - && strcmp ("stp", inst.opcode->name) == 0) + && streq ("stp", inst.opcode->name)) { /* STP with addressing mode Pre-indexed and Base register. */ unsigned rt1; @@ -526,7 +525,7 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, && (inst.opcode->op == OP_STR_POS || inst.opcode->op == OP_STRF_POS))) && inst.operands[1].addr.base_regno == AARCH64_SP_REGNUM - && strcmp ("str", inst.opcode->name) == 0) + && streq ("str", inst.opcode->name)) { /* STR (immediate) */ unsigned int rt = inst.operands[0].reg.regno; diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 0663de01fda..7c691d5a099 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -563,7 +563,7 @@ exp1 : exp primary : primary DOT_ID { - if (strcmp ($2.ptr, "all") == 0) + if (streq ($2.ptr, "all")) ada_wrap<ada_unop_ind_operation> (); else { @@ -1553,7 +1553,7 @@ find_primitive_type (struct parser_state *par_state, const char *name) type = language_lookup_primitive_type (par_state->language (), par_state->gdbarch (), name); - if (type == NULL && strcmp ("system__address", name) == 0) + if (type == NULL && streq ("system__address", name)) type = type_system_address (par_state); if (type != NULL) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 908b33d9c72..ddffc2973e4 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -454,12 +454,11 @@ field_name_match (const char *field_name, const char *target) { int len = strlen (target); - return - (strncmp (field_name, target, len) == 0 - && (field_name[len] == '\0' - || (startswith (field_name + len, "___") - && strcmp (field_name + strlen (field_name) - 6, - "___XVN") != 0))); + return (strncmp (field_name, target, len) == 0 + && (field_name[len] == '\0' + || (startswith (field_name + len, "___") + && !streq (field_name + strlen (field_name) - 6, + "___XVN")))); } @@ -519,7 +518,7 @@ is_suffix (const char *str, const char *suffix) return false; len1 = strlen (str); len2 = strlen (suffix); - return len1 >= len2 && strcmp (str + len1 - len2, suffix) == 0; + return len1 >= len2 && streq (str + len1 - len2, suffix); } /* The contents of value VAL, treated as a value of type TYPE. The @@ -1699,8 +1698,8 @@ ada_fixup_array_indexes_type (struct type *index_desc_type) the field type should be a meaningless integer type whose name is not equal to the field name. */ if (index_desc_type->field (0).type ()->name () != NULL - && strcmp (index_desc_type->field (0).type ()->name (), - index_desc_type->field (0).name ()) == 0) + && streq (index_desc_type->field (0).type ()->name (), + index_desc_type->field (0).name ())) return; /* Fixup each field of INDEX_DESC_TYPE. */ @@ -3850,7 +3849,7 @@ ada_resolve_enum (std::vector<struct block_symbol> &syms, /* We let an anonymous enum type match a non-anonymous one. */ if (type1->name () != nullptr && type2->name () != nullptr - && strcmp (type1->name (), type2->name ()) != 0) + && !streq (type1->name (), type2->name ())) continue; if (ada_identical_enum_types_p (type1, type2)) return i; @@ -4847,10 +4846,9 @@ equiv_types (struct type *type0, struct type *type1) if (type0 == NULL || type1 == NULL || type0->code () != type1->code ()) return false; - if ((type0->code () == TYPE_CODE_STRUCT - || type0->code () == TYPE_CODE_ENUM) + if ((type0->code () == TYPE_CODE_STRUCT || type0->code () == TYPE_CODE_ENUM) && ada_type_name (type0) != NULL && ada_type_name (type1) != NULL - && strcmp (ada_type_name (type0), ada_type_name (type1)) == 0) + && streq (ada_type_name (type0), ada_type_name (type1))) return true; return false; @@ -4894,7 +4892,7 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1) { const char *name0 = sym0->linkage_name (); const char *name1 = sym1->linkage_name (); - return (strcmp (name0, name1) == 0 + return (streq (name0, name1) && sym0->value_address () == sym1->value_address ()); } @@ -4983,7 +4981,7 @@ is_nondebugging_type (struct type *type) { const char *name = ada_type_name (type); - return (name != NULL && strcmp (name, "<variable, no debug info>") == 0); + return (name != NULL && streq (name, "<variable, no debug info>")); } /* Return true if TYPE1 and TYPE2 are two enumeration types @@ -5112,8 +5110,8 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms) if (j != i && !syms[j].symbol->type ()->is_stub () && syms[j].symbol->linkage_name () != NULL - && strcmp (syms[i].symbol->linkage_name (), - syms[j].symbol->linkage_name ()) == 0) + && streq (syms[i].symbol->linkage_name (), + syms[j].symbol->linkage_name ())) remove_p = true; } } @@ -5129,12 +5127,12 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms) { if (i != j && syms[j].symbol->linkage_name () != NULL - && strcmp (syms[i].symbol->linkage_name (), - syms[j].symbol->linkage_name ()) == 0 + && streq (syms[i].symbol->linkage_name (), + syms[j].symbol->linkage_name ()) && (syms[i].symbol->loc_class () == syms[j].symbol->loc_class ()) - && syms[i].symbol->value_address () - == syms[j].symbol->value_address ()) + && (syms[i].symbol->value_address () + == syms[j].symbol->value_address ())) remove_p = true; } } @@ -5820,7 +5818,7 @@ is_name_suffix (const char *str) /* "TKB" suffixes are used for subprograms implementing task bodies. */ - if (strcmp (str, "TKB") == 0) + if (streq (str, "TKB")) return true; #if 0 @@ -5876,14 +5874,14 @@ is_name_suffix (const char *str) return false; if (str[2] == '_') { - if (strcmp (str + 3, "JM") == 0) + if (streq (str + 3, "JM")) return true; /* FIXME: brobecker/2004-09-30: GNAT will soon stop using the LJM suffix in favor of the JM one. But we will still accept LJM as a valid suffix for a reasonable amount of time, just to allow ourselves to debug programs compiled using an older version of GNAT. */ - if (strcmp (str + 3, "LJM") == 0) + if (streq (str + 3, "LJM")) return true; if (str[3] != 'X') return false; @@ -6211,7 +6209,7 @@ ada_is_dispatch_table_ptr_type (struct type *type) if (name == NULL) return false; - return (strcmp (name, "ada__tags__dispatch_table") == 0); + return (streq (name, "ada__tags__dispatch_table")); } /* Return true if TYPE is an interface tag. */ @@ -6224,7 +6222,7 @@ ada_is_interface_tag (struct type *type) if (name == nullptr) return false; - return (strcmp (name, "ada__tags__interface_tag") == 0); + return (streq (name, "ada__tags__interface_tag")); } /* True if field number FIELD_NUM in struct or union type TYPE is supposed @@ -6304,8 +6302,7 @@ ada_is_tag_type (struct type *type) { const char *name = ada_type_name (type->target_type ()); - return (name != NULL - && strcmp (name, "ada__tags__dispatch_table") == 0); + return name != nullptr && streq (name, "ada__tags__dispatch_table"); } } @@ -6654,7 +6651,7 @@ ada_is_wrapper_field (struct type *type, int field_num) { const char *name = type->field (field_num).name (); - if (name != NULL && strcmp (name, "RETVAL") == 0) + if (name != NULL && streq (name, "RETVAL")) { /* This happens in functions with "out" or "in out" parameters which are passed by copy. For such functions, GNAT describes @@ -6667,7 +6664,7 @@ ada_is_wrapper_field (struct type *type, int field_num) return (name != NULL && (startswith (name, "PARENT") - || strcmp (name, "REP") == 0 + || streq (name, "REP") || startswith (name, "_parent") || name[0] == 'S' || name[0] == 'R' || name[0] == 'O')); } @@ -7565,7 +7562,7 @@ find_parallel_type_by_descriptive_type (struct type *type, const char *name) } /* If the names match, stop. */ - if (strcmp (result_name, name) == 0) + if (streq (result_name, name)) break; /* Otherwise, look at the next item on the list, if any. */ @@ -7652,7 +7649,7 @@ dynamic_template_type (struct type *type) { int len = strlen (ada_type_name (type)); - if (len > 6 && strcmp (ada_type_name (type) + len - 6, "___XVE") == 0) + if (len > 6 && streq (ada_type_name (type) + len - 6, "___XVE")) return type; else return ada_find_parallel_type (type, "___XVE"); @@ -8873,10 +8870,10 @@ ada_is_character_type (struct type *type) return (name != NULL && (type->code () == TYPE_CODE_INT || type->code () == TYPE_CODE_RANGE) - && (strcmp (name, "character") == 0 - || strcmp (name, "wide_character") == 0 - || strcmp (name, "wide_wide_character") == 0 - || strcmp (name, "unsigned char") == 0)); + && (streq (name, "character") + || streq (name, "wide_character") + || streq (name, "wide_wide_character") + || streq (name, "unsigned char"))); } /* True if TYPE appears to be an Ada string type. */ @@ -8924,7 +8921,7 @@ ada_is_aligner_type (struct type *type) return (type->code () == TYPE_CODE_STRUCT && type->num_fields () == 1 - && strcmp (type->field (0).name (), "F") == 0); + && streq (type->field (0).name (), "F")); } /* If there is an ___XVS-convention type parallel to SUBTYPE, return @@ -10646,7 +10643,7 @@ convert_char_literal (struct type *type, LONGEST val) const char *ename = field.name (); size_t elen = strlen (ename); - if (elen >= len && strcmp (name, ename + elen - len) == 0) + if (elen >= len && streq (name, ename + elen - len)) return field.loc_enumval (); } return val; @@ -11432,7 +11429,7 @@ ada_ternop_slice_operation::resolve (struct expression *exp, bool ada_is_system_address_type (struct type *type) { - return (type->name () && strcmp (type->name (), "system__address") == 0); + return (type->name () && streq (type->name (), "system__address")); } @@ -12020,8 +12017,8 @@ ada_unhandled_exception_name_addr_from_raise (void) = find_frame_funname (fi, &func_lang, NULL); if (func_name != NULL) { - if (strcmp (func_name.get (), - data->exception_info->catch_exception_sym) == 0) + if (streq (func_name.get (), + data->exception_info->catch_exception_sym)) break; /* We found the frame we were looking for... */ } fi = get_prev_frame (fi); @@ -12773,7 +12770,7 @@ ada_exception_catchpoint_cond_string (const char *excep_string, for (const char *name : standard_exc) { - if (strcmp (name, excep_string) == 0) + if (streq (name, excep_string)) { is_standard_exc = true; break; @@ -12981,7 +12978,7 @@ ada_is_exception_sym (struct symbol *sym) && sym->loc_class () != LOC_BLOCK && sym->loc_class () != LOC_CONST && sym->loc_class () != LOC_UNRESOLVED - && type_name != NULL && strcmp (type_name, "exception") == 0); + && type_name != nullptr && streq (type_name, "exception")); } /* Given a global symbol SYM, return non-zero iff SYM is a non-standard @@ -12995,13 +12992,13 @@ ada_is_non_standard_exception_sym (struct symbol *sym) return false; for (const char *name : standard_exc) - if (strcmp (sym->linkage_name (), name) == 0) + if (streq (sym->linkage_name (), name)) return false; /* A standard exception. */ /* Numeric_Error is also a standard exception, so exclude it. See the STANDARD_EXC description for more details as to why this exception is not listed in that array. */ - if (strcmp (sym->linkage_name (), "numeric_error") == 0) + if (streq (sym->linkage_name (), "numeric_error")) return false; return true; @@ -13029,7 +13026,7 @@ ada_exc_info::operator< (const ada_exc_info &other) const bool ada_exc_info::operator== (const ada_exc_info &other) const { - return addr == other.addr && strcmp (name, other.name) == 0; + return addr == other.addr && streq (name, other.name); } /* Sort EXCEPTIONS using compare_ada_exception_info as the comparison @@ -13373,7 +13370,7 @@ do_exact_match (const char *symbol_search_name, const lookup_name_info &lookup_name, completion_match_result *comp_match_res) { - return strcmp (symbol_search_name, ada_lookup_name (lookup_name)) == 0; + return streq (symbol_search_name, ada_lookup_name (lookup_name)); } /* Build the Ada lookup name for LOOKUP_NAME. */ diff --git a/gdb/amd64-dicos-tdep.c b/gdb/amd64-dicos-tdep.c index 915d1141110..259d4e86c00 100644 --- a/gdb/amd64-dicos-tdep.c +++ b/gdb/amd64-dicos-tdep.c @@ -38,8 +38,7 @@ amd64_dicos_osabi_sniffer (bfd *abfd) /* On amd64-DICOS, the Load Module's "header" section is 72 bytes. */ - if (strcmp (target_name, "elf64-x86-64") == 0 - && dicos_load_module_p (abfd, 72)) + if (streq (target_name, "elf64-x86-64") && dicos_load_module_p (abfd, 72)) return GDB_OSABI_DICOS; return GDB_OSABI_UNKNOWN; diff --git a/gdb/amd64-gnu-tdep.c b/gdb/amd64-gnu-tdep.c index 963ca791b10..366cc4584ad 100644 --- a/gdb/amd64-gnu-tdep.c +++ b/gdb/amd64-gnu-tdep.c @@ -90,7 +90,7 @@ amd64_gnu_sigtramp_p (const frame_info_ptr &this_frame) find_pc_partial_function (pc, &name, NULL, NULL); /* If we have a NAME, we can check for the trampoline function */ - if (name != NULL && strcmp (name, "trampoline") == 0) + if (name != NULL && streq (name, "trampoline")) return 1; return amd64_gnu_sigtramp_start (this_frame) != 0; diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index ff0c58464f2..17d9f78f32d 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -206,7 +206,7 @@ amd64_linux_sigtramp_p (const frame_info_ptr &this_frame) if (name == NULL || strstr (name, "sigaction") != NULL) return (amd64_linux_sigtramp_start (this_frame) != 0); - return (strcmp ("__restore_rt", name) == 0); + return (streq ("__restore_rt", name)); } /* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */ diff --git a/gdb/amd64-obsd-tdep.c b/gdb/amd64-obsd-tdep.c index 81bc5f5d93c..0dbc47be6f9 100644 --- a/gdb/amd64-obsd-tdep.c +++ b/gdb/amd64-obsd-tdep.c @@ -396,10 +396,9 @@ amd64obsd_trapframe_sniffer (const struct frame_unwind *self, return 0; find_pc_partial_function (get_frame_pc (this_frame), &name, NULL, NULL); - return (name && ((strcmp (name, "calltrap") == 0) - || (strcmp (name, "osyscall1") == 0) - || (strcmp (name, "Xsyscall") == 0) - || (startswith (name, "Xintr")))); + return (name != nullptr + && (streq (name, "calltrap") || streq (name, "osyscall1") + || streq (name, "Xsyscall") || startswith (name, "Xintr"))); } static const struct frame_unwind_legacy amd64obsd_trapframe_unwind ( diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index a9ca7b2ac79..85f7ac51a4f 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -444,7 +444,7 @@ amd64_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) bound_minimal_symbol s = lookup_minimal_symbol_by_pc (call_dest); if (s.minsym != NULL && s.minsym->linkage_name () != NULL - && strcmp (s.minsym->linkage_name (), "__main") == 0) + && streq (s.minsym->linkage_name (), "__main")) pc += 5; } } @@ -1379,7 +1379,7 @@ amd64_cygwin_core_osabi_sniffer (bfd *abfd) /* Cygwin uses elf core dumps. Do not claim all ELF executables, check whether there is a .reg section of proper size. */ - if (strcmp (target_name, "elf64-x86-64") == 0) + if (streq (target_name, "elf64-x86-64")) { asection *section = bfd_get_section_by_name (abfd, ".reg"); if (section != nullptr diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 8de7655e638..ea0b3c111f9 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -295,7 +295,7 @@ default_floatformat_for_type (struct gdbarch *gdbarch, /* Check if this is a bfloat16 type. It has the same size as the IEEE half float type, so we use the base type name to tell them apart. */ - if (name != nullptr && strcmp (name, "__bf16") == 0 + if (name != nullptr && streq (name, "__bf16") && len == gdbarch_bfloat16_bit (gdbarch)) format = gdbarch_bfloat16_format (gdbarch); else if (len == gdbarch_half_bit (gdbarch)) @@ -553,7 +553,7 @@ set_architecture (const char *ignore_args, { struct gdbarch_info info; - if (strcmp (set_architecture_string, "auto") == 0) + if (streq (set_architecture_string, "auto")) { target_architecture_user = NULL; if (!gdbarch_update_p (current_inferior (), info)) diff --git a/gdb/arm-pikeos-tdep.c b/gdb/arm-pikeos-tdep.c index ce7297d51be..8b84cc3f68a 100644 --- a/gdb/arm-pikeos-tdep.c +++ b/gdb/arm-pikeos-tdep.c @@ -58,12 +58,10 @@ arm_pikeos_osabi_sniffer (bfd *abfd) { const char *name = bfd_asymbol_name (sym); - if (strcmp (name, "_vm_stack") == 0 - || strcmp (name, "__p4_stack") == 0) + if (streq (name, "_vm_stack") || streq (name, "__p4_stack")) pikeos_stack_found = 1; - if (strcmp (name, "_vm_stack_size") == 0 - || strcmp (name, "__p4_stack_end") == 0) + if (streq (name, "_vm_stack_size") || streq (name, "__p4_stack_end")) pikeos_stack_size_found = 1; } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index dabae0aec0f..83dc71cc9da 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -734,9 +734,9 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr) return 1; /* If the user wants to override the symbol table, let him. */ - if (strcmp (arm_force_mode_string, "arm") == 0) + if (streq (arm_force_mode_string, "arm")) return 0; - if (strcmp (arm_force_mode_string, "thumb") == 0) + if (streq (arm_force_mode_string, "thumb")) return 1; /* ARM v6-M and v7-M are always in Thumb mode. */ @@ -754,9 +754,9 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr) return (MSYMBOL_IS_SPECIAL (sym.minsym)); /* If the user wants to override the fallback mode, let them. */ - if (strcmp (arm_fallback_mode_string, "arm") == 0) + if (streq (arm_fallback_mode_string, "arm")) return 0; - if (strcmp (arm_fallback_mode_string, "thumb") == 0) + if (streq (arm_fallback_mode_string, "thumb")) return 1; /* If we couldn't find any symbol, but we're talking to a running @@ -9408,7 +9408,7 @@ arm_skip_stub (const frame_info_ptr &frame, CORE_ADDR pc) int offset = strlen (name) - 2; for (regno = 0; regno <= 14; regno++) - if (strcmp (&name[offset], table[regno]) == 0) + if (streq (&name[offset], table[regno])) return get_frame_register_unsigned (frame, regno); } @@ -9476,7 +9476,7 @@ set_fp_model_sfunc (const char *args, int from_tty, int fp_model; for (fp_model = ARM_FLOAT_AUTO; fp_model != ARM_FLOAT_LAST; fp_model++) - if (strcmp (current_fp_model, fp_model_strings[fp_model]) == 0) + if (streq (current_fp_model, fp_model_strings[fp_model])) { arm_fp_model = (enum arm_float_model) fp_model; break; @@ -9516,7 +9516,7 @@ arm_set_abi (const char *args, int from_tty, int arm_abi; for (arm_abi = ARM_ABI_AUTO; arm_abi != ARM_ABI_LAST; arm_abi++) - if (strcmp (arm_abi_string, arm_abi_strings[arm_abi]) == 0) + if (streq (arm_abi_string, arm_abi_strings[arm_abi])) { arm_abi_global = (enum arm_abi_kind) arm_abi; break; @@ -10043,7 +10043,7 @@ arm_code_of_frame_writable (struct gdbarch *gdbarch, const frame_info_ptr &frame static const char * arm_gnu_triplet_regexp (struct gdbarch *gdbarch) { - if (strcmp (gdbarch_bfd_arch_info (gdbarch)->arch_name, "arm") == 0) + if (streq (gdbarch_bfd_arch_info (gdbarch)->arch_name, "arm")) return "arm(v[^- ]*)?"; return gdbarch_bfd_arch_info (gdbarch)->arch_name; } @@ -11010,7 +11010,7 @@ INIT_GDB_FILE (arm_tdep) size_t offset = strlen ("reg-names-"); const char *style = disasm_options->name[i]; valid_disassembly_styles[j++] = &style[offset]; - if (strcmp (&style[offset], "std") == 0) + if (streq (&style[offset], "std")) disassembly_style = &style[offset]; length = snprintf (rdptr, rest, "%s - %s\n", &style[offset], disasm_options->description[i]); diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c index 39593f4c3f3..1a03e63bb68 100644 --- a/gdb/arm-wince-tdep.c +++ b/gdb/arm-wince-tdep.c @@ -103,7 +103,7 @@ arm_wince_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) if (s.minsym != NULL && s.minsym->linkage_name () != NULL - && strcmp (s.minsym->linkage_name (), "__gccmain") == 0) + && streq (s.minsym->linkage_name (), "__gccmain")) pc += 4; } @@ -143,7 +143,7 @@ arm_wince_osabi_sniffer (bfd *abfd) { const char *target_name = bfd_get_target (abfd); - if (strcmp (target_name, "pei-arm-wince-little") == 0) + if (streq (target_name, "pei-arm-wince-little")) return GDB_OSABI_WINCE; return GDB_OSABI_UNKNOWN; diff --git a/gdb/auto-load.c b/gdb/auto-load.c index b5fec13743c..7bb062ed432 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -279,7 +279,7 @@ auto_load_safe_path_vec_update (void) if (debug_auto_load) { - if (strcmp (in_vec.get (), original.get ()) == 0) + if (streq (in_vec.get (), original.get ())) auto_load_debug_printf ("Using directory \"%s\".", in_vec.get ()); else @@ -288,7 +288,7 @@ auto_load_safe_path_vec_update (void) } /* If gdb_realpath returns a different content, append it. */ - if (strcmp (real_path.get (), in_vec.get ()) != 0) + if (!streq (real_path.get (), in_vec.get ())) { auto_load_debug_printf ("And canonicalized as \"%s\".", real_path.get ()); @@ -468,12 +468,12 @@ filename_is_in_auto_load_safe_path_vec (const char *filename, if (*filename_realp == NULL) { *filename_realp = gdb_realpath (filename); - if (debug_auto_load && strcmp (filename_realp->get (), filename) != 0) + if (debug_auto_load && !streq (filename_realp->get (), filename)) auto_load_debug_printf ("Resolved file \"%s\" as \"%s\".", filename, filename_realp->get ()); } - if (strcmp (filename_realp->get (), filename) != 0) + if (!streq (filename_realp->get (), filename)) for (const gdb::unique_xmalloc_ptr<char> &p : auto_load_safe_path_vec) if (filename_is_in_pattern (filename_realp->get (), p.get ())) { @@ -629,7 +629,7 @@ eq_loaded_script_entry (const void *a, const void *b) const struct loaded_script *ea = (const struct loaded_script *) a; const struct loaded_script *eb = (const struct loaded_script *) b; - return strcmp (ea->name, eb->name) == 0 && ea->language == eb->language; + return streq (ea->name, eb->name) && ea->language == eb->language; } /* Initialize the table to track loaded scripts. @@ -915,7 +915,7 @@ auto_load_objfile_script (struct objfile *objfile, (bfd_get_debug_link_info (parent->obfd.get (), &crc32)); if (debuglink.get () != nullptr - && strcmp (debuglink.get (), lbasename (realname.get ())) != 0) + && !streq (debuglink.get (), lbasename (realname.get ()))) { /* Replace the last component of the parent's path with the debuglink name. */ @@ -1261,8 +1261,7 @@ print_script (struct loaded_script *script) uiout->text ("\n"); /* If the name isn't the full path, print it too. */ - if (script->full_path != NULL - && strcmp (script->name, script->full_path) != 0) + if (script->full_path != NULL && !streq (script->name, script->full_path)) { uiout->text ("\tfull name: "); uiout->field_string ("full_path", script->full_path); diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 8b88f69a04f..f445a2db6ba 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1412,7 +1412,7 @@ avr_address_class_name_to_type_flags (struct gdbarch *gdbarch, const char* name, type_instance_flags *type_flags_ptr) { - if (strcmp (name, "flash") == 0) + if (streq (name, "flash")) { *type_flags_ptr = AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH; return true; diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 2a96ff1c621..498a307c868 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1345,7 +1345,7 @@ gen_struct_ref_recursive (struct agent_expr *ax, struct axs_value *value, if (this_name) { - if (strcmp (field, this_name) == 0) + if (streq (field, this_name)) { /* Note that bytecodes for the struct's base (aka "this") will have been generated already, which will @@ -1486,7 +1486,7 @@ gen_struct_elt_for_reference (struct agent_expr *ax, struct axs_value *value, { const char *t_field_name = t->field (i).name (); - if (t_field_name && strcmp (t_field_name, fieldname) == 0) + if (t_field_name && streq (t_field_name, fieldname)) { if (t->field (i).is_static ()) { @@ -2478,7 +2478,7 @@ agent_eval_command_one (const char *exp, int eval, CORE_ADDR pc) agent_expr_up agent; arg = exp; - if (!eval && strcmp (arg, "$_ret") == 0) + if (!eval && streq (arg, "$_ret")) { agent = gen_trace_for_return_address (pc, get_current_arch (), trace_string); diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c index 5e133016645..2a9e458e51c 100644 --- a/gdb/bfin-tdep.c +++ b/gdb/bfin-tdep.c @@ -597,7 +597,7 @@ bfin_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) *size = kind; - if (strcmp (target_shortname (), "sim") == 0) + if (streq (target_shortname (), "sim")) return bfin_sim_breakpoint; else return bfin_breakpoint; diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c index fbc4458145a..ea85083b6f8 100644 --- a/gdb/break-catch-sig.c +++ b/gdb/break-catch-sig.c @@ -87,7 +87,7 @@ signal_to_name_or_int (enum gdb_signal sig) { const char *result = gdb_signal_to_name (sig); - if (strcmp (result, "?") == 0) + if (streq (result, "?")) result = plongest (sig); return result; diff --git a/gdb/break-cond-parse.c b/gdb/break-cond-parse.c index e2283a8d59f..4fec4dbef94 100644 --- a/gdb/break-cond-parse.c +++ b/gdb/break-cond-parse.c @@ -588,9 +588,9 @@ test (const char *input, const char *condition, int thread = -1, if ((condition == nullptr) != (extracted_condition.get () == nullptr) || (condition != nullptr - && strcmp (condition, extracted_condition.get ()) != 0) + && !streq (condition, extracted_condition.get ())) || (rest == nullptr) != (extracted_rest.get () == nullptr) - || (rest != nullptr && strcmp (rest, extracted_rest.get ()) != 0) + || (rest != nullptr && !streq (rest, extracted_rest.get ())) || thread != extracted_thread || inferior != extracted_inferior || task != extracted_task diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index a48a2ceb4f3..d7be1b44229 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4836,7 +4836,7 @@ breakpoint_about_to_proceed (void) static bool command_line_is_silent (struct command_line *cmd) { - return cmd && (strcmp ("silent", cmd->line) == 0); + return cmd && (streq ("silent", cmd->line)); } /* Sets the $_hit_bpnum and $_hit_locno to bpnum and locno. @@ -6325,7 +6325,7 @@ wrap_indent_at_field (struct ui_out *uiout, const char *col_name) total_width = 0; for (i = 1; uiout->query_table_field (i, &width, &align, &text); i++) { - if (strcmp (text, col_name) == 0) + if (streq (text, col_name)) return total_width; total_width += width + 1; @@ -8723,9 +8723,9 @@ update_dprintf_command_list (struct breakpoint *b) if (*dprintf_args != '"') error (_("Bad format string, missing '\"'.")); - if (strcmp (dprintf_style, dprintf_style_gdb) == 0) + if (streq (dprintf_style, dprintf_style_gdb)) printf_line = xstrprintf ("printf %s", dprintf_args); - else if (strcmp (dprintf_style, dprintf_style_call) == 0) + else if (streq (dprintf_style, dprintf_style_call)) { if (dprintf_function.empty ()) error (_("No function supplied for dprintf call")); @@ -8740,7 +8740,7 @@ update_dprintf_command_list (struct breakpoint *b) dprintf_function.c_str (), dprintf_args); } - else if (strcmp (dprintf_style, dprintf_style_agent) == 0) + else if (streq (dprintf_style, dprintf_style_agent)) { if (target_can_run_breakpoint_commands ()) printf_line = xstrprintf ("agent-printf %s", dprintf_args); @@ -13102,8 +13102,7 @@ update_breakpoint_locations (code_breakpoint *b, { for (bp_location &l : b->locations ()) if (l.function_name - && strcmp (e.function_name.get (), - l.function_name.get ()) == 0) + && streq (e.function_name.get (), l.function_name.get ())) { l.enabled = e.enabled; break; diff --git a/gdb/bt-utils.c b/gdb/bt-utils.c index c2566931bf2..7fc8d04f306 100644 --- a/gdb/bt-utils.c +++ b/gdb/bt-utils.c @@ -104,7 +104,7 @@ libbacktrace_print (void *data, uintptr_t pc, const char *filename, } sig_write ("\n"); - return function != nullptr && strcmp (function, "main") == 0; + return function != nullptr && streq (function, "main"); } /* Write a backtrace to GDB's stderr in an async safe manner. This is a diff --git a/gdb/btrace.c b/gdb/btrace.c index 27487f526ab..6a8f0f549d1 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -196,7 +196,7 @@ ftrace_function_switched (const struct btrace_function *bfun, /* If the minimal symbol changed, we certainly switched functions. */ if (mfun != NULL && msym != NULL - && strcmp (mfun->linkage_name (), msym->linkage_name ()) != 0) + && !streq (mfun->linkage_name (), msym->linkage_name ())) return 1; /* If the symbol changed, we certainly switched functions. */ @@ -205,7 +205,7 @@ ftrace_function_switched (const struct btrace_function *bfun, const char *bfname, *fname; /* Check the function name. */ - if (strcmp (fun->linkage_name (), sym->linkage_name ()) != 0) + if (!streq (fun->linkage_name (), sym->linkage_name ())) return 1; /* Check the location of those functions, as well. */ @@ -604,7 +604,7 @@ ftrace_update_function (struct btrace_thread_info *btinfo, create a stack back trace with the same function names but different frame id's. This will confuse stepping. */ fname = ftrace_print_function_name (bfun); - if (strcmp (fname, "_dl_runtime_resolve") == 0) + if (streq (fname, "_dl_runtime_resolve")) return ftrace_new_tailcall (btinfo, mfun, fun); return ftrace_new_return (btinfo, mfun, fun); @@ -3316,7 +3316,7 @@ maint_btrace_packet_history_cmd (const char *arg, int from_tty) return; } - if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0) + if (arg == NULL || *arg == 0 || streq (arg, "+")) { from = to; @@ -3324,7 +3324,7 @@ maint_btrace_packet_history_cmd (const char *arg, int from_tty) size = end - from; to = from + size; } - else if (strcmp (arg, "-") == 0) + else if (streq (arg, "-")) { to = from; diff --git a/gdb/c-lang.c b/gdb/c-lang.c index a8e3a467bec..fdb5be7b2b7 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -90,19 +90,19 @@ classify_type (struct type *elttype, struct gdbarch *gdbarch, goto done; } - if (!strcmp (name, "wchar_t")) + if (streq (name, "wchar_t")) { result = C_WIDE_CHAR; goto done; } - if (!strcmp (name, "char16_t")) + if (streq (name, "char16_t")) { result = C_CHAR_16; goto done; } - if (!strcmp (name, "char32_t")) + if (streq (name, "char32_t")) { result = C_CHAR_32; goto done; diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 76472c23254..821b78becf4 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -128,7 +128,7 @@ c_print_type_1 (struct type *type, || code == TYPE_CODE_METHODPTR || TYPE_IS_REFERENCE (type)))) gdb_puts (" ", stream); - need_post_space = (varstring != NULL && strcmp (varstring, "") != 0); + need_post_space = (varstring != NULL && !streq (varstring, "")); c_type_print_varspec_prefix (type, stream, show, 0, need_post_space, language, flags, podata); } @@ -181,8 +181,7 @@ c_print_typedef (struct type *type, gdb_printf (stream, "typedef "); type_print (type, "", stream, -1); if ((new_symbol->type ())->name () == 0 - || strcmp ((new_symbol->type ())->name (), - new_symbol->linkage_name ()) != 0 + || !streq ((new_symbol->type ())->name (), new_symbol->linkage_name ()) || new_symbol->type ()->code () == TYPE_CODE_TYPEDEF) gdb_printf (stream, " %s", new_symbol->print_name ()); gdb_printf (stream, ";"); @@ -1100,8 +1099,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i); const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i); const char *name = type->name (); - int is_constructor = name && strcmp (method_name, - name) == 0; + int is_constructor = name != nullptr && streq (method_name, name); for (j = 0; j < len2; j++) { diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 522b42497d1..9f9f61ea2e0 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -38,9 +38,9 @@ static int textual_name (const char *name) { - return (!strcmp (name, "wchar_t") - || !strcmp (name, "char16_t") - || !strcmp (name, "char32_t")); + return (streq (name, "wchar_t") + || streq (name, "char16_t") + || streq (name, "char32_t")); } /* Apply a heuristic to decide whether an array of TYPE or a pointer @@ -500,8 +500,7 @@ c_value_print (struct value *val, struct ui_file *stream, if (original_type->code () == TYPE_CODE_PTR && original_type->name () == NULL && original_type->target_type ()->name () != NULL - && (strcmp (original_type->target_type ()->name (), - "char") == 0 + && (streq (original_type->target_type ()->name (), "char") || textual_name (original_type->target_type ()->name ()))) { /* Print nothing. */ diff --git a/gdb/charset.c b/gdb/charset.c index 2f0ceafd57d..1b0725b5078 100644 --- a/gdb/charset.c +++ b/gdb/charset.c @@ -106,16 +106,16 @@ static iconv_t phony_iconv_open (const char *to, const char *from) { - if (strcmp (to, "wchar_t") && strcmp (to, GDB_DEFAULT_HOST_CHARSET)) + if (!streq (to, "wchar_t") && !streq (to, GDB_DEFAULT_HOST_CHARSET)) return -1; - if (!strcmp (from, "UTF-32BE") || !strcmp (from, "UTF-32")) + if (streq (from, "UTF-32BE") || streq (from, "UTF-32")) return 1; - if (!strcmp (from, "UTF-32LE")) + if (streq (from, "UTF-32LE")) return 2; - if (strcmp (from, "wchar_t") && strcmp (from, GDB_DEFAULT_HOST_CHARSET)) + if (!streq (from, "wchar_t") && !streq (from, GDB_DEFAULT_HOST_CHARSET)) return -1; return 0; @@ -232,7 +232,7 @@ show_host_charset_name (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - if (!strcmp (value, "auto")) + if (streq (value, "auto")) gdb_printf (file, _("The host character set is \"auto; currently %s\".\n"), auto_host_charset_name); @@ -245,7 +245,7 @@ static void show_target_charset_name (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - if (!strcmp (value, "auto")) + if (streq (value, "auto")) gdb_printf (file, _("The target character set is \"auto; " "currently %s\".\n"), @@ -262,7 +262,7 @@ show_target_wide_charset_name (struct ui_file *file, struct cmd_list_element *c, const char *value) { - if (!strcmp (value, "auto")) + if (streq (value, "auto")) gdb_printf (file, _("The target wide character set is \"auto; " "currently %s\".\n"), @@ -311,7 +311,7 @@ set_be_le_names (struct gdbarch *gdbarch) target_wide_charset_be_name = NULL; target_wide = target_wide_charset_name; - if (!strcmp (target_wide, "auto")) + if (streq (target_wide, "auto")) target_wide = gdbarch_auto_wide_charset (gdbarch); len = strlen (target_wide); @@ -344,7 +344,7 @@ validate (struct gdbarch *gdbarch) const char *target_cset = target_charset (gdbarch); const char *target_wide_cset = target_wide_charset_name; - if (!strcmp (target_wide_cset, "auto")) + if (streq (target_wide_cset, "auto")) target_wide_cset = gdbarch_auto_wide_charset (gdbarch); desc = iconv_open (target_wide_cset, host_cset); @@ -416,7 +416,7 @@ show_charset (struct ui_file *file, int from_tty, const char * host_charset (void) { - if (!strcmp (host_charset_name, "auto")) + if (streq (host_charset_name, "auto")) return auto_host_charset_name; return host_charset_name; } @@ -424,7 +424,7 @@ host_charset (void) const char * target_charset (struct gdbarch *gdbarch) { - if (!strcmp (target_charset_name, "auto")) + if (streq (target_charset_name, "auto")) return default_auto_charset (); return target_charset_name; } @@ -446,7 +446,7 @@ target_wide_charset (struct gdbarch *gdbarch) return target_wide_charset_le_name; } - if (!strcmp (target_wide_charset_name, "auto")) + if (streq (target_wide_charset_name, "auto")) return gdbarch_auto_wide_charset (gdbarch); return target_wide_charset_name; @@ -505,7 +505,7 @@ convert_between_encodings (const char *from, const char *to, unsigned int space_request; /* Often, the host and target charsets will be the same. */ - if (!strcmp (from, to)) + if (streq (from, to)) { obstack_grow (output, bytes, num_bytes); return; @@ -1004,7 +1004,7 @@ INIT_GDB_FILE (charset) /* Solaris will return `646' here -- but the Solaris iconv then does not accept this. Darwin (and maybe FreeBSD) may return "" here, which GNU libiconv doesn't like (infinite loop). */ - if (!strcmp (auto_host_charset_name, "646") || !*auto_host_charset_name) + if (streq (auto_host_charset_name, "646") || !*auto_host_charset_name) auto_host_charset_name = "ASCII"; auto_target_charset_name = auto_host_charset_name; #elif defined (USE_WIN32API) @@ -1031,7 +1031,7 @@ INIT_GDB_FILE (charset) auto_target_charset_name = auto_host_charset_name; /* Windows Terminal supports Emoji when using UTF-8 output. */ - if (strcmp (w32_host_default_charset, "UTF-8") != 0) + if (!streq (w32_host_default_charset, "UTF-8")) no_emojis (); } #endif @@ -1039,7 +1039,7 @@ INIT_GDB_FILE (charset) /* Recall that the first element is always "auto". */ host_charset_name = charset_enum[0]; - gdb_assert (strcmp (host_charset_name, "auto") == 0); + gdb_assert (streq (host_charset_name, "auto")); add_setshow_enum_cmd ("charset", class_support, charset_enum, &host_charset_name, _("\ Set the host and target character sets."), _("\ @@ -1070,7 +1070,7 @@ To see a list of the character sets GDB supports, type `set host-charset <TAB>'. /* Recall that the first element is always "auto". */ target_charset_name = charset_enum[0]; - gdb_assert (strcmp (target_charset_name, "auto") == 0); + gdb_assert (streq (target_charset_name, "auto")); add_setshow_enum_cmd ("target-charset", class_support, charset_enum, &target_charset_name, _("\ Set the target character set."), _("\ @@ -1085,7 +1085,7 @@ To see a list of the character sets GDB supports, type `set target-charset'<TAB> /* Recall that the first element is always "auto". */ target_wide_charset_name = charset_enum[0]; - gdb_assert (strcmp (target_wide_charset_name, "auto") == 0); + gdb_assert (streq (target_wide_charset_name, "auto")); add_setshow_enum_cmd ("target-wide-charset", class_support, charset_enum, &target_wide_charset_name, _("\ diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 760889fbc72..e58553245b3 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -497,7 +497,7 @@ pwd_command (const char *args, int from_tty) error (_("Error finding name of working directory: %s"), safe_strerror (errno)); - if (strcmp (cwd.get (), current_directory) != 0) + if (!streq (cwd.get (), current_directory)) gdb_printf (_("Working directory %ps\n (canonically %ps).\n"), styled_string (file_name_style.style (), current_directory), @@ -2193,13 +2193,12 @@ alias_command (const char *args, int from_tty) if (alias_cmd != nullptr && alias_cmd->prefix == prefix_cmd - && strcmp (alias_name, alias_cmd->name) == 0) + && streq (alias_name, alias_cmd->name)) error (_("Alias already exists: %s"), alias); /* Check ALIAS differs from the found CMD. */ - if (cmd->prefix == prefix_cmd - && strcmp (alias_name, cmd->name) == 0) + if (cmd->prefix == prefix_cmd && streq (alias_name, cmd->name)) error (_("Alias %s is the name of an existing command"), alias); } } diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 285f5f1f0c4..de40faeed59 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -1528,7 +1528,7 @@ delete_cmd (const char *name, struct cmd_list_element **list, for (iter = *previous_chain_ptr; iter; iter = *previous_chain_ptr) { - if (strcmp (iter->name, name) == 0) + if (streq (iter->name, name)) { if (iter->destroyer) iter->destroyer (iter, iter->context ()); @@ -1638,8 +1638,7 @@ user_documented_alias (const cmd_list_element &alias) gdb_assert (alias.is_alias ()); /* Alias is user documented if it has an allocated documentation that differs from the aliased command. */ - return (alias.doc_allocated - && strcmp (alias.doc, alias.alias_target->doc) != 0); + return alias.doc_allocated && !streq (alias.doc, alias.alias_target->doc); } /* Print the definition of alias C using title style for alias @@ -1838,7 +1837,7 @@ help_cmd (const char *command, struct ui_file *stream) return; } - if (strcmp (command, "all") == 0) + if (streq (command, "all")) { help_all (stream); return; @@ -2502,7 +2501,7 @@ lookup_cmd_exact (const char *name, const char *tem = name; struct cmd_list_element *cmd = lookup_cmd (&tem, list, "", NULL, -1, ignore_help_classes); - if (cmd != nullptr && strcmp (name, cmd->name) != 0) + if (cmd != nullptr && !streq (name, cmd->name)) cmd = nullptr; return cmd; } diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index 3084aa11128..59c5827c093 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -193,7 +193,7 @@ dump_memory_to_file (const char *cmd, const char *mode, const char *file_format) read_memory (lo, buf.data (), count); /* Have everything. Open/write the data. */ - if (file_format == NULL || strcmp (file_format, "binary") == 0) + if (file_format == NULL || streq (file_format, "binary")) dump_binary_file (filename.get (), mode, buf.data (), count); else dump_bfd_file (filename.get (), mode, file_format, lo, buf.data (), count); @@ -221,7 +221,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) error (_("Invalid expression.")); /* Have everything. Open/write the data. */ - if (file_format == NULL || strcmp (file_format, "binary") == 0) + if (file_format == NULL || streq (file_format, "binary")) dump_binary_file (filename.get (), mode, val->contents ().data (), val->type ()->length ()); else diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c index 24409d0e007..ded79adaa14 100644 --- a/gdb/cli/cli-option.c +++ b/gdb/cli/cli-option.c @@ -588,12 +588,12 @@ complete_options (completion_tracker &tracker, *args = skip_spaces (*args); completion_info.word = *args; - if (strcmp (*args, "-") == 0) + if (streq (*args, "-")) { complete_on_options (options_group, tracker, *args + 1, completion_info.word); } - else if (strcmp (*args, "--") == 0) + else if (streq (*args, "--")) { tracker.add_completion (make_unique_xstrdup (*args)); } diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index e403f7e9b5e..253e63af570 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -1662,7 +1662,7 @@ commands_equal (const command_line *a, const command_line *b) } /* Check lines are identical. */ - if (a->line != nullptr && strcmp (a->line, b->line) != 0) + if (a->line != nullptr && !streq (a->line, b->line)) return false; /* Check body_list_0. */ diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c index ac4fb27e725..272e857c2a5 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -89,13 +89,13 @@ terminal_supports_styling () /* Windows doesn't by default define $TERM, but can support styles regardless. */ #ifndef _WIN32 - if (term == nullptr || strcmp (term, "dumb") == 0) + if (term == nullptr || streq (term, "dumb")) return false; #else /* But if they do define $TERM, let us behave the same as on Posix platforms, for the benefit of programs which invoke GDB as their back-end. */ - if (term != nullptr && strcmp (term, "dumb") == 0) + if (term != nullptr && streq (term, "dumb")) return false; #endif @@ -438,7 +438,7 @@ emojis_ok () return false; if (emoji_styling == AUTO_BOOLEAN_TRUE) return true; - return strcmp (host_charset (), "UTF-8") == 0; + return streq (host_charset (), "UTF-8"); } /* See cli-style.h. */ diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c index 5073a4b0c4b..48963ff8d05 100644 --- a/gdb/coff-pe-read.c +++ b/gdb/coff-pe-read.c @@ -71,17 +71,17 @@ struct read_pe_section_data static int read_pe_section_index (const char *section_name) { - if (strcmp (section_name, ".text") == 0) + if (streq (section_name, ".text")) { return PE_SECTION_INDEX_TEXT; } - else if (strcmp (section_name, ".data") == 0) + else if (streq (section_name, ".data")) { return PE_SECTION_INDEX_DATA; } - else if (strcmp (section_name, ".bss") == 0) + else if (streq (section_name, ".bss")) { return PE_SECTION_INDEX_BSS; } @@ -336,15 +336,15 @@ read_pe_exported_syms (minimal_symbol_reader &reader, section_data[PE_SECTION_INDEX_BSS].ms_type = mst_bss; section_data[PE_SECTION_INDEX_BSS].section_name = ".bss"; - is_pe64 = (strcmp (target, "pe-x86-64") == 0 - || strcmp (target, "pei-x86-64") == 0 - || strcmp (target, "pe-aarch64") == 0 - || strcmp (target, "pei-aarch64") == 0 - || strcmp (target, "pei-aarch64-little") == 0); - is_pe32 = (strcmp (target, "pe-i386") == 0 - || strcmp (target, "pei-i386") == 0 - || strcmp (target, "pe-arm-wince-little") == 0 - || strcmp (target, "pei-arm-wince-little") == 0); + is_pe64 = (streq (target, "pe-x86-64") + || streq (target, "pei-x86-64") + || streq (target, "pe-aarch64") + || streq (target, "pei-aarch64") + || streq (target, "pei-aarch64-little")); + is_pe32 = (streq (target, "pe-i386") + || streq (target, "pei-i386") + || streq (target, "pe-arm-wince-little") + || streq (target, "pei-arm-wince-little")); /* Possibly print a debug message about DLL not having a valid format. */ auto maybe_print_debug_msg = [&] () -> void { @@ -406,10 +406,10 @@ read_pe_exported_syms (minimal_symbol_reader &reader, || bfd_read (sname, sizeof (sname), dll) != sizeof (sname)) return maybe_print_debug_msg (); - if ((strcmp (sname, ".edata") == 0) + if (streq (sname, ".edata") || (vaddr <= export_opthdrrva && export_opthdrrva < vaddr + vsize)) { - if (strcmp (sname, ".edata") != 0) + if (!streq (sname, ".edata")) { if (debug_coff_pe_read) gdb_printf (gdb_stdlog, _("Export RVA for dll " @@ -636,15 +636,15 @@ pe_text_section_offset (struct bfd *abfd) target = bfd_get_target (abfd); - is_pe64 = (strcmp (target, "pe-x86-64") == 0 - || strcmp (target, "pei-x86-64") == 0 - || strcmp (target, "pe-aarch64") == 0 - || strcmp (target, "pei-aarch64") == 0 - || strcmp (target, "pei-aarch64-little") == 0); - is_pe32 = (strcmp (target, "pe-i386") == 0 - || strcmp (target, "pei-i386") == 0 - || strcmp (target, "pe-arm-wince-little") == 0 - || strcmp (target, "pei-arm-wince-little") == 0); + is_pe64 = (streq (target, "pe-x86-64") + || streq (target, "pei-x86-64") + || streq (target, "pe-aarch64") + || streq (target, "pei-aarch64") + || streq (target, "pei-aarch64-little")); + is_pe32 = (streq (target, "pe-i386") + || streq (target, "pei-i386") + || streq (target, "pe-arm-wince-little") + || streq (target, "pei-arm-wince-little")); if (!is_pe32 && !is_pe64) { @@ -677,7 +677,7 @@ pe_text_section_offset (struct bfd *abfd) || bfd_read (sname, SCNNMLEN, abfd) != SCNNMLEN) return DEFAULT_COFF_PE_TEXT_SECTION_OFFSET; sname[SCNNMLEN] = '\0'; - if (strcmp (sname, ".text") == 0) + if (streq (sname, ".text")) return vaddr; } diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index bbee2f7cc56..fe48979e4f6 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -561,7 +561,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base) struct value *regval; CORE_ADDR inferior_addr; - if (strcmp (reg_name, COMPILE_I_SIMPLE_REGISTER_DUMMY) == 0) + if (streq (reg_name, COMPILE_I_SIMPLE_REGISTER_DUMMY)) continue; if ((reg_bitpos % 8) != 0 || reg_bitsize != 0) @@ -694,7 +694,7 @@ compile_object_load (const compile_file_names &file_names, continue; sym->flags = BSF_GLOBAL; sym->section = bfd_abs_section_ptr; - if (strcmp (sym->name, "_GLOBAL_OFFSET_TABLE_") == 0) + if (streq (sym->name, "_GLOBAL_OFFSET_TABLE_")) { if (compile_debug) gdb_printf (gdb_stdlog, @@ -707,7 +707,7 @@ compile_object_load (const compile_file_names &file_names, sym->value = 0; continue; } - if (strcmp (sym->name, ".TOC.") == 0) + if (streq (sym->name, ".TOC.")) { /* Handle the .TOC. symbol as the linker would do. Set the .TOC. sections value to 0x8000 (see bfd/elf64-ppc.c TOC_BASE_OFF); diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 2a9702ee852..a64297bcbe1 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -462,7 +462,7 @@ filter_args (char **argv) for (destv = argv; *argv != NULL; argv++) { /* -fpreprocessed may get in commonly from ccache. */ - if (strcmp (*argv, "-fpreprocessed") == 0) + if (streq (*argv, "-fpreprocessed")) { xfree (*argv); continue; @@ -767,7 +767,7 @@ compile_register_name_demangle (struct gdbarch *gdbarch, regname += 2; for (regnum = 0; regnum < gdbarch_num_regs (gdbarch); regnum++) - if (strcmp (regname, gdbarch_register_name (gdbarch, regnum)) == 0) + if (streq (regname, gdbarch_register_name (gdbarch, regnum))) return regnum; error (_("Cannot find gdbarch register \"%s\"."), regname); diff --git a/gdb/completer.c b/gdb/completer.c index 01c607c3850..8c70a61cdec 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -90,7 +90,7 @@ public: /* Return true of the name in this hash entry is STR. */ bool is_name_eq (const char *str) const { - return strcmp (m_name.get (), str) == 0; + return streq (m_name.get (), str); } /* Return the hash value based on the name of the entry. */ @@ -2200,7 +2200,7 @@ signal_completer (struct cmd_list_element *ignore, signame = gdb_signal_to_name ((enum gdb_signal) signum); /* Ignore the unknown signal case. */ - if (!signame || strcmp (signame, "?") == 0) + if (!signame || streq (signame, "?")) continue; if (strncasecmp (signame, word, len) == 0) diff --git a/gdb/corelow.c b/gdb/corelow.c index f6e8179d1f4..79b902118fa 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -1345,13 +1345,13 @@ get_core_registers_cb (const char *sect_name, int supply_size, int collect_size, if (!variable_size_section) gdb_assert (supply_size == collect_size); - if (strcmp (sect_name, ".reg") == 0) + if (streq (sect_name, ".reg")) { required = true; if (human_name == NULL) human_name = "general-purpose"; } - else if (strcmp (sect_name, ".reg2") == 0) + else if (streq (sect_name, ".reg2")) { if (human_name == NULL) human_name = "floating-point"; diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c index 4c2429dafc7..a2189579cb5 100644 --- a/gdb/cp-abi.c +++ b/gdb/cp-abi.c @@ -284,7 +284,7 @@ set_cp_abi_as_auto_default (const char *short_name) /* Since we copy the current ABI into current_cp_abi instead of using a pointer, if auto is currently the default, we need to reset it. */ - if (strcmp (current_cp_abi.shortname, "auto") == 0) + if (streq (current_cp_abi.shortname, "auto")) switch_to_cp_abi ("auto"); } @@ -296,7 +296,7 @@ find_cp_abi (const char *short_name) int i; for (i = 0; i < num_cp_abis; i++) - if (strcmp (cp_abis[i]->shortname, short_name) == 0) + if (streq (cp_abis[i]->shortname, short_name)) return cp_abis[i]; return NULL; diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index fe3c6dce8ca..4be50599762 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -2092,7 +2092,7 @@ should_be_the_same (const char *one, const char *two) if (cptwo != nullptr) two = cptwo.get (); - SELF_CHECK (strcmp (one, two) == 0); + SELF_CHECK (streq (one, two)); } static void diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index efdb2a2c850..c8cd5c245aa 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -431,7 +431,7 @@ cp_lookup_symbol_via_imports (const char *scope, && (len == 0 || scope[len] == ':' || scope[len] == '\0')) - : strcmp (scope, current->import_dest) == 0); + : streq (scope, current->import_dest)); /* If the import destination is the current scope or one of its ancestors then it is applicable. */ @@ -447,9 +447,10 @@ cp_lookup_symbol_via_imports (const char *scope, with the sought out name. If there is a match pass current->import_src as NAMESPACE to direct the search towards the imported namespace. */ - if (current->declaration - && strcmp (name, current->alias - ? current->alias : current->declaration) == 0) + if (current->declaration != nullptr + && streq (name, (current->alias != nullptr + ? current->alias + : current->declaration))) sym = cp_lookup_symbol_in_namespace (current->import_src, current->declaration, block, domain, 1); @@ -467,13 +468,12 @@ cp_lookup_symbol_via_imports (const char *scope, /* Do not follow CURRENT if NAME matches its EXCLUDES. */ for (excludep = current->excludes; *excludep; excludep++) - if (strcmp (name, *excludep) == 0) + if (streq (name, *excludep)) break; if (*excludep) continue; - if (current->alias != NULL - && strcmp (name, current->alias) == 0) + if (current->alias != nullptr && streq (name, current->alias)) /* If the import is creating an alias and the alias matches the sought name. Pass current->import_src as the NAME to direct the search towards the aliased namespace. */ diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 5dfb2a78505..d321986f72d 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -110,9 +110,9 @@ cp_already_canonical (const char *string) /* These are the only two identifiers which canonicalize to other than themselves or an error: unsigned -> unsigned int and signed -> int. */ - if (string[0] == 'u' && strcmp (&string[1], "nsigned") == 0) + if (string[0] == 'u' && streq (&string[1], "nsigned")) return 0; - else if (string[0] == 's' && strcmp (&string[1], "igned") == 0) + else if (string[0] == 's' && streq (&string[1], "igned")) return 0; /* Identifier character [a-zA-Z0-9_]. */ @@ -165,7 +165,7 @@ inspect_type (struct demangle_parse_info *info, { const char *new_name = (*finder) (otype, data); - if (new_name != nullptr && strcmp (new_name, name) != 0) + if (new_name != nullptr && !streq (new_name, name)) { ret_comp->u.s_name.s = new_name; ret_comp->u.s_name.len = strlen (new_name); @@ -200,8 +200,7 @@ inspect_type (struct demangle_parse_info *info, If the symbol is typedef and its type name is the same as the symbol's name, e.g., "typedef struct foo foo;". */ - if (type->name () != nullptr - && strcmp (type->name (), name) == 0) + if (type->name () != nullptr && streq (type->name (), name)) return 0; is_anon = (type->name () == NULL @@ -617,7 +616,7 @@ cp_canonicalize_string_full (const char *string, /* Finally, compare the original string with the computed name, returning NULL if they are the same. */ - if (strcmp (us.get (), string) == 0) + if (streq (us.get (), string)) return nullptr; return us; @@ -666,7 +665,7 @@ cp_canonicalize_string (const char *string) if (info->added_parens) maybe_strip_parens (us.get ()); - if (strcmp (us.get (), string) == 0) + if (streq (us.get (), string)) return nullptr; return us; @@ -1239,7 +1238,7 @@ overload_list_add_symbol (struct symbol *sym, /* skip any symbols that we've already considered. */ for (symbol *listed_sym : *overload_list) - if (strcmp (sym->linkage_name (), listed_sym->linkage_name ()) == 0) + if (streq (sym->linkage_name (), listed_sym->linkage_name ())) return; /* Get the demangled name without parameters */ @@ -1249,7 +1248,7 @@ overload_list_add_symbol (struct symbol *sym, return; /* skip symbols that cannot match */ - if (strcmp (sym_name.get (), oload_name) != 0) + if (!streq (sym_name.get (), oload_name)) return; overload_list->push_back (sym); @@ -1429,7 +1428,7 @@ add_symbol_overload_list_using (const char *func_name, if (current->alias != NULL || current->declaration != NULL) continue; - if (strcmp (the_namespace, current->import_dest) == 0) + if (streq (the_namespace, current->import_dest)) { /* Mark this import as searched so that the recursive call does not search it again. */ @@ -2206,9 +2205,8 @@ check_remove_params (const char *file, int line, gdb::unique_xmalloc_ptr<char> result = cp_remove_params_if_any (name, completion_mode); - if ((expected == NULL) != (result == NULL) - || (expected != NULL - && strcmp (result.get (), expected) != 0)) + if ((expected == nullptr) != (result == nullptr) + || (expected != nullptr && !streq (result.get (), expected))) { error (_("%s:%d: make-paramless self-test failed: (completion=%d) " "\"%s\" -> %s, expected %s"), diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 54b992b3b21..349a0d6bf9e 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -66,7 +66,7 @@ cp_is_vtbl_ptr_type (struct type *type) { const char *type_name = type->name (); - return (type_name != NULL && !strcmp (type_name, vtbl_ptr_name)); + return (type_name != NULL && streq (type_name, vtbl_ptr_name)); } /* Return truth value for the assertion that TYPE is of the type @@ -247,7 +247,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, /* Do not print leading '=' in case of anonymous unions. */ - if (strcmp (type->field (i).name (), "")) + if (!streq (type->field (i).name (), "")) gdb_puts (" = ", stream); else { diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index 33b99bb35e6..e86f79a42ea 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -2455,14 +2455,11 @@ csky_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int dw_reg) static int csky_essential_reg_check (const struct csky_supported_tdesc_register *reg) { - if ((strcmp (reg->name , "pc") == 0) - && (reg->num == CSKY_PC_REGNUM)) + if (streq (reg->name, "pc") && reg->num == CSKY_PC_REGNUM) return CSKY_TDESC_REGS_PC_NUMBERED; - else if ((strcmp (reg->name , "r14") == 0) - && (reg->num == CSKY_SP_REGNUM)) + else if (streq (reg->name, "r14") && reg->num == CSKY_SP_REGNUM) return CSKY_TDESC_REGS_SP_NUMBERED; - else if ((strcmp (reg->name , "r15") == 0) - && (reg->num == CSKY_LR_REGNUM)) + else if (streq (reg->name, "r15") && reg->num == CSKY_LR_REGNUM) return CSKY_TDESC_REGS_LR_NUMBERED; else return 0; @@ -2474,11 +2471,9 @@ static int csky_fr0_fr15_reg_check (const struct csky_supported_tdesc_register *reg) { int i = 0; for (i = 0; i < 16; i++) - { - if ((strcmp (reg->name, csky_supported_fpu_regs[i].name) == 0) - && (csky_supported_fpu_regs[i].num == reg->num)) - return (1 << i); - } + if (streq (reg->name, csky_supported_fpu_regs[i].name) + && csky_supported_fpu_regs[i].num == reg->num) + return 1 << i; return 0; }; @@ -2489,11 +2484,9 @@ static int csky_fr16_fr31_reg_check (const struct csky_supported_tdesc_register *reg) { int i = 0; for (i = 0; i < 16; i++) - { - if ((strcmp (reg->name, csky_supported_fpu_regs[i + 16].name) == 0) - && (csky_supported_fpu_regs[i + 16].num == reg->num)) - return (1 << i); - } + if (streq (reg->name, csky_supported_fpu_regs[i + 16].name) + && csky_supported_fpu_regs[i + 16].num == reg->num) + return (1 << i); return 0; }; @@ -2504,11 +2497,9 @@ static int csky_vr0_vr15_reg_check (const struct csky_supported_tdesc_register *reg) { int i = 0; for (i = 0; i < 16; i++) - { - if ((strcmp (reg->name, csky_supported_fpu_regs[i + 32].name) == 0) - && (csky_supported_fpu_regs[i + 32].num == reg->num)) - return (1 << i); - } + if (streq (reg->name, csky_supported_fpu_regs[i + 32].name) + && csky_supported_fpu_regs[i + 32].num == reg->num) + return (1 << i); return 0; }; diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 3de7e8d54ef..b95cdbed33c 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -543,7 +543,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid) type = alloc.new_type (TYPE_CODE_ERROR, cet.cte_bits, name); } - if (name != nullptr && strcmp (name, "char") == 0) + if (name != nullptr && streq (name, "char")) type->set_has_no_signedness (true); return set_tid_type (ccp, tid, type); @@ -1139,7 +1139,7 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg) if (kind == CTF_K_FUNCTION) { sym->set_domain (FUNCTION_DOMAIN); - if (name != nullptr && strcmp (name, "main") == 0) + if (name != nullptr && streq (name, "main")) set_objfile_main_name (objfile, name, language_c); } else @@ -1233,12 +1233,12 @@ build_ctf_archive_member (ctf_dict_t *dict, const char *name, void *arg) auto *iter_data = static_cast<ctf_archive_iter_data *> (arg); ctf_per_objfile &per_objfile = iter_data->per_objfile; - if (strcmp (name, ".ctf") != 0) + if (!streq (name, ".ctf")) ctf_import (dict, per_objfile.parent_dict.get ()); objfile *objfile = per_objfile.objfile; - if (strcmp (name, ".ctf") == 0) + if (streq (name, ".ctf")) { name = bfd_get_filename (objfile->obfd.get ()); ctf_debug_printf ("is parent, using name='%s'", name); diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index 575db0c08b7..34b90c0ed93 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -378,7 +378,7 @@ d_lookup_symbol_imports (const char *scope, const char *name, const char **excludep; /* If the import destination is the current scope then search it. */ - if (!current->searched && strcmp (scope, current->import_dest) == 0) + if (!current->searched && streq (scope, current->import_dest)) { /* Mark this import as searched so that the recursive call does not search it again. */ @@ -390,9 +390,10 @@ d_lookup_symbol_imports (const char *scope, const char *name, with the sought out name. If there is a match pass current->import_src as MODULE to direct the search towards the imported module. */ - if (current->declaration - && strcmp (name, current->alias - ? current->alias : current->declaration) == 0) + if (current->declaration != nullptr + && streq (name, (current->alias != nullptr + ? current->alias + : current->declaration))) sym = d_lookup_symbol_in_module (current->import_src, current->declaration, block, domain, 1); @@ -409,7 +410,7 @@ d_lookup_symbol_imports (const char *scope, const char *name, /* Do not follow CURRENT if NAME matches its EXCLUDES. */ for (excludep = current->excludes; *excludep; excludep++) - if (strcmp (name, *excludep) == 0) + if (streq (name, *excludep)) break; if (*excludep) continue; @@ -417,7 +418,7 @@ d_lookup_symbol_imports (const char *scope, const char *name, /* If the import statement is creating an alias. */ if (current->alias != NULL) { - if (strcmp (name, current->alias) == 0) + if (streq (name, current->alias)) { /* If the alias matches the sought name. Pass current->import_src as the NAME to direct the diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index a3dd80a10ec..6e5757192da 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -35,8 +35,8 @@ dynamic_array_type (struct type *type, { if (type->num_fields () == 2 && type->field (0).type ()->code () == TYPE_CODE_INT - && strcmp (type->field (0).name (), "length") == 0 - && strcmp (type->field (1).name (), "ptr") == 0 + && streq (type->field (0).name (), "length") + && streq (type->field (1).name (), "ptr") && !val->bits_any_optimized_out (TARGET_CHAR_BIT * embedded_offset, TARGET_CHAR_BIT * type->length ())) { diff --git a/gdb/darwin-nat-info.c b/gdb/darwin-nat-info.c index d274c4a4fcc..d1befa7d8c3 100644 --- a/gdb/darwin-nat-info.c +++ b/gdb/darwin-nat-info.c @@ -123,7 +123,7 @@ get_task_from_args (const char *args) return priv->task; } - if (strcmp (args, "gdb") == 0) + if (streq (args, "gdb")) return mach_task_self (); task = strtoul (args, &eptr, 0); if (*eptr) @@ -799,7 +799,7 @@ info_mach_exceptions_command (const char *args, int from_tty) if (args != NULL) { - if (strcmp (args, "saved") == 0) + if (streq (args, "saved")) { if (inferior_ptid == null_ptid) gdb_printf (_("No inferior running\n")); @@ -809,7 +809,7 @@ info_mach_exceptions_command (const char *args, int from_tty) disp_exception (&priv->exception_info); return; } - else if (strcmp (args, "host") == 0) + else if (streq (args, "host")) { /* FIXME: This needs a privileged host port! */ kret = host_get_exception_ports diff --git a/gdb/dicos-tdep.c b/gdb/dicos-tdep.c index f6a071184d6..805889174d1 100644 --- a/gdb/dicos-tdep.c +++ b/gdb/dicos-tdep.c @@ -80,7 +80,7 @@ dicos_load_module_p (bfd *abfd, int header_size) { if (sym->name != NULL && symname[0] == sym->name[0] - && strcmp (symname + 1, sym->name + 1) == 0) + && streq (symname + 1, sym->name + 1)) { ret = 1; break; diff --git a/gdb/dictionary.c b/gdb/dictionary.c index e3ff053504e..4c3d8782368 100644 --- a/gdb/dictionary.c +++ b/gdb/dictionary.c @@ -791,7 +791,7 @@ language_defn::search_name_hash (const char *string0) const ignore the "TKB" suffix because searches for this task body subprogram are going to be performed using `pck__t' (the encoded version of the natural name `pck.t'). */ - if (strcmp (string, "TKB") == 0) + if (streq (string, "TKB")) return hash; break; } diff --git a/gdb/disasm.c b/gdb/disasm.c index 17f281138b2..81c466c188a 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -1311,7 +1311,7 @@ set_disassembler_options (const char *prospective_options) if (valid_options->arg[i]->values == NULL) break; for (j = 0; valid_options->arg[i]->values[j] != NULL; j++) - if (strcmp (arg, valid_options->arg[i]->values[j]) == 0) + if (streq (arg, valid_options->arg[i]->values[j])) { found = true; break; @@ -1319,7 +1319,7 @@ set_disassembler_options (const char *prospective_options) if (found) break; } - else if (strcmp (opt, valid_options->name[i]) == 0) + else if (streq (opt, valid_options->name[i])) break; if (valid_options->name[i] == NULL) { diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c index b42afea5a17..e69e6f754b4 100644 --- a/gdb/dtrace-probe.c +++ b/gdb/dtrace-probe.c @@ -846,7 +846,7 @@ dtrace_static_probe_ops::get_probes that sh_type == SHT_SUNW_dof. Therefore, in addition to the sh_type check, we need to check for sections named .sframe. */ if (elf_section_data (sect)->this_hdr.sh_type == SHT_SUNW_dof - && strcmp (bfd_section_name (sect), ".sframe") != 0) + && !streq (bfd_section_name (sect), ".sframe")) { bfd_byte *dof; diff --git a/gdb/dwarf2/cooked-index-shard.c b/gdb/dwarf2/cooked-index-shard.c index 938ee8f2969..91dc9ab8945 100644 --- a/gdb/dwarf2/cooked-index-shard.c +++ b/gdb/dwarf2/cooked-index-shard.c @@ -104,7 +104,7 @@ cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag, && parent_entry.resolved == nullptr && m_main == nullptr && language_may_use_plain_main (lang) - && strcmp (name, "main") == 0) + && streq (name, "main")) m_main = result; return result; diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 9e84e5e65fa..167e39ffc89 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -197,7 +197,7 @@ cooked_index::get_main () const exception. */ if ((entry->lang != language_ada && entry->lang != language_cplus) - || strcmp (entry->name, "main") == 0) + || streq (entry->name, "main")) { /* There won't be one better than this. */ return entry; diff --git a/gdb/dwarf2/cooked-indexer.c b/gdb/dwarf2/cooked-indexer.c index 1848b92e2ca..302b4a6d6a0 100644 --- a/gdb/dwarf2/cooked-indexer.c +++ b/gdb/dwarf2/cooked-indexer.c @@ -554,7 +554,7 @@ cooked_indexer::index_dies (cutu_reader *reader, if (abbrev->tag == DW_TAG_namespace && m_language == language_cplus - && strcmp (name, "::") == 0) + && streq (name, "::")) { /* GCC 4.0 and 4.1 had a bug (PR c++/28460) where they generated bogus DW_TAG_namespace DIEs with a name of "::" diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c index 7dca05b3a81..c3bfd15f14a 100644 --- a/gdb/dwarf2/cu.c +++ b/gdb/dwarf2/cu.c @@ -178,7 +178,7 @@ dwarf2_cu::get_builder () void dwarf2_cu::set_producer (const char *producer) { - gdb_assert (m_producer == nullptr || strcmp (producer, m_producer) == 0); + gdb_assert (m_producer == nullptr || streq (producer, m_producer)); m_producer = producer; int major, minor; diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index c4e75898f4c..f40e9636a0b 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -284,8 +284,7 @@ mapped_symtab::find_slot (const char *name) for (;;) { - if (m_data[index].name == NULL - || strcmp (name, m_data[index].name) == 0) + if (m_data[index].name == nullptr || streq (name, m_data[index].name)) return m_data[index]; index = (index + step) & (m_data.size () - 1); } @@ -443,7 +442,7 @@ public: bool operator== (const c_str_view &other) const { - return strcmp (m_cstr, other.m_cstr) == 0; + return streq (m_cstr, other.m_cstr); } bool operator< (const c_str_view &other) const diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index ddbac684675..48d1200270b 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -315,7 +315,7 @@ mapped_gdb_index::build_name_components (dwarf2_per_objfile *per_objfile) flags |= IS_STATIC; if (main_name != nullptr && tag == DW_TAG_subprogram - && strcmp (name, main_name) == 0) + && streq (name, main_name)) { flags |= IS_MAIN; this_lang = main_lang; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e41f06890d7..29c601ef2c3 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -433,7 +433,7 @@ dwo_file_eq::operator() (const dwo_file_search &search, if (search.comp_dir == nullptr || dwo_file->comp_dir == nullptr) return search.comp_dir == dwo_file->comp_dir; - return std::strcmp (search.comp_dir, dwo_file->comp_dir) == 0; + return streq (search.comp_dir, dwo_file->comp_dir); } /* See dwarf2/read.h. */ @@ -4114,7 +4114,7 @@ fixup_go_packaging (struct dwarf2_cu *cu) { objfile *objfile = cu->per_objfile->objfile; - if (strcmp (package_name.get (), this_package_name.get ()) != 0) + if (!streq (package_name.get (), this_package_name.get ())) complaint (_("Symtab %s has objects from two different Go " "packages: %s and %s"), (sym->symtab () != NULL @@ -4361,8 +4361,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* Could be data-less variant, so keep going. */ disr_type = nullptr; } - else if (strcmp (disr_type->field (0).name (), - "RUST$ENUM$DISR") != 0) + else if (!streq (disr_type->field (0).name (), "RUST$ENUM$DISR")) { /* Not a Rust enum. */ return; @@ -5418,7 +5417,7 @@ dwarf2_physname (const char *name, struct die_info *die, struct dwarf2_cu *cu) { const char *physname = dwarf2_compute_name (name, die, cu, 1); - if (canon != NULL && strcmp (physname, canon) != 0) + if (canon != NULL && !streq (physname, canon)) { /* It may not mean a bug in GDB. The compiler could also compute DW_AT_linkage_name incorrectly. But in such case @@ -7219,8 +7218,8 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile) dwp_name += ".dwp"; gdb_bfd_ref_ptr dbfd (open_dwp_file (per_bfd, dwp_name.c_str ())); - if (dbfd == NULL - && strcmp (objfile->original_name, objfile_name (objfile)) != 0) + if (dbfd == nullptr + && !streq (objfile->original_name, objfile_name (objfile))) { /* Try to find .dwp for the binary file after gdb_realpath resolving. */ dwp_name = objfile_name (objfile); @@ -9947,7 +9946,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, /* Look up member function name in fieldlist. */ for (i = 0; i < fip->fnfieldlists.size (); i++) { - if (strcmp (fip->fnfieldlists[i].name, fieldname) == 0) + if (streq (fip->fnfieldlists[i].name, fieldname)) { flp = &fip->fnfieldlists[i]; break; @@ -10183,9 +10182,9 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) /* Check for __pfn and __delta members. */ if (type->field (0).name () == NULL - || strcmp (type->field (0).name (), "__pfn") != 0 + || !streq (type->field (0).name (), "__pfn") || type->field (1).name () == NULL - || strcmp (type->field (1).name (), "__delta") != 0) + || !streq (type->field (1).name (), "__delta")) return; /* Find the type of the method. */ @@ -10271,9 +10270,9 @@ quirk_ada_thick_pointer_struct (struct die_info *die, struct dwarf2_cu *cu, /* Check for P_ARRAY and P_BOUNDS members. */ if (type->field (0).name () == NULL - || strcmp (type->field (0).name (), "P_ARRAY") != 0 + || !streq (type->field (0).name (), "P_ARRAY") || type->field (1).name () == NULL - || strcmp (type->field (1).name (), "P_BOUNDS") != 0) + || !streq (type->field (1).name (), "P_BOUNDS")) return; /* Make sure we're looking at a pointer to an array. */ @@ -10843,7 +10842,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) i >= TYPE_N_BASECLASSES (type); --i) { - if (strcmp (type->field (i).name (), "__vfp") == 0) + if (streq (type->field (i).name (), "__vfp")) { set_type_vptr_fieldno (type, i); set_type_vptr_basetype (type, type); @@ -12653,7 +12652,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) if (follow_die_ref (die, attr, &arg_cu) == child_die) is_this = 1; } - else if (name && strcmp (name, "this") == 0) + else if (name && streq (name, "this")) /* Function definitions will have the argument names. */ is_this = 1; else if (name == NULL && iparams == 0) @@ -13038,7 +13037,7 @@ dwarf2_init_integer_type (struct dwarf2_cu *cu, int bits, int unsigned_p, at least versions 14, 17, and 18. */ type_allocator alloc (objfile, cu->lang ()); if (bits == 0 && cu->producer_is_icc () && name != nullptr - && strcmp (name, "void") == 0) + && streq (name, "void")) type = alloc.copy_type (builtin_type (objfile)->builtin_void); else type = init_integer_type (alloc, bits, unsigned_p, name); @@ -13329,7 +13328,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) if (type->code () == TYPE_CODE_INT && name != nullptr - && strcmp (name, "char") == 0) + && streq (name, "char")) type->set_has_no_signedness (true); maybe_set_alignment (cu, die, type); @@ -16375,7 +16374,7 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu) const char *die_name = dwarf2_name (die, cu); if (die_name != NULL - && strcmp (die_name, actual_name.get ()) != 0) + && !streq (die_name, actual_name.get ())) { /* Strip off the class name from the full name. We want the prefix. */ @@ -16554,7 +16553,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) DW_TAG_namespace DIEs with a name of "::" for the global namespace. Work around this problem here. */ if (cu->lang () == language_cplus - && strcmp (parent_type->name (), "::") == 0) + && streq (parent_type->name (), "::")) return ""; /* We give a name to even anonymous namespaces. */ return parent_type->name (); @@ -16638,7 +16637,7 @@ typename_concat (const char *prefix, const char *suffix, int physname, { /* For D, the 'main' function could be defined in any module, but it should never be prefixed. */ - if (strcmp (suffix, "D main") == 0) + if (streq (suffix, "D main")) { prefix = ""; sep = ""; @@ -18179,7 +18178,7 @@ cutu_reader::prepare_one_comp_unit (struct dwarf2_cu *cu, if (attr != nullptr && cu->producer_is_gcc () && attr->as_string () != nullptr - && strcmp (attr->as_string (), "<artificial>") == 0) + && streq (attr->as_string (), "<artificial>")) cu->per_cu->lto_artificial = true; switch (m_top_level_die->tag) diff --git a/gdb/dwarf2/sect-names.h b/gdb/dwarf2/sect-names.h index 54e29c2a106..a2c007f7e69 100644 --- a/gdb/dwarf2/sect-names.h +++ b/gdb/dwarf2/sect-names.h @@ -35,8 +35,8 @@ struct dwarf2_section_names { /* Return true if NAME matches either of this section's names. */ bool matches (const char *name) const { - return ((normal != nullptr && strcmp (name, normal) == 0) - || (compressed != nullptr && strcmp (name, compressed) == 0)); + return ((normal != nullptr && streq (name, normal)) + || (compressed != nullptr && streq (name, compressed))); } }; diff --git a/gdb/elfread.c b/gdb/elfread.c index 8924bb6ba24..7e2f4fe8f3f 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -191,15 +191,15 @@ elf_symfile_segments (bfd *abfd) static void elf_locate_sections (asection *sectp, struct elfinfo *ei) { - if (strcmp (sectp->name, ".stab") == 0) + if (streq (sectp->name, ".stab")) { ei->stabsect = sectp; } - else if (strcmp (sectp->name, ".mdebug") == 0) + else if (streq (sectp->name, ".mdebug")) { ei->mdebugsect = sectp; } - else if (strcmp (sectp->name, ".ctf") == 0) + else if (streq (sectp->name, ".ctf")) { ei->ctfsect = sectp; } @@ -508,7 +508,7 @@ elf_symtab_read (minimal_symbol_reader &reader, { const char *atsign = strchr (sym->name, '@'); bool is_at_symbol = atsign != nullptr && atsign > sym->name; - bool is_plt = is_at_symbol && strcmp (atsign, "@plt") == 0; + bool is_plt = is_at_symbol && streq (atsign, "@plt"); int len = is_at_symbol ? atsign - sym->name : 0; if (is_at_symbol @@ -708,14 +708,14 @@ elf_gnu_ifunc_record_cache (const char *name, CORE_ADDR addr) /* Note we check the symbol's name instead of checking whether the symbol is in the .plt section because some systems have @plt symbols in the .text section. */ - if (len > 4 && strcmp (target_name + len - 4, "@plt") == 0) + if (len > 4 && streq (target_name + len - 4, "@plt")) { gnu_ifunc_debug_printf ("target \"%s\" is a PLT stub, not caching", target_name); return 0; } - if (strcmp (target_name, "_PROCEDURE_LINKAGE_TABLE_") == 0) + if (streq (target_name, "_PROCEDURE_LINKAGE_TABLE_")) { gnu_ifunc_debug_printf ("target is _PROCEDURE_LINKAGE_TABLE_, " "not caching"); diff --git a/gdb/eval.c b/gdb/eval.c index c13f3cb170d..c47ac2614c5 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1015,7 +1015,7 @@ add_struct_fields (struct type *type, completion_list &output, computed_type_name = 1; } /* Omit constructors from the completion list. */ - if (!type_name || strcmp (type_name, name)) + if (!type_name || !streq (type_name, name)) output.emplace_back (concat (prefix, name, nullptr)); } } diff --git a/gdb/event-top.c b/gdb/event-top.c index d27ce02e61c..48dfb34c47f 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -821,7 +821,7 @@ command_line_handler (gdb::unique_xmalloc_ptr<char> &&rl) Which we will get with a newer readline, but this really is the best we can do with older versions of readline. */ const char *value = rl_variable_value ("enable-bracketed-paste"); - if (value != nullptr && strcmp (value, "on") == 0 + if (value != nullptr && streq (value, "on") && ((rl_readline_version >> 8) & 0xff) > 0x07) printf_unfiltered ("\n"); printf_unfiltered ("quit\n"); diff --git a/gdb/exec.c b/gdb/exec.c index 94051ddab23..5d297bfee56 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -114,7 +114,7 @@ set_exec_file_mismatch_command (const char *ignore, ; mode = static_cast<enum exec_file_mismatch_mode>(1 + (int) mode)) { - if (strcmp (exec_file_mismatch, exec_file_mismatch_names[mode]) == 0) + if (streq (exec_file_mismatch, exec_file_mismatch_names[mode])) { exec_file_mismatch_mode = mode; return; @@ -512,8 +512,8 @@ exec_file_attach (const char *filename, int from_tty) bfd *curr_bfd = current_program_space->exec_bfd (); bool reload_p = (((prev_bfd != nullptr) == (curr_bfd != nullptr)) && (prev_bfd == nullptr - || (strcmp (bfd_get_filename (prev_bfd), - bfd_get_filename (curr_bfd)) == 0))); + || (streq (bfd_get_filename (prev_bfd), + bfd_get_filename (curr_bfd))))); gdb::observers::executable_changed.notify (current_program_space, reload_p); } diff --git a/gdb/extension.c b/gdb/extension.c index 2560ff91e89..d8ef8123ab5 100644 --- a/gdb/extension.c +++ b/gdb/extension.c @@ -123,7 +123,7 @@ has_extension (const char *file, const char *extension) int extension_len = strlen (extension); return (file_len > extension_len - && strcmp (&file[file_len - extension_len], extension) == 0); + && streq (&file[file_len - extension_len], extension)); } /* Return the extension language of FILE, or NULL if diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index f9309066936..123d9995c39 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -378,7 +378,7 @@ f_language::f_type_print_base (struct type *type, struct ui_file *stream, through as TYPE_CODE_INT since dbxstclass.h is so C-oriented, we must change these to "character" from "char". */ - if (strcmp (type->name (), "char") == 0) + if (streq (type->name (), "char")) gdb_printf (stream, "%*scharacter", level, ""); else goto default_case; diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index c66e90c0402..13921c03a48 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -634,8 +634,9 @@ info_common_command_for_block (const struct block *block, const char *comname, gdb_assert (sym->loc_class () == LOC_COMMON_BLOCK); - if (comname && (!sym->linkage_name () - || strcmp (comname, sym->linkage_name ()) != 0)) + if (comname != nullptr + && (sym->linkage_name () == nullptr + || !streq (comname, sym->linkage_name ()))) continue; if (*any_printed) diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 80116553d9b..dc486139861 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -897,7 +897,7 @@ fbsd_nat_target::thread_name (struct thread_info *thr) return nullptr; if (ptrace (PT_LWPINFO, lwp, (caddr_t) &pl, sizeof pl) == -1) return nullptr; - if (strcmp (kp.ki_comm, pl.pl_tdname) == 0) + if (streq (kp.ki_comm, pl.pl_tdname)) return NULL; xsnprintf (buf, sizeof buf, "%s", pl.pl_tdname); return buf; diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index e3c78aaff5d..4bbe0c120e6 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -573,7 +573,7 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, bfd &cbfd, as its thread name instead of an empty name if a name has not been set explicitly. Return a NULL name in that case. */ - if (strcmp (buf, elf_tdata (&cbfd)->core->program) != 0) + if (!streq (buf, elf_tdata (&cbfd)->core->program)) return buf; } } diff --git a/gdb/frame.c b/gdb/frame.c index 746d7d06ec1..70621cf6e20 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2439,7 +2439,7 @@ get_prev_frame_always_1 (const frame_info_ptr &this_frame) morestack_msym = lookup_minimal_symbol_by_pc (this_pc_in_block).minsym; if (morestack_msym) morestack_name = morestack_msym->linkage_name (); - if (!morestack_name || strcmp (morestack_name, "__morestack") != 0) + if (!morestack_name || !streq (morestack_name, "__morestack")) { frame_debug_printf (" -> nullptr // this frame ID is inner"); this_frame->stop_reason = UNWIND_INNER_ID; diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index 94d3db68ae9..33a270497f3 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -1071,9 +1071,9 @@ frv_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) call_dest = pc + 4 * displ; bound_minimal_symbol s = lookup_minimal_symbol_by_pc (call_dest); - if (s.minsym != NULL - && s.minsym->linkage_name () != NULL - && strcmp (s.minsym->linkage_name (), "__main") == 0) + if (s.minsym != nullptr + && s.minsym->linkage_name () != nullptr + && streq (s.minsym->linkage_name (), "__main")) { pc += 4; return pc; diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index 5a1f3315c7f..ba0a0882a0a 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -377,7 +377,7 @@ ft32_address_class_name_to_type_flags (struct gdbarch *gdbarch, const char* name, [...] [diff truncated at 100000 bytes]