Skip to content

Commit

Permalink
cleanup: Add nonnull annotations to function definitions.
Browse files Browse the repository at this point in the history
These help static analysis and ubsan. We should eventually have all
functions annotated like this with a cimple check to make sure every
pointer has an explicit nullability annotation. The `nullable`
annotation does nothing in GCC, but will be used by cimple to validate
that every parameter has defined nullability.
  • Loading branch information
iphydf committed Feb 8, 2022
1 parent 6f36b67 commit 5a3a0b6
Show file tree
Hide file tree
Showing 12 changed files with 248 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/scripts/flags-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ add_flag -Wno-reserved-id-macro
# TODO(iphydf): Clean these up. They are likely not bugs, but still
# potential issues and probably confusing.
add_flag -Wno-sign-compare
# __attribute__((nonnull)) causes this warning on defensive null checks.
add_flag -Wno-tautological-pointer-compare
# Our use of mutexes results in a false positive, see 1bbe446.
add_flag -Wno-thread-safety-analysis
# File transfer code has this.
Expand Down
2 changes: 2 additions & 0 deletions .github/scripts/flags-gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ add_flag -Wno-unused-parameter
# struct Foo foo = {0}; is a common idiom. Missing braces means we'd need to
# write {{{0}}} in some cases, which is ugly and a maintenance burden.
add_flag -Wno-missing-braces
# __attribute__((nonnull)) causes this warning on defensive null checks.
add_flag -Wno-nonnull-compare
4 changes: 2 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[build]
command = """\
if cd doxygen-awesome-css; then \
git pull && cd ..; \
git pull --rebase && cd ..; \
else \
git clone --depth=1 https://github.com/jothepro/doxygen-awesome-css.git;
git clone --depth=1 https://github.com/jothepro/doxygen-awesome-css;
fi && \
doxygen docs/Doxyfile \
"""
Expand Down
1 change: 1 addition & 0 deletions other/analysis/run-clang
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ run() {
-Wno-old-style-cast \
-Wno-padded \
-Wno-sign-compare \
-Wno-tautological-pointer-compare \
-Wno-unreachable-code-return \
-Wno-unused-parameter \
-Wno-used-but-marked-unused \
Expand Down
7 changes: 6 additions & 1 deletion other/analysis/run-clang-tidy
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/bin/bash

CHECKS="*"

# __attribute__((nonnull)) causes this warning on defensive null checks.
CHECKS="$CHECKS,-clang-diagnostic-pointer-bool-conversion"
CHECKS="$CHECKS,-clang-diagnostic-tautological-pointer-compare"

# TODO(iphydf): We might want some of these. For the ones we don't want, add a
# comment explaining why not.
CHECKS="*"
CHECKS="$CHECKS,-altera-unroll-loops"
CHECKS="$CHECKS,-android-cloexec-accept"
CHECKS="$CHECKS,-android-cloexec-fopen"
Expand Down
2 changes: 1 addition & 1 deletion other/analysis/run-gcc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ run() {
-Wno-float-conversion \
-Wno-format-signedness \
-Wno-missing-field-initializers \
-Wno-nonnull-compare \
-Wno-padded \
-Wno-sign-compare \
-Wno-sign-conversion \
Expand Down Expand Up @@ -52,7 +53,6 @@ run() {
-Wmemset-transposed-args \
-Wmisleading-indentation \
-Wnonnull \
-Wnonnull-compare \
-Wnull-dereference \
-Wodr \
-Wredundant-decls \
Expand Down
11 changes: 8 additions & 3 deletions other/bootstrap_daemon/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ RUN ["apk", "--no-cache", "add",\
"linux-headers",\
"libconfig-dev",\
"libconfig-static",\
"msgpack-c-dev",\
"libsodium-dev",\
"libsodium-static",\
"msgpack-c-dev",\
"ninja",\
"python3"\
]
Expand All @@ -33,10 +33,11 @@ COPY CMakeLists.txt so.version ./

RUN cmake -B_build -H. \
-GNinja \
-DCMAKE_C_FLAGS=-DTCP_SERVER_USE_EPOLL \
-DMIN_LOGGER_LEVEL=DEBUG \
-DCMAKE_C_FLAGS="-DTCP_SERVER_USE_EPOLL -fstack-protector-all -fisolate-erroneous-paths-attribute" \
-DCMAKE_UNITY_BUILD=ON \
-DCMAKE_BUILD_TYPE=Release \
-DFULLY_STATIC=ON \
-DMIN_LOGGER_LEVEL=DEBUG \
-DBUILD_TOXAV=OFF \
-DBOOTSTRAP_DAEMON=ON && \
cmake --build _build --target install
Expand Down Expand Up @@ -73,6 +74,10 @@ WORKDIR /var/lib/tox-bootstrapd

USER tox-bootstrapd

# Smoke-test: make sure the binary actually starts up.
# hadolint ignore=DL4006
RUN script /usr/local/bin/tox-bootstrapd --help | grep "Usage"

ENTRYPOINT ["/usr/local/bin/tox-bootstrapd",\
"--config", "/etc/tox-bootstrapd.conf",\
"--log-backend", "stdout",\
Expand Down
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dd0f0cc84ecb5ce44ca56ff47793fca162e12b1a542c34e39fae4d3e53996874 /usr/local/bin/tox-bootstrapd
30845d5b6a5a2606afccceff83c7f1089040a800eb138c9ad92932cea2447e30 /usr/local/bin/tox-bootstrapd
Loading

0 comments on commit 5a3a0b6

Please sign in to comment.