From d3b286cb434ed228e7b62cc70cb293e7a5554bfa Mon Sep 17 00:00:00 2001 From: iphydf Date: Fri, 23 Feb 2018 02:22:38 +0000 Subject: Fix a bunch of compiler warnings and remove suppressions. --- other/analysis/gen-file.sh | 48 ++++++++++++++++++++++++++++++ other/analysis/run-clang | 7 +++++ other/analysis/run-cppcheck | 7 +++++ other/analysis/run-gcc | 72 +++++++++++++++++++++++++++++++++++++++++++++ other/analysis/run-infer | 10 +++++++ other/analysis/run-sparse | 9 ++++++ 6 files changed, 153 insertions(+) create mode 100644 other/analysis/gen-file.sh create mode 100755 other/analysis/run-clang create mode 100755 other/analysis/run-cppcheck create mode 100755 other/analysis/run-gcc create mode 100755 other/analysis/run-infer create mode 100755 other/analysis/run-sparse (limited to 'other/analysis') diff --git a/other/analysis/gen-file.sh b/other/analysis/gen-file.sh new file mode 100644 index 00000000..710e20d7 --- /dev/null +++ b/other/analysis/gen-file.sh @@ -0,0 +1,48 @@ +CPPFLAGS="-DMIN_LOGGER_LEVEL=LOG_TRACE -Iauto_tests -Itoxcore -Itoxav -Itoxencryptsave `pkg-config --cflags libsodium opus vpx`" + +put() { + if [ "$SKIP_LINES" = "" ]; then + echo "#line 1 \"$1\"" >> test.c + fi + cat $1 >> test.c +} + +:> test.c + +put toxcore/tox.c + +put toxcore/DHT.c +put toxcore/LAN_discovery.c +put toxcore/Messenger.c +put toxcore/TCP_client.c +put toxcore/TCP_connection.c +put toxcore/TCP_server.c +put toxcore/crypto_core.c +put toxcore/crypto_core_mem.c +put toxcore/friend_connection.c +put toxcore/friend_requests.c +put toxcore/group.c +put toxcore/list.c +put toxcore/logger.c +put toxcore/network.c +put toxcore/net_crypto.c +put toxcore/onion.c +put toxcore/onion_announce.c +put toxcore/onion_client.c +put toxcore/ping.c +put toxcore/ping_array.c +put toxcore/tox_api.c +put toxcore/util.c + +# Not included yet, since there are too many issues with this code. +#put toxav/audio.c +#put toxav/bwcontroller.c +#put toxav/groupav.c +#put toxav/msi.c +#put toxav/ring_buffer.c +#put toxav/rtp.c +#put toxav/toxav.c +#put toxav/toxav_old.c +#put toxav/video.c + +put toxencryptsave/toxencryptsave.c diff --git a/other/analysis/run-clang b/other/analysis/run-clang new file mode 100755 index 00000000..1c8da7ea --- /dev/null +++ b/other/analysis/run-clang @@ -0,0 +1,7 @@ +#!/bin/sh + +. other/analysis/gen-file.sh + +put auto_tests/lan_discovery_test.c + +clang --analyze test.c $CPPFLAGS diff --git a/other/analysis/run-cppcheck b/other/analysis/run-cppcheck new file mode 100755 index 00000000..9e928c9a --- /dev/null +++ b/other/analysis/run-cppcheck @@ -0,0 +1,7 @@ +#!/bin/sh + +. other/analysis/gen-file.sh + +put auto_tests/lan_discovery_test.c + +cppcheck test.c $CPPFLAGS diff --git a/other/analysis/run-gcc b/other/analysis/run-gcc new file mode 100755 index 00000000..ffd42f4e --- /dev/null +++ b/other/analysis/run-gcc @@ -0,0 +1,72 @@ +#!/bin/sh + +. other/analysis/gen-file.sh + +put auto_tests/lan_discovery_test.c + +# TODO(iphydf): Get rid of all VLAs, then enable -fstack-protector -Wstack-protector +gcc -O3 -c -o /dev/null test.c $CPPFLAGS \ + -std=c99 \ + -pedantic \ + -Wall \ + -Wextra \ + -Wno-aggregate-return \ + -Wno-aggressive-loop-optimizations \ + -Wno-float-conversion \ + -Wno-format-signedness \ + -Wno-missing-field-initializers \ + -Wno-padded \ + -Wno-sign-compare \ + -Wno-sign-conversion \ + -Wno-switch-default \ + -Wno-unused-parameter \ + -Wstrict-aliasing=0 \ + -Wstrict-overflow=1 \ + \ + -Wbad-function-cast \ + -Wmissing-declarations \ + -Wmissing-parameter-type \ + -Wmissing-prototypes \ + -Wnested-externs \ + -Wold-style-declaration \ + -Wold-style-definition \ + -Wstrict-prototypes \ + -Wbool-compare \ + -Wc99-c11-compat \ + -Wc++-compat \ + -Wcast-align \ + -Wcast-qual \ + -Wchar-subscripts \ + -Wdouble-promotion \ + -Wduplicated-cond \ + -Wempty-body \ + -Wenum-compare \ + -Wfloat-equal \ + -Wformat=2 \ + -Wframe-address \ + -Wframe-larger-than=133168 \ + -Wjump-misses-init \ + -Wignored-qualifiers \ + -Wignored-attributes \ + -Wincompatible-pointer-types \ + -Winit-self \ + -Winline \ + -Wlarger-than=133120 \ + -Wmaybe-uninitialized \ + -Wmemset-transposed-args \ + -Wmisleading-indentation \ + -Wnonnull \ + -Wnonnull-compare \ + -Wnull-dereference \ + -Wodr \ + -Wredundant-decls \ + -Wreturn-type \ + -Wshadow \ + -Wsuggest-attribute=format \ + -Wundef \ + -Wunsafe-loop-optimizations \ + -Wunused-label \ + -Wunused-local-typedefs \ + -Wunused-value \ + -Wunused-but-set-parameter \ + -Wunused-but-set-variable \ diff --git a/other/analysis/run-infer b/other/analysis/run-infer new file mode 100755 index 00000000..942d0cfd --- /dev/null +++ b/other/analysis/run-infer @@ -0,0 +1,10 @@ +#!/bin/sh + +# Infer ignores everything that's not in the "current file". +SKIP_LINES=1 + +. other/analysis/gen-file.sh + +put auto_tests/lan_discovery_test.c + +infer -- clang -fsyntax-only test.c $CPPFLAGS diff --git a/other/analysis/run-sparse b/other/analysis/run-sparse new file mode 100755 index 00000000..b4d0f736 --- /dev/null +++ b/other/analysis/run-sparse @@ -0,0 +1,9 @@ +#!/bin/sh + +. other/analysis/gen-file.sh + +put auto_tests/lan_discovery_test.c + +sparse test.c $CPPFLAGS \ + -Wsparse-all \ + -Wno-declaration-after-statement -- cgit v1.2.3