From 92cb3c449b5dfc1f4005d8037519f15a2b76301e Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Sun, 1 Aug 2021 14:52:03 +0200 Subject: [PATCH] fixed additional warnings --- .github/workflows/macos-builds.yml | 2 +- .github/workflows/windows-builds.yml | 2 +- src/symbolize.cc | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/macos-builds.yml b/.github/workflows/macos-builds.yml index 58321cc..3629d34 100644 --- a/.github/workflows/macos-builds.yml +++ b/.github/workflows/macos-builds.yml @@ -25,7 +25,7 @@ jobs: - name: Configure shell: bash env: - CXXFLAGS: -Wall -Wextra -Wsign-conversion -Werror + CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Werror run: | if [[ ${{matrix.std}} == 98 ]]; then export CXXFLAGS="-Werror=c++11-extensions ${CXXFLAGS}" diff --git a/.github/workflows/windows-builds.yml b/.github/workflows/windows-builds.yml index 12628a8..911daa7 100644 --- a/.github/workflows/windows-builds.yml +++ b/.github/workflows/windows-builds.yml @@ -102,7 +102,7 @@ jobs: if: ${{ startswith(matrix.config.name, 'MinGW-') }} shell: powershell env: - CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Werror -Wno-error=variadic-macros -Wno-error=long-long + CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Werror -Wno-error=variadic-macros -Wno-error=long-long run: cmake -S . -B ${{runner.workspace}}/build_${{matrix.config.name}}_${{matrix.build_type}} -G "${{matrix.config.generator}}" -DCMAKE_CXX_STANDARD=${{matrix.config.std}} -DCMAKE_CXX_EXTENSIONS=OFF -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}} - name: Build MinGW if: ${{ startswith(matrix.config.name, 'MinGW-') }} diff --git a/src/symbolize.cc b/src/symbolize.cc index 99cc79e..acfd35e 100644 --- a/src/symbolize.cc +++ b/src/symbolize.cc @@ -233,8 +233,9 @@ bool GetSectionHeaderByName(int fd, const char *name, size_t name_len, } ElfW(Shdr) shstrtab; - size_t shstrtab_offset = (elf_header.e_shoff + - elf_header.e_shentsize * elf_header.e_shstrndx); + size_t shstrtab_offset = + (elf_header.e_shoff + static_cast(elf_header.e_shentsize) * + static_cast(elf_header.e_shstrndx)); if (!ReadFromOffsetExact(fd, &shstrtab, sizeof(shstrtab), shstrtab_offset)) { return false; } @@ -670,7 +671,7 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc, // bytes. Output will be truncated as needed, and a NUL character is always // appended. // NOTE: code from sandbox/linux/seccomp-bpf/demo.cc. -static char *itoa_r(uintptr_t i, char *buf, size_t sz, unsigned base, size_t padding) { +static char *itoa_r(intptr_t i, char *buf, size_t sz, unsigned base, size_t padding) { // Make sure we can write at least one NUL byte. size_t n = 1; if (n > sz) @@ -683,7 +684,7 @@ static char *itoa_r(uintptr_t i, char *buf, size_t sz, unsigned base, size_t pad char *start = buf; - uintptr_t j = i; + uintptr_t j = static_cast(i); // Handle negative numbers (only for base 10). if (i < 0 && base == 10) { @@ -943,7 +944,6 @@ _END_GOOGLE_NAMESPACE_ _START_GOOGLE_NAMESPACE_ bool Symbolize(void *pc, char *out, size_t out_size) { - SAFE_ASSERT(out_size >= 0); return SymbolizeAndDemangle(pc, out, out_size); }