From ef4897a8984a512e0e8f9e501fc90dffe18195bc Mon Sep 17 00:00:00 2001 From: iphydf Date: Tue, 26 Dec 2023 19:39:22 +0000 Subject: [PATCH] cleanup: Upgrade to clang-tidy-17 and fix some warnings. --- .circleci/config.yml | 19 --- .clang-tidy | 4 +- .github/workflows/ci.yml | 10 ++ other/DHT_bootstrap.c | 29 +++-- other/analysis/run-clang-tidy | 114 ++++++++++-------- .../docker/tox-bootstrapd.sha256 | 2 +- .../src/command_line_arguments.c | 21 ++-- .../src/command_line_arguments.h | 14 ++- other/bootstrap_daemon/src/tox-bootstrapd.c | 32 +++-- other/docker/autotools/Dockerfile | 3 +- other/docker/clang-tidy/Dockerfile | 20 +++ other/docker/clang-tidy/run | 5 + other/docker/misra/Dockerfile | 3 +- other/docker/tokstyle/Dockerfile | 3 +- testing/BUILD.bazel | 1 - toxcore/events/friend_status.c | 2 +- toxcore/list.c | 2 + 17 files changed, 178 insertions(+), 106 deletions(-) create mode 100644 other/docker/clang-tidy/Dockerfile create mode 100755 other/docker/clang-tidy/run diff --git a/.circleci/config.yml b/.circleci/config.yml index 9006f681..5531177d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,6 @@ workflows: - ubsan # Static analysis - clang-analyze - - clang-tidy - cpplint - infer - static-analysis @@ -154,24 +153,6 @@ jobs: - run: git submodule update --init --recursive - run: other/analysis/run-clang-analyze - clang-tidy: - working_directory: ~/work - docker: - - image: ubuntu - - steps: - - run: *apt_install - - run: - apt-get install -y --no-install-recommends - ca-certificates - clang-tidy-14 - - checkout - - run: git submodule update --init --recursive - - run: - other/analysis/run-clang-tidy || - other/analysis/run-clang-tidy || - other/analysis/run-clang-tidy - cpplint: working_directory: ~/work docker: diff --git a/.clang-tidy b/.clang-tidy index 5ad92a14..b6423bc9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -35,6 +35,8 @@ CheckOptions: value: lower_case - key: llvmlibc-restrict-system-libc-headers.Includes - value: "arpa/inet.h,assert.h,ctype.h,errno.h,fcntl.h,getopt.h,libconfig.h,linux/netdevice.h,math.h,netdb.h,netinet/in.h,opus.h,pthread.h,signal.h,sodium/crypto_scalarmult_curve25519.h,sodium.h,sodium/randombytes.h,stdio.h,stdlib.h,string.h,sys/ioctl.h,syslog.h,sys/resource.h,sys/socket.h,sys/stat.h,sys/time.h,sys/types.h,time.h,unistd.h,vpx/vp8cx.h,vpx/vp8dx.h,vpx/vpx_decoder.h,vpx/vpx_encoder.h,vpx/vpx_image.h" + value: "arpa/inet.h,assert.h,ctype.h,errno.h,fcntl.h,getopt.h,libconfig.h,limits.h,linux/netdevice.h,math.h,netdb.h,netinet/in.h,opus.h,pthread.h,signal.h,sodium/crypto_scalarmult_curve25519.h,sodium.h,sodium/randombytes.h,stdarg.h,stdbool.h,stdint.h,stdio.h,stdlib.h,string.h,sys/ioctl.h,syslog.h,sys/resource.h,sys/socket.h,sys/stat.h,sys/time.h,sys/types.h,time.h,unistd.h,vpx/vp8cx.h,vpx/vp8dx.h,vpx/vpx_decoder.h,vpx/vpx_encoder.h,vpx/vpx_image.h" - key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals value: true + - key: concurrency-mt-unsafe.FunctionSet + value: posix diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea641dbb..fdcab2cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,16 @@ jobs: (find . -name "*.py" -and -not -name "conanfile.py"; grep -lR '^#!.*python') \ | xargs -n1 -P8 mypy --strict + clang-tidy: + runs-on: ubuntu-latest + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Docker Build + uses: docker/build-push-action@v4 + with: + file: other/docker/clang-tidy/Dockerfile + doxygen: runs-on: ubuntu-latest steps: diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index 93bf72a1..6c5a27c6 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c @@ -46,7 +46,7 @@ static const char *motd_str = ""; //Change this to anything within 256 bytes(but #define PORT 33445 -static void manage_keys(DHT *dht) +static bool manage_keys(DHT *dht) { enum { KEYS_SIZE = CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE }; uint8_t keys[KEYS_SIZE]; @@ -60,7 +60,8 @@ static void manage_keys(DHT *dht) if (read_size != KEYS_SIZE) { printf("Error while reading the key file\nExiting.\n"); - exit(1); + fclose(keys_file); + return false; } dht_set_self_public_key(dht, keys); @@ -73,18 +74,20 @@ static void manage_keys(DHT *dht) if (keys_file == nullptr) { printf("Error opening key file in write mode.\nKeys will not be saved.\n"); - return; + return false; } if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) { printf("Error while writing the key file.\nExiting.\n"); - exit(1); + fclose(keys_file); + return false; } printf("Keys saved successfully.\n"); } fclose(keys_file); + return true; } static const char *strlevel(Logger_Level level) @@ -121,7 +124,7 @@ int main(int argc, char *argv[]) if (argc == 2 && !tox_strncasecmp(argv[1], "-h", 3)) { printf("Usage (connected) : %s [--ipv4|--ipv6] IP PORT KEY\n", argv[0]); printf("Usage (unconnected): %s [--ipv4|--ipv6]\n", argv[0]); - exit(0); + return 0; } /* let user override default by cmdline */ @@ -129,7 +132,7 @@ int main(int argc, char *argv[]) int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); if (argvoffset < 0) { - exit(1); + return 1; } /* Initialize networking - @@ -162,14 +165,16 @@ int main(int argc, char *argv[]) if (!(onion && forwarding && onion_a)) { printf("Something failed to initialize.\n"); - exit(1); + return 1; } gca_onion_init(gc_announces_list, onion_a); perror("Initialization"); - manage_keys(dht); + if (!manage_keys(dht)) { + return 1; + } printf("Public key: "); #ifdef TCP_RELAY_ENABLED @@ -179,7 +184,7 @@ int main(int argc, char *argv[]) if (tcp_s == nullptr) { printf("TCP server failed to initialize.\n"); - exit(1); + return 1; } #endif @@ -189,7 +194,7 @@ int main(int argc, char *argv[]) if (file == nullptr) { printf("Could not open file \"%s\" for writing. Exiting...\n", public_id_filename); - exit(1); + return 1; } for (uint32_t i = 0; i < 32; ++i) { @@ -210,7 +215,7 @@ int main(int argc, char *argv[]) if (port_conv <= 0 || port_conv > UINT16_MAX) { printf("Failed to convert \"%s\" into a valid port. Exiting...\n", argv[argvoffset + 2]); - exit(1); + return 1; } const uint16_t port = net_htons((uint16_t)port_conv); @@ -222,7 +227,7 @@ int main(int argc, char *argv[]) if (!res) { printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); - exit(1); + return 1; } } diff --git a/other/analysis/run-clang-tidy b/other/analysis/run-clang-tidy index d1fcae1a..dc8177f6 100755 --- a/other/analysis/run-clang-tidy +++ b/other/analysis/run-clang-tidy @@ -1,6 +1,55 @@ -#!/bin/bash +#!/usr/bin/env bash CHECKS="*" +ERRORS="*" + +# Need to investigate or disable and document these. +# ========================================================= + +# TODO(iphydf): Fix these. +ERRORS="$ERRORS,-cert-err34-c" +ERRORS="$ERRORS,-cert-str34-c" +ERRORS="$ERRORS,-readability-suspicious-call-argument" + +# TODO(iphydf): Fix these. +CHECKS="$CHECKS,-bugprone-switch-missing-default-case" +CHECKS="$CHECKS,-misc-include-cleaner" + +# TODO(iphydf): We might want some of these. For the ones we don't want, add a +# comment explaining why not. +CHECKS="$CHECKS,-clang-analyzer-optin.performance.Padding" +CHECKS="$CHECKS,-hicpp-signed-bitwise" +CHECKS="$CHECKS,-readability-function-cognitive-complexity" + +# TODO(iphydf): Maybe fix these? +CHECKS="$CHECKS,-bugprone-easily-swappable-parameters" +CHECKS="$CHECKS,-bugprone-implicit-widening-of-multiplication-result" +CHECKS="$CHECKS,-bugprone-integer-division" +CHECKS="$CHECKS,-clang-analyzer-core.NullDereference" +CHECKS="$CHECKS,-clang-analyzer-valist.Uninitialized" +CHECKS="$CHECKS,-cppcoreguidelines-avoid-non-const-global-variables" +CHECKS="$CHECKS,-misc-no-recursion" + +# TODO(iphydf): Probably fix these. +CHECKS="$CHECKS,-cert-err33-c" +CHECKS="$CHECKS,-cppcoreguidelines-avoid-magic-numbers" +CHECKS="$CHECKS,-google-readability-casting" +CHECKS="$CHECKS,-modernize-macro-to-enum" +CHECKS="$CHECKS,-readability-magic-numbers" + +# Documented disabled checks. We don't want these for sure. +# ========================================================= + +# Callback handlers often don't use all their parameters. There's +# IgnoreVirtual, but that doesn't work for C-style callbacks. +CHECKS="$CHECKS,-misc-unused-parameters" + +# We sometimes use #if 0. +CHECKS="$CHECKS,-readability-avoid-unconditional-preprocessor-if" + +# We have better macro hygiene checks with tokstyle. We can never pass macro +# arguments that require parentheses inside the macro. +CHECKS="$CHECKS,-bugprone-macro-parentheses" # We don't use memcpy_s. CHECKS="$CHECKS,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling" @@ -81,42 +130,6 @@ CHECKS="$CHECKS,-cert-dcl03-c" CHECKS="$CHECKS,-hicpp-static-assert" CHECKS="$CHECKS,-misc-static-assert" -# TODO(iphydf): We might want some of these. For the ones we don't want, add a -# comment explaining why not. -CHECKS="$CHECKS,-clang-analyzer-optin.performance.Padding" -CHECKS="$CHECKS,-hicpp-signed-bitwise" -CHECKS="$CHECKS,-misc-unused-parameters" -CHECKS="$CHECKS,-readability-function-cognitive-complexity" - -# TODO(iphydf): Maybe fix these? -CHECKS="$CHECKS,-bugprone-easily-swappable-parameters" -CHECKS="$CHECKS,-bugprone-implicit-widening-of-multiplication-result" -CHECKS="$CHECKS,-bugprone-integer-division" -CHECKS="$CHECKS,-clang-analyzer-core.NullDereference" -CHECKS="$CHECKS,-clang-analyzer-valist.Uninitialized" -CHECKS="$CHECKS,-concurrency-mt-unsafe" -CHECKS="$CHECKS,-cppcoreguidelines-avoid-non-const-global-variables" -CHECKS="$CHECKS,-misc-no-recursion" - -# TODO(iphydf): Probably fix these. -CHECKS="$CHECKS,-cert-err33-c" -CHECKS="$CHECKS,-cppcoreguidelines-avoid-magic-numbers" -CHECKS="$CHECKS,-google-readability-casting" -CHECKS="$CHECKS,-modernize-macro-to-enum" -CHECKS="$CHECKS,-readability-magic-numbers" - -# TODO(iphydf): These two trip on list.c. Investigate why. -CHECKS="$CHECKS,-clang-analyzer-core.NonNullParamChecker" -CHECKS="$CHECKS,-clang-analyzer-unix.Malloc" - -ERRORS="*" - -# TODO(iphydf): Fix these. -ERRORS="$ERRORS,-bugprone-macro-parentheses" -ERRORS="$ERRORS,-cert-err34-c" -ERRORS="$ERRORS,-cert-str34-c" -ERRORS="$ERRORS,-readability-suspicious-call-argument" - set -eux run() { @@ -125,18 +138,21 @@ run() { for i in "${!EXTRA_ARGS[@]}"; do EXTRA_ARGS[$i]="--extra-arg=${EXTRA_ARGS[$i]}" done - clang-tidy-14 \ - -p=_build \ - --extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \ - "${EXTRA_ARGS[@]}" \ - --checks="$CHECKS" \ - --warnings-as-errors="$ERRORS" \ - --use-color \ - other/bootstrap_daemon/src/*.c \ - other/*.c \ - toxav/*.c \ - toxcore/*.c \ - toxencryptsave/*.c + find \ + other/bootstrap_daemon/src \ + other \ + toxav \ + toxcore \ + toxcore/events \ + toxencryptsave \ + -maxdepth 1 -name "*.c" -print0 \ + | xargs -0 -n15 -P"$(nproc)" clang-tidy \ + -p=_build \ + --extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \ + "${EXTRA_ARGS[@]}" \ + --checks="$CHECKS" \ + --warnings-as-errors="$ERRORS" \ + --use-color } cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON diff --git a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 index 65acdd98..57cad658 100644 --- a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 +++ b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 @@ -1 +1 @@ -68432689967d06dd144e5cdfe37751ccc62b2aa85b73a9cc55aff3732dc47fde /usr/local/bin/tox-bootstrapd +793cce1916b0d406b8e337d1a5243dc71b07727974cc83a3ef39b7af6cbf6cdb /usr/local/bin/tox-bootstrapd diff --git a/other/bootstrap_daemon/src/command_line_arguments.c b/other/bootstrap_daemon/src/command_line_arguments.c index f7af443e..60bd5245 100644 --- a/other/bootstrap_daemon/src/command_line_arguments.c +++ b/other/bootstrap_daemon/src/command_line_arguments.c @@ -47,13 +47,14 @@ static void print_help(void) " --version Print version information.\n"); } -void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend, - bool *run_in_foreground) +Cli_Status handle_command_line_arguments( + int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend, + bool *run_in_foreground) { if (argc < 2) { log_write(LOG_LEVEL_ERROR, "Error: No arguments provided.\n\n"); print_help(); - exit(1); + return CLI_STATUS_ERROR; } opterr = 0; @@ -89,7 +90,7 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, case 'h': print_help(); - exit(0); + return CLI_STATUS_DONE; case 'l': if (strcmp(optarg, "syslog") == 0) { @@ -101,24 +102,24 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, } else { log_write(LOG_LEVEL_ERROR, "Error: Invalid BACKEND value for --log-backend option passed: %s\n\n", optarg); print_help(); - exit(1); + return CLI_STATUS_ERROR; } break; case 'v': log_write(LOG_LEVEL_INFO, "Version: %lu\n", DAEMON_VERSION_NUMBER); - exit(0); + return CLI_STATUS_DONE; case '?': log_write(LOG_LEVEL_ERROR, "Error: Unrecognized option %s\n\n", argv[optind - 1]); print_help(); - exit(1); + return CLI_STATUS_ERROR; case ':': log_write(LOG_LEVEL_ERROR, "Error: No argument provided for option %s\n\n", argv[optind - 1]); print_help(); - exit(1); + return CLI_STATUS_ERROR; } } @@ -129,6 +130,8 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, if (!cfg_file_path_set) { log_write(LOG_LEVEL_ERROR, "Error: The required --config option wasn't specified\n\n"); print_help(); - exit(1); + return CLI_STATUS_ERROR; } + + return CLI_STATUS_OK; } diff --git a/other/bootstrap_daemon/src/command_line_arguments.h b/other/bootstrap_daemon/src/command_line_arguments.h index 2cb8edd9..3595ece3 100644 --- a/other/bootstrap_daemon/src/command_line_arguments.h +++ b/other/bootstrap_daemon/src/command_line_arguments.h @@ -12,6 +12,15 @@ #include "log.h" +typedef enum Cli_Status { + /** Continue the program. Command line processing completed. */ + CLI_STATUS_OK, + /** Stop the program with success status. */ + CLI_STATUS_DONE, + /** Stop the program with error status. */ + CLI_STATUS_ERROR, +} Cli_Status; + /** * Handles command line arguments, setting cfg_file_path and log_backend. * Terminates the application if incorrect arguments are specified. @@ -22,7 +31,8 @@ * @param log_backend Sets to the provided by the user log backend option. * @param run_in_foreground Sets to the provided by the user foreground option. */ -void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend, - bool *run_in_foreground); +Cli_Status handle_command_line_arguments( + int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend, + bool *run_in_foreground); #endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_COMMAND_LINE_ARGUMENTS_H diff --git a/other/bootstrap_daemon/src/tox-bootstrapd.c b/other/bootstrap_daemon/src/tox-bootstrapd.c index 9330e8ce..57eed234 100644 --- a/other/bootstrap_daemon/src/tox-bootstrapd.c +++ b/other/bootstrap_daemon/src/tox-bootstrapd.c @@ -116,7 +116,7 @@ static void print_public_key(const uint8_t *public_key) // Demonizes the process, appending PID to the PID file and closing file descriptors based on log backend // Terminates the application if the daemonization fails. -static void daemonize(LOG_BACKEND log_backend, char *pid_file_path) +static Cli_Status daemonize(LOG_BACKEND log_backend, char *pid_file_path) { // Check if the PID file exists FILE *pid_file = fopen(pid_file_path, "r"); @@ -131,7 +131,7 @@ static void daemonize(LOG_BACKEND log_backend, char *pid_file_path) if (pid_file == nullptr) { log_write(LOG_LEVEL_ERROR, "Couldn't open the PID file for writing: %s. Exiting.\n", pid_file_path); - exit(1); + return CLI_STATUS_ERROR; } // Fork off from the parent process @@ -141,27 +141,27 @@ static void daemonize(LOG_BACKEND log_backend, char *pid_file_path) fprintf(pid_file, "%d", pid); fclose(pid_file); log_write(LOG_LEVEL_INFO, "Forked successfully: PID: %d.\n", pid); - exit(0); + return CLI_STATUS_DONE; } else { fclose(pid_file); } if (pid < 0) { log_write(LOG_LEVEL_ERROR, "Forking failed. Exiting.\n"); - exit(1); + return CLI_STATUS_ERROR; } // Create a new SID for the child process if (setsid() < 0) { log_write(LOG_LEVEL_ERROR, "SID creation failure. Exiting.\n"); - exit(1); + return CLI_STATUS_ERROR; } // Change the current working directory if ((chdir("/")) < 0) { log_write(LOG_LEVEL_ERROR, "Couldn't change working directory to '/'. Exiting.\n"); - exit(1); + return CLI_STATUS_ERROR; } // Go quiet @@ -170,6 +170,8 @@ static void daemonize(LOG_BACKEND log_backend, char *pid_file_path) close(STDIN_FILENO); close(STDERR_FILENO); } + + return CLI_STATUS_OK; } // Logs toxcore logger message using our logger facility @@ -216,7 +218,14 @@ int main(int argc, char *argv[]) LOG_BACKEND log_backend = isatty(STDOUT_FILENO) ? LOG_BACKEND_STDOUT : LOG_BACKEND_SYSLOG; log_open(log_backend); - handle_command_line_arguments(argc, argv, &cfg_file_path, &log_backend, &run_in_foreground); + switch (handle_command_line_arguments(argc, argv, &cfg_file_path, &log_backend, &run_in_foreground)) { + case CLI_STATUS_OK: + break; + case CLI_STATUS_DONE: + return 0; + case CLI_STATUS_ERROR: + return 1; + } log_close(); log_open(log_backend); @@ -254,7 +263,14 @@ int main(int argc, char *argv[]) } if (!run_in_foreground) { - daemonize(log_backend, pid_file_path); + switch (daemonize(log_backend, pid_file_path)) { + case CLI_STATUS_OK: + break; + case CLI_STATUS_DONE: + return 0; + case CLI_STATUS_ERROR: + return 1; + } } free(pid_file_path); diff --git a/other/docker/autotools/Dockerfile b/other/docker/autotools/Dockerfile index e61c83f1..fc85f505 100644 --- a/other/docker/autotools/Dockerfile +++ b/other/docker/autotools/Dockerfile @@ -2,7 +2,8 @@ # autotools-linux FROM ubuntu:22.04 -RUN apt-get update && apt-get install --no-install-recommends -y \ +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ autoconf \ automake \ ca-certificates \ diff --git a/other/docker/clang-tidy/Dockerfile b/other/docker/clang-tidy/Dockerfile new file mode 100644 index 00000000..a7e58fd9 --- /dev/null +++ b/other/docker/clang-tidy/Dockerfile @@ -0,0 +1,20 @@ +FROM alpine:3.19.0 + +RUN ["apk", "add", "--no-cache", \ + "bash", \ + "clang", \ + "clang-extra-tools", \ + "cmake", \ + "libconfig-dev", \ + "libsodium-dev", \ + "libvpx-dev", \ + "linux-headers", \ + "opus-dev", \ + "pkgconfig", \ + "samurai"] + +ENV CC=clang CXX=clang++ + +COPY . /src/workspace/c-toxcore/ +WORKDIR /src/workspace/c-toxcore +RUN other/analysis/run-clang-tidy diff --git a/other/docker/clang-tidy/run b/other/docker/clang-tidy/run new file mode 100755 index 00000000..62036edf --- /dev/null +++ b/other/docker/clang-tidy/run @@ -0,0 +1,5 @@ +#!/bin/sh + +set -eux +BUILD=clang-tidy +docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" . diff --git a/other/docker/misra/Dockerfile b/other/docker/misra/Dockerfile index 3efcdedb..d005b4c9 100644 --- a/other/docker/misra/Dockerfile +++ b/other/docker/misra/Dockerfile @@ -1,6 +1,7 @@ FROM ubuntu:20.04 -RUN apt-get update && apt-get install --no-install-recommends -y \ +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ ca-certificates \ cppcheck \ libopus-dev \ diff --git a/other/docker/tokstyle/Dockerfile b/other/docker/tokstyle/Dockerfile index 446583b6..3bb677b5 100644 --- a/other/docker/tokstyle/Dockerfile +++ b/other/docker/tokstyle/Dockerfile @@ -1,7 +1,8 @@ FROM toxchat/haskell:hs-tokstyle AS tokstyle FROM ubuntu:22.04 -RUN apt-get update && apt-get install --no-install-recommends -y \ +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ ca-certificates \ clang \ git \ diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index bb7a4930..ac19a6df 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -13,7 +13,6 @@ sh_test( args = ["$(locations %s)" % f for f in CIMPLE_FILES] + [ "-Wno-boolean-return", "-Wno-callback-names", - "-Wno-enum-names", "+RTS", "-N4", "-RTS", diff --git a/toxcore/events/friend_status.c b/toxcore/events/friend_status.c index 970b9592..4208df47 100644 --- a/toxcore/events/friend_status.c +++ b/toxcore/events/friend_status.c @@ -7,9 +7,9 @@ #include #include #include -#include "../bin_unpack.h" #include "../bin_pack.h" +#include "../bin_unpack.h" #include "../ccompat.h" #include "../tox.h" #include "../tox_events.h" diff --git a/toxcore/list.c b/toxcore/list.c index e3674873..3f6ad228 100644 --- a/toxcore/list.c +++ b/toxcore/list.c @@ -10,6 +10,7 @@ */ #include "list.h" +#include #include #include #include @@ -206,6 +207,7 @@ bool bs_list_add(BS_List *list, const uint8_t *data, int id) } // insert data to element array + assert(list->data != nullptr); memmove(list->data + (i + 1) * list->element_size, list->data + i * list->element_size, (list->n - i) * list->element_size); memcpy(list->data + i * list->element_size, data, list->element_size);