Skip to content

Commit

Permalink
ci: enable warnings as errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Dec 10, 2021
1 parent 660352f commit a6f022e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 48 deletions.
51 changes: 29 additions & 22 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,35 @@ jobs:
build_type: [Debug, Release]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@master
with:
version: 1.10.0
- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@master
with:
version: 1.10.0

- name: Configure
run: |
cmake -S . -B build_${{matrix.abi}} \
-DANDROID_ABI=${{matrix.abi}} \
-DANDROID_NATIVE_API_LEVEL=28 \
-DANDROID_STL=c++_shared \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \
-G Ninja \
-Werror
- name: Setup C++98 Environment
if: matrix.std == '98'
run: |
echo 'CXXFLAGS=-Wno-error=variadic-macros -Wno-error=long-long ${{env.CXXFLAGS}}' >> $GITHUB_ENV
- name: Build
run: |
cmake --build build_${{matrix.abi}} \
--config ${{matrix.build_type}}
- name: Configure
env:
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Werror ${{env.CXXFLAGS}}
run: |
cmake -S . -B build_${{matrix.abi}} \
-DANDROID_ABI=${{matrix.abi}} \
-DANDROID_NATIVE_API_LEVEL=28 \
-DANDROID_STL=c++_shared \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \
-G Ninja \
-Werror
- name: Build
run: |
cmake --build build_${{matrix.abi}} \
--config ${{matrix.build_type}}
7 changes: 7 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ jobs:
echo 'CXXFLAGS=--coverage' >> $GITHUB_ENV
echo 'GTest_ROOT=${{github.workspace}}/gtest' >> $GITHUB_ENV
- name: Setup C++98 Environment
if: matrix.std == '98'
run: |
echo 'CXXFLAGS=-Wno-error=variadic-macros -Wno-error=long-long ${{env.CXXFLAGS}}' >> $GITHUB_ENV
- name: Configure
env:
CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Werror ${{env.CXXFLAGS}}
run: |
cmake -S . -B build_${{matrix.build_type}} \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ jobs:
run: |
echo 'CXXFLAGS=--coverage' >> $GITHUB_ENV
- name: Setup C++98 Environment
if: matrix.std == '98'
run: |
echo 'CXXFLAGS=-Wall -Wextra -Wsign-conversion -Wtautological-compare -Werror ${{env.CXXFLAGS}}' >> $GITHUB_ENV
- name: Configure
shell: bash
env:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ jobs:
mingw-w64-${{matrix.env}}-gflags
mingw-w64-${{matrix.env}}-ninja
- name: Setup C++98 Environment
if: matrix.std == '98'
run: |
echo 'CXXFLAGS=-Wno-error=variadic-macros -Wno-error=long-long ${{env.CXXFLAGS}}' >> $GITHUB_ENV
- name: Configure
env:
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Werror -Wno-error=variadic-macros -Wno-error=long-long
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Werror ${{env.CXXFLAGS}}
run: |
if [[ ${{matrix.build_type}} == "Debug" ]]; then
export CXXFLAGS="--coverage ${CXXFLAGS}"
Expand Down
25 changes: 5 additions & 20 deletions src/symbolize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -666,12 +666,12 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,

// POSIX doesn't define any async-signal safe function for converting
// an integer to ASCII. We'll have to define our own version.
// itoa_r() converts a (signed) integer to ASCII. It returns "buf", if the
// itoa_r() converts an (unsigned) integer to ASCII. It returns "buf", if the
// conversion was successful or NULL otherwise. It never writes more than "sz"
// 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(intptr_t i, char *buf, size_t sz, unsigned base, size_t padding) {
static char *itoa_r(uintptr_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)
Expand All @@ -684,21 +684,6 @@ static char *itoa_r(intptr_t i, char *buf, size_t sz, unsigned base, size_t padd

char *start = buf;

uintptr_t j = static_cast<uintptr_t>(i);

// Handle negative numbers (only for base 10).
if (i < 0 && base == 10) {
// This does "j = -i" while avoiding integer overflow.
j = static_cast<uintptr_t>(-(i + 1)) + 1;

// Make sure we can write the '-' character.
if (++n > sz) {
buf[0] = '\000';
return NULL;
}
*start++ = '-';
}

// Loop until we have converted the entire number. Output at least one
// character (i.e. '0').
char *ptr = start;
Expand All @@ -710,12 +695,12 @@ static char *itoa_r(intptr_t i, char *buf, size_t sz, unsigned base, size_t padd
}

// Output the next digit.
*ptr++ = "0123456789abcdef"[j % base];
j /= base;
*ptr++ = "0123456789abcdef"[i % base];
i /= base;

if (padding > 0)
padding--;
} while (j > 0 || padding > 0);
} while (i > 0 || padding > 0);

// Terminate the output with a NUL character.
*ptr = '\000';
Expand Down

0 comments on commit a6f022e

Please sign in to comment.