From patchwork Wed Apr 29 17:51:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39184 From: gprocida@google.com (Giuliano Procida) Date: Wed, 29 Apr 2020 18:51:28 +0100 Subject: [PATCH 1/6] Tabify code indentation. In-Reply-To: <20200429175133.19814-1-gprocida@google.com> References: <20200429175133.19814-1-gprocida@google.com> Message-ID: <20200429175133.19814-2-gprocida@google.com> Some sources file lines are not indented consistently with leading 8-space tabs. This patch updates the leading whitespace in those cases. * src/abg-dwarf-reader.cc: At the start of lines, after any number of tabs, replace sequences of 8 spaces, or 1-7 spaces followed by a tab, with the same number of tabs. * src/abg-tools-utils.cc: Ditto. * src/abg-writer.cc: Ditto. * tools/abidiff.cc: Ditto. * tools/abipkgdiff.cc: Ditto. Signed-off-by: Giuliano Procida --- src/abg-dwarf-reader.cc | 138 ++++++++++++++++++------------------- src/abg-tools-utils.cc | 12 ++-- src/abg-writer.cc | 42 ++++++------ tools/abidiff.cc | 2 +- tools/abipkgdiff.cc | 148 ++++++++++++++++++++-------------------- 5 files changed, 171 insertions(+), 171 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 850281ad..fe369fcf 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -1499,8 +1499,8 @@ lookup_public_variable_symbol_from_elf(const environment* env, bool lookup_data_tag_from_dynamic_segment(Elf* elf, - Elf64_Sxword data_tag, - vector& dt_tag_data) + Elf64_Sxword data_tag, + vector& dt_tag_data) { size_t num_prog_headers = 0; bool found = false; @@ -1513,7 +1513,7 @@ lookup_data_tag_from_dynamic_segment(Elf* elf, GElf_Phdr phdr_mem; GElf_Phdr *phdr = gelf_getphdr(elf, i, &phdr_mem); if (phdr == NULL || phdr->p_type != PT_DYNAMIC) - continue; + continue; // Poke at the dynamic segment like a section, so that we can // get its section header information; also we'd like to read @@ -1527,48 +1527,48 @@ lookup_data_tag_from_dynamic_segment(Elf* elf, GElf_Shdr *dynamic_section_header = gelf_getshdr(dynamic_section, &shdr_mem); if (dynamic_section_header == NULL - || dynamic_section_header->sh_type != SHT_DYNAMIC) - continue; + || dynamic_section_header->sh_type != SHT_DYNAMIC) + continue; // Get data of the dynamic segment (seen as a section). Elf_Data *data = elf_getdata(dynamic_section, NULL); if (data == NULL) - continue; + continue; // Get the index of the section headers string table. size_t string_table_index = 0; ABG_ASSERT (elf_getshdrstrndx(elf, &string_table_index) >= 0); size_t dynamic_section_header_entry_size = gelf_fsize(elf, - ELF_T_DYN, 1, - EV_CURRENT); + ELF_T_DYN, 1, + EV_CURRENT); GElf_Shdr link_mem; GElf_Shdr *link = - gelf_getshdr(elf_getscn(elf, - dynamic_section_header->sh_link), + gelf_getshdr(elf_getscn(elf, + dynamic_section_header->sh_link), &link_mem); ABG_ASSERT(link != NULL); size_t num_dynamic_section_entries = - dynamic_section_header->sh_size / dynamic_section_header_entry_size; + dynamic_section_header->sh_size / dynamic_section_header_entry_size; // Now walk through all the DT_* data tags that are in the // segment/section for (size_t j = 0; j < num_dynamic_section_entries; ++j) - { - GElf_Dyn dynamic_section_mem; - GElf_Dyn *dynamic_section = gelf_getdyn(data, - j, - &dynamic_section_mem); - if (dynamic_section->d_tag == data_tag) - { - dt_tag_data.push_back(elf_strptr(elf, - dynamic_section_header->sh_link, + { + GElf_Dyn dynamic_section_mem; + GElf_Dyn *dynamic_section = gelf_getdyn(data, + j, + &dynamic_section_mem); + if (dynamic_section->d_tag == data_tag) + { + dt_tag_data.push_back(elf_strptr(elf, + dynamic_section_header->sh_link, dynamic_section->d_un.d_val)); - found = true; - } - } + found = true; + } + } } return found; } @@ -4885,7 +4885,7 @@ public: i != types_to_canonicalize(source).end(); ++i) { - type_base_sptr t = lookup_type_from_die_offset(*i, source); + type_base_sptr t = lookup_type_from_die_offset(*i, source); if (t->get_canonical_type()) ++canonicalized; else @@ -4932,15 +4932,15 @@ public: << elf_path() << "\n"; cerr << " # late canonicalized types: " - << num_canonicalized; - if (total) - cerr << " (" << num_canonicalized * 100 / total << "%)"; - cerr << "\n" + << num_canonicalized; + if (total) + cerr << " (" << num_canonicalized * 100 / total << "%)"; + cerr << "\n" << " # missed canonicalization opportunities: " - << num_missed; - if (total) - cerr << " (" << num_missed * 100 / total << "%)"; - cerr << "\n"; + << num_missed; + if (total) + cerr << " (" << num_missed * 100 / total << "%)"; + cerr << "\n"; } } @@ -6960,9 +6960,9 @@ public: /// @return true upon successful completion, false otherwise. bool populate_symbol_map_from_ksymtab(Elf_Scn *section, - address_set_sptr exported_fns_set, - address_set_sptr exported_vars_set, - size_t nb_entries) + address_set_sptr exported_fns_set, + address_set_sptr exported_vars_set, + size_t nb_entries) { // The data of the section. Elf_Data *elf_data = elf_rawdata(section, 0); @@ -7072,8 +7072,8 @@ public: /// @return true upon successful completion, false otherwise. bool populate_symbol_map_from_ksymtab_reloc(Elf_Scn *reloc_section, - address_set_sptr exported_fns_set, - address_set_sptr exported_vars_set) + address_set_sptr exported_fns_set, + address_set_sptr exported_vars_set) { GElf_Shdr reloc_section_mem; GElf_Shdr *reloc_section_shdr = gelf_getshdr(reloc_section, @@ -7105,7 +7105,7 @@ public: ABG_ASSERT(symbol); - // If the symbol is a linux string constant then ignore it. + // If the symbol is a linux string constant then ignore it. if (symbol->get_is_linux_string_cst()) continue; @@ -7226,8 +7226,8 @@ public: } else return populate_symbol_map_from_ksymtab_reloc(reloc_section, - linux_exported_fns_set, - linux_exported_vars_set); + linux_exported_fns_set, + linux_exported_vars_set); } /// Load the special __ksymtab section. This is for linux kernel @@ -17672,35 +17672,35 @@ get_soname_of_elf_file(const string& path, string &soname) GElf_Phdr* phdr = gelf_getphdr (elf, i, &phdr_mem); if (phdr != NULL && phdr->p_type == PT_DYNAMIC) - { - Elf_Scn* scn = gelf_offscn (elf, phdr->p_offset); - GElf_Shdr shdr_mem; - GElf_Shdr* shdr = gelf_getshdr (scn, &shdr_mem); - int maxcnt = (shdr != NULL - ? shdr->sh_size / shdr->sh_entsize : INT_MAX); - ABG_ASSERT (shdr == NULL || shdr->sh_type == SHT_DYNAMIC); - Elf_Data* data = elf_getdata (scn, NULL); - if (data == NULL) - break; - - for (int cnt = 0; cnt < maxcnt; ++cnt) - { - GElf_Dyn dynmem; - GElf_Dyn* dyn = gelf_getdyn (data, cnt, &dynmem); - if (dyn == NULL) - continue; - - if (dyn->d_tag == DT_NULL) - break; - - if (dyn->d_tag != DT_SONAME) - continue; - - soname = elf_strptr (elf, shdr->sh_link, dyn->d_un.d_val); - break; - } - break; - } + { + Elf_Scn* scn = gelf_offscn (elf, phdr->p_offset); + GElf_Shdr shdr_mem; + GElf_Shdr* shdr = gelf_getshdr (scn, &shdr_mem); + int maxcnt = (shdr != NULL + ? shdr->sh_size / shdr->sh_entsize : INT_MAX); + ABG_ASSERT (shdr == NULL || shdr->sh_type == SHT_DYNAMIC); + Elf_Data* data = elf_getdata (scn, NULL); + if (data == NULL) + break; + + for (int cnt = 0; cnt < maxcnt; ++cnt) + { + GElf_Dyn dynmem; + GElf_Dyn* dyn = gelf_getdyn (data, cnt, &dynmem); + if (dyn == NULL) + continue; + + if (dyn->d_tag == DT_NULL) + break; + + if (dyn->d_tag != DT_SONAME) + continue; + + soname = elf_strptr (elf, shdr->sh_link, dyn->d_un.d_val); + break; + } + break; + } } elf_end(elf); diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc index a06e8615..9825dcef 100644 --- a/src/abg-tools-utils.cc +++ b/src/abg-tools-utils.cc @@ -1486,12 +1486,12 @@ guess_file_type(istream& in) && (unsigned char) buf[2] == 0xee && (unsigned char) buf[3] == 0xdb) { - if (buf[7] == 0x00) - return FILE_TYPE_RPM; - else if (buf[7] == 0x01) - return FILE_TYPE_SRPM; - else - return FILE_TYPE_UNKNOWN; + if (buf[7] == 0x00) + return FILE_TYPE_RPM; + else if (buf[7] == 0x01) + return FILE_TYPE_SRPM; + else + return FILE_TYPE_UNKNOWN; } if (buf[257] == 'u' diff --git a/src/abg-writer.cc b/src/abg-writer.cc index 8c6cc91a..afd99085 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -838,7 +838,7 @@ static bool write_pointer_type_def(const pointer_type_def_sptr&, static bool write_reference_type_def(const reference_type_def_sptr&, write_context&, unsigned); static bool write_array_type_def(const array_type_def_sptr&, - write_context&, unsigned); + write_context&, unsigned); static bool write_enum_type_decl(const enum_type_decl_sptr&, write_context&, unsigned); static bool write_typedef_decl(const typedef_decl_sptr&, @@ -2766,8 +2766,8 @@ write_array_type_def(const array_type_def_sptr& decl, vector::const_iterator si; for (si = decl->get_subranges().begin(); - si != decl->get_subranges().end(); ++si) - { + si != decl->get_subranges().end(); ++si) + { unsigned local_indent = indent + ctxt.get_config().get_xml_element_indent(); write_array_subrange_type(*si, ctxt, local_indent); @@ -3184,18 +3184,18 @@ write_function_decl(const function_decl_sptr& decl, write_context& ctxt, ++pi) { if ((*pi)->get_variadic_marker()) - { - do_indent(o, indent + ctxt.get_config().get_xml_element_indent()); - o << "get_type(); - annotate(*pi, ctxt, + annotate(*pi, ctxt, indent + ctxt.get_config().get_xml_element_indent()); - do_indent(o, indent + ctxt.get_config().get_xml_element_indent()); + do_indent(o, indent + ctxt.get_config().get_xml_element_indent()); o << "get_type(); - annotate(*pi, ctxt, indent + ctxt.get_config().get_xml_element_indent()); + annotate(*pi, ctxt, indent + ctxt.get_config().get_xml_element_indent()); - do_indent(o, indent + ctxt.get_config().get_xml_element_indent()); + do_indent(o, indent + ctxt.get_config().get_xml_element_indent()); o << "get_base_specifiers().end(); ++base) { - annotate((*base)->get_base_class(), ctxt, indent); + annotate((*base)->get_base_class(), ctxt, indent); do_indent(o, nb_ws); o << "(t), id, ctxt, nb_ws) || write_array_type_def(dynamic_pointer_cast(t), - id, ctxt, nb_ws) + id, ctxt, nb_ws) || write_enum_type_decl(dynamic_pointer_cast(t), id, ctxt, nb_ws) || write_typedef_decl(dynamic_pointer_cast(t), @@ -4293,7 +4293,7 @@ create_archive_write_context(const string& archive_path) static bool write_translation_unit_to_archive(const translation_unit& tu, archive_write_ctxt& ctxt, - const bool annotate) + const bool annotate) { if (!ctxt.archive) return false; @@ -4335,7 +4335,7 @@ write_translation_unit_to_archive(const translation_unit& tu, static bool write_corpus_to_archive(const corpus& corp, archive_write_ctxt& ctxt, - const bool annotate) + const bool annotate) { for (translation_units::const_iterator i = corp.get_translation_units().begin(); @@ -4366,7 +4366,7 @@ write_corpus_to_archive(const corpus& corp, static bool write_corpus_to_archive(const corpus& corp, archive_write_ctxt_sptr ctxt, - const bool annotate) + const bool annotate) {return write_corpus_to_archive(corp, *ctxt, annotate);} /// Serialize the current corpus to disk in a file at a given path. @@ -4382,7 +4382,7 @@ write_corpus_to_archive(const corpus& corp, bool write_corpus_to_archive(const corpus& corp, const string& path, - const bool annotate) + const bool annotate) { archive_write_ctxt_sptr ctxt = create_archive_write_context(path); ABG_ASSERT(ctxt); diff --git a/tools/abidiff.cc b/tools/abidiff.cc index 162d5ebc..4a9c4d1e 100644 --- a/tools/abidiff.cc +++ b/tools/abidiff.cc @@ -690,7 +690,7 @@ set_diff_context_from_opts(diff_context_sptr ctxt, // redundancy analysis pass altogether. That could help save a // couple of CPU cycle here and there! ctxt->show_redundant_changes(opts.show_redundant_changes - || opts.leaf_changes_only); + || opts.leaf_changes_only); ctxt->show_symbols_unreferenced_by_debug_info (opts.show_symbols_not_referenced_by_debug_info); ctxt->show_added_symbols_unreferenced_by_debug_info diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc index 7d946e72..a5fc0a7c 100644 --- a/tools/abipkgdiff.cc +++ b/tools/abipkgdiff.cc @@ -360,7 +360,7 @@ public: /// @param pkg_kind the kind of package. package(const string& path, const string& dir, - kind pkg_kind = package::KIND_MAIN) + kind pkg_kind = package::KIND_MAIN) : path_(path), kind_(pkg_kind) { @@ -767,9 +767,9 @@ package::extracted_packages_parent_dir() const char *cachedir = getenv("XDG_CACHE_HOME"); if (cachedir != NULL) - p = cachedir; + p = cachedir; else - { + { const char* s = getenv("HOME"); if (s != NULL) p = s; @@ -782,7 +782,7 @@ package::extracted_packages_parent_dir() p = "/tmp"; } p += "/.cache/libabigail"; - } + } // Create the cache directory if it doesn't exist ABG_ASSERT(ensure_dir_path_created(p)); @@ -1057,11 +1057,11 @@ extract_package(const package& package, case abigail::tools_utils::FILE_TYPE_RPM: #ifdef WITH_RPM if (!extract_rpm(package.path(), package.extracted_dir_path(), opts)) - { - emit_prefix("abipkgdiff", cerr) + { + emit_prefix("abipkgdiff", cerr) << "Error while extracting package " << package.path() << "\n"; - return false; - } + return false; + } return true; #else emit_prefix("abipkgdiff", cerr) @@ -1073,11 +1073,11 @@ extract_package(const package& package, case abigail::tools_utils::FILE_TYPE_DEB: #ifdef WITH_DEB if (!extract_deb(package.path(), package.extracted_dir_path(), opts)) - { - emit_prefix("abipkgdiff", cerr) + { + emit_prefix("abipkgdiff", cerr) << "Error while extracting package" << package.path() << "\n"; - return false; - } + return false; + } return true; #else emit_prefix("abipkgdiff", cerr) @@ -1095,12 +1095,12 @@ extract_package(const package& package, case abigail::tools_utils::FILE_TYPE_TAR: #ifdef WITH_TAR if (!extract_tar(package.path(), package.extracted_dir_path(), opts)) - { - emit_prefix("abipkgdiff", cerr) + { + emit_prefix("abipkgdiff", cerr) << "Error while extracting GNU tar archive " << package.path() << "\n"; - return false; - } + return false; + } return true; #else emit_prefix("abipkgdiff", cerr) @@ -1155,7 +1155,7 @@ set_diff_context_from_opts(diff_context_sptr ctxt, ctxt->error_output_stream(&cerr); // See comment in abidiff.cc's set_diff_context_from_opts. ctxt->show_redundant_changes(opts.show_redundant_changes - || opts.leaf_changes_only); + || opts.leaf_changes_only); ctxt->show_leaf_changes_only(opts.leaf_changes_only); ctxt->show_impacted_interfaces(opts.show_impacted_interfaces); ctxt->show_unreachable_types(opts.show_all_types); @@ -2015,7 +2015,7 @@ create_maps_of_package_content(package& package, options& opts) { if (e->type != abigail::dwarf_reader::ELF_TYPE_DSO && e->type != abigail::dwarf_reader::ELF_TYPE_EXEC - && e->type != abigail::dwarf_reader::ELF_TYPE_PI_EXEC) + && e->type != abigail::dwarf_reader::ELF_TYPE_PI_EXEC) { if (is_linux_kernel_package) { @@ -2364,7 +2364,7 @@ compare_prepared_userspace_packages(package& first_package, if (iter != second_package.path_elf_file_sptr_map().end() && (iter->second->type == abigail::dwarf_reader::ELF_TYPE_DSO || iter->second->type == abigail::dwarf_reader::ELF_TYPE_EXEC - || iter->second->type == abigail::dwarf_reader::ELF_TYPE_PI_EXEC + || iter->second->type == abigail::dwarf_reader::ELF_TYPE_PI_EXEC || iter->second->type == abigail::dwarf_reader::ELF_TYPE_RELOCATABLE)) { if (iter->second->type != abigail::dwarf_reader::ELF_TYPE_RELOCATABLE) @@ -2697,85 +2697,85 @@ parse_command_line(int argc, char* argv[], options& opts) for (int i = 1; i < argc; ++i) { if (argv[i][0] != '-') - { - if (opts.package1.empty()) - { - opts.package1 = make_path_absolute(argv[i]).get(); - opts.nonexistent_file = !file_exists(opts.package1); - } - else if (opts.package2.empty()) - { - opts.package2 = make_path_absolute(argv[i]).get(); - opts.nonexistent_file = !file_exists(opts.package2); - } - else + { + if (opts.package1.empty()) + { + opts.package1 = make_path_absolute(argv[i]).get(); + opts.nonexistent_file = !file_exists(opts.package1); + } + else if (opts.package2.empty()) + { + opts.package2 = make_path_absolute(argv[i]).get(); + opts.nonexistent_file = !file_exists(opts.package2); + } + else { opts.wrong_arg = argv[i]; return false; } - if (opts.nonexistent_file) - { - opts.wrong_option = argv[i]; - return true; - } - } + if (opts.nonexistent_file) + { + opts.wrong_option = argv[i]; + return true; + } + } else if (!strcmp(argv[i], "--debug-info-pkg1") || !strcmp(argv[i], "--d1")) - { - int j = i + 1; - if (j >= argc) - { + { + int j = i + 1; + if (j >= argc) + { opts.missing_operand = true; opts.wrong_option = argv[i]; return true; - } - opts.debug_packages1.push_back + } + opts.debug_packages1.push_back (abigail::tools_utils::make_path_absolute(argv[j]).get()); - ++i; - } + ++i; + } else if (!strcmp(argv[i], "--debug-info-pkg2") || !strcmp(argv[i], "--d2")) - { - int j = i + 1; - if (j >= argc) - { + { + int j = i + 1; + if (j >= argc) + { opts.missing_operand = true; opts.wrong_option = argv[i]; return true; - } - opts.debug_packages2.push_back + } + opts.debug_packages2.push_back (abigail::tools_utils::make_path_absolute(argv[j]).get()); - ++i; - } + ++i; + } else if (!strcmp(argv[i], "--devel-pkg1") || !strcmp(argv[i], "--devel1")) - { - int j = i + 1; - if (j >= argc) - { + { + int j = i + 1; + if (j >= argc) + { opts.missing_operand = true; opts.wrong_option = argv[i]; return true; - } - opts.devel_package1 = + } + opts.devel_package1 = abigail::tools_utils::make_path_absolute(argv[j]).get(); - ++i; - } + ++i; + } else if (!strcmp(argv[i], "--devel-pkg2") || !strcmp(argv[i], "--devel2")) - { - int j = i + 1; - if (j >= argc) - { + { + int j = i + 1; + if (j >= argc) + { opts.missing_operand = true; opts.wrong_option = argv[i]; return true; - } - opts.devel_package2 = + } + opts.devel_package2 = abigail::tools_utils::make_path_absolute(argv[j]).get(); - ++i; - } + ++i; + } else if (!strcmp(argv[i], "--drop-private-types")) opts.drop_private_types = true; else if (!strcmp(argv[i], "--no-default-suppression")) @@ -2877,10 +2877,10 @@ parse_command_line(int argc, char* argv[], options& opts) } else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) - { - opts.display_usage = true; - return true; - } + { + opts.display_usage = true; + return true; + } else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) { @@ -2921,7 +2921,7 @@ main(int argc, char* argv[]) { emit_prefix("abipkgdiff", cerr) << "missing operand\n" - "try the --help option for more information\n"; + "try the --help option for more information\n"; return (abigail::tools_utils::ABIDIFF_USAGE_ERROR | abigail::tools_utils::ABIDIFF_ERROR); }