Fix build failures.

- Fix a test build failure introduced by cc7abac08b.
- Use strcmp from <string> instead of std::strcmp from <cstring>.

Bug: google-breakpad:867
Change-Id: I8dcbc7d5ac8ea799b4d5287ddbbf5d6626992123
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4095054
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Zequan Wu 2022-12-12 17:22:04 +08:00 committed by Mike Frysinger
parent cc7abac08b
commit 9acaa082c8
2 changed files with 7 additions and 7 deletions

View file

@ -183,7 +183,7 @@ class Elf64 {
template<class ElfArch> template<class ElfArch>
class ElfSectionReader { class ElfSectionReader {
public: public:
ElfSectionReader(const char* name, const string& path, int fd, ElfSectionReader(const char* cname, const string& path, int fd,
const typename ElfArch::Shdr& section_header) const typename ElfArch::Shdr& section_header)
: contents_aligned_(NULL), : contents_aligned_(NULL),
contents_(NULL), contents_(NULL),
@ -198,8 +198,8 @@ class ElfSectionReader {
if (header_.sh_type == SHT_NOBITS || header_.sh_size == 0) if (header_.sh_type == SHT_NOBITS || header_.sh_size == 0)
return; return;
// extra sh_type check for string table. // extra sh_type check for string table.
if ((std::strcmp(name, ".strtab") == 0 || std::string_view name{cname};
std::strcmp(name, ".shstrtab") == 0) && if ((name == ".strtab" || name == ".shstrtab") &&
header_.sh_type != SHT_STRTAB) { header_.sh_type != SHT_STRTAB) {
fprintf(stderr, fprintf(stderr,
"Invalid sh_type for string table section: expected " "Invalid sh_type for string table section: expected "
@ -215,7 +215,7 @@ class ElfSectionReader {
(header_.sh_offset - offset_aligned); (header_.sh_offset - offset_aligned);
// Check for and handle any compressed contents. // Check for and handle any compressed contents.
//if (strncmp(name, ".zdebug_", strlen(".zdebug_")) == 0) //if (name == ".zdebug_")
// DecompressZlibContents(); // DecompressZlibContents();
// TODO(saugustine): Add support for proposed elf-section flag // TODO(saugustine): Add support for proposed elf-section flag
// "SHF_COMPRESS". // "SHF_COMPRESS".

View file

@ -91,7 +91,7 @@ TYPED_TEST(DumpSymbols, Invalid) {
Elf32_Ehdr header; Elf32_Ehdr header;
memset(&header, 0, sizeof(header)); memset(&header, 0, sizeof(header));
Module* module; Module* module;
DumpOptions options(ALL_SYMBOL_DATA, true); DumpOptions options(ALL_SYMBOL_DATA, true, false);
EXPECT_FALSE(ReadSymbolDataInternal(reinterpret_cast<uint8_t*>(&header), EXPECT_FALSE(ReadSymbolDataInternal(reinterpret_cast<uint8_t*>(&header),
"foo", "foo",
"Linux", "Linux",
@ -128,7 +128,7 @@ TYPED_TEST(DumpSymbols, SimplePublic) {
this->GetElfContents(elf); this->GetElfContents(elf);
Module* module; Module* module;
DumpOptions options(ALL_SYMBOL_DATA, true); DumpOptions options(ALL_SYMBOL_DATA, true, false);
EXPECT_TRUE(ReadSymbolDataInternal(this->elfdata, EXPECT_TRUE(ReadSymbolDataInternal(this->elfdata,
"foo", "foo",
"Linux", "Linux",
@ -185,7 +185,7 @@ TYPED_TEST(DumpSymbols, SimpleBuildID) {
this->GetElfContents(elf); this->GetElfContents(elf);
Module* module; Module* module;
DumpOptions options(ALL_SYMBOL_DATA, true); DumpOptions options(ALL_SYMBOL_DATA, true, false);
EXPECT_TRUE(ReadSymbolDataInternal(this->elfdata, EXPECT_TRUE(ReadSymbolDataInternal(this->elfdata,
"foo", "foo",
"Linux", "Linux",