From 6a90ddfe4e5b2c3d10a8a4b307eb9ffaf0d93c08 Mon Sep 17 00:00:00 2001 From: iphydf Date: Wed, 27 Dec 2023 01:43:03 +0000 Subject: [PATCH] cleanup: Run clang-tidy on headers, as well. --- .clang-tidy | 3 ++- .github/settings.yml | 1 - other/analysis/run-clang-tidy | 2 +- other/docker/clang-tidy/Dockerfile | 4 ++-- toxcore/DHT.h | 2 +- toxcore/events/events_alloc.h | 6 +++--- toxcore/group_announce.h | 6 +++--- toxcore/group_chats.h | 6 +++--- toxcore/group_common.h | 6 +++--- toxcore/group_connection.h | 6 +++--- toxcore/group_pack.h | 6 +++--- toxcore/onion_client.h | 14 +++++++------- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 2f25d8d40..f1aca9f9f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,4 +1,5 @@ # vim:ft=yaml +HeaderFilterRegex: "/c-toxcore/[^/]+/[^.].+" CheckOptions: - key: readability-identifier-naming.ClassCase value: Camel_Snake_Case @@ -35,7 +36,7 @@ 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,limits.h,linux/if.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" + value: "arpa/inet.h,assert.h,ctype.h,errno.h,fcntl.h,getopt.h,libconfig.h,limits.h,linux/if.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,stddef.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 diff --git a/.github/settings.yml b/.github/settings.yml index 2dae52a9c..1d140afe2 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -14,7 +14,6 @@ branches: contexts: - "bazel-dbg" - "bazel-opt" - - "build-alpine-s390x" - "build-android" - "build-autotools" - "build-compcert" diff --git a/other/analysis/run-clang-tidy b/other/analysis/run-clang-tidy index d4bcd5f05..dc07f9465 100755 --- a/other/analysis/run-clang-tidy +++ b/other/analysis/run-clang-tidy @@ -168,7 +168,7 @@ run() { if ! find "${DIRS[@]}" \ -maxdepth 1 -name "*.c" -print0 \ | xargs -0 -n15 -P"$(nproc)" clang-tidy \ - -p=_build \ + -p="$PWD/_build" \ --extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \ "${EXTRA_ARGS[@]}" \ --fix \ diff --git a/other/docker/clang-tidy/Dockerfile b/other/docker/clang-tidy/Dockerfile index a7610a6f9..eaf23f984 100644 --- a/other/docker/clang-tidy/Dockerfile +++ b/other/docker/clang-tidy/Dockerfile @@ -16,6 +16,6 @@ RUN ["apk", "add", "--no-cache", \ ENV CC=clang CXX=clang++ -COPY . /src/workspace/c-toxcore/ -WORKDIR /src/workspace/c-toxcore +COPY . /c-toxcore/ +WORKDIR /c-toxcore RUN other/analysis/run-clang-tidy diff --git a/toxcore/DHT.h b/toxcore/DHT.h index 3e5ab36a1..bc58f8e44 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h @@ -232,7 +232,7 @@ int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length, bool non_null() int dht_create_packet(const Memory *mem, const Random *rng, const uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE], - const uint8_t *shared_key, const uint8_t type, + const uint8_t *shared_key, uint8_t type, const uint8_t *plain, size_t plain_length, uint8_t *packet, size_t length); diff --git a/toxcore/events/events_alloc.h b/toxcore/events/events_alloc.h index 6c5a7abd4..e59bfcea3 100644 --- a/toxcore/events/events_alloc.h +++ b/toxcore/events/events_alloc.h @@ -2,8 +2,8 @@ * Copyright © 2022 The TokTok team. */ -#ifndef C_TOXCORE_TOXCORE_TOX_EVENTS_INTERNAL_H -#define C_TOXCORE_TOXCORE_TOX_EVENTS_INTERNAL_H +#ifndef C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H +#define C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H #include "../attributes.h" #include "../bin_pack.h" @@ -213,4 +213,4 @@ Tox_Events_State *tox_events_alloc(void *user_data); } #endif -#endif // C_TOXCORE_TOXCORE_TOX_EVENTS_INTERNAL_H +#endif // C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H diff --git a/toxcore/group_announce.h b/toxcore/group_announce.h index 801363d6b..19ca2985c 100644 --- a/toxcore/group_announce.h +++ b/toxcore/group_announce.h @@ -6,8 +6,8 @@ /** * Similar to ping.h, but designed for group chat purposes */ -#ifndef GROUP_ANNOUNCE_H -#define GROUP_ANNOUNCE_H +#ifndef C_TOXCORE_TOXCORE_GROUP_ANNOUNCE_H +#define C_TOXCORE_TOXCORE_GROUP_ANNOUNCE_H #include @@ -215,4 +215,4 @@ bool gca_is_valid_announce(const GC_Announce *announce); } // extern "C" #endif -#endif // GROUP_ANNOUNCE_H +#endif // C_TOXCORE_TOXCORE_GROUP_ANNOUNCE_H diff --git a/toxcore/group_chats.h b/toxcore/group_chats.h index 920e1a675..55fc199b2 100644 --- a/toxcore/group_chats.h +++ b/toxcore/group_chats.h @@ -7,8 +7,8 @@ * An implementation of massive text only group chats. */ -#ifndef GROUP_CHATS_H -#define GROUP_CHATS_H +#ifndef C_TOXCORE_TOXCORE_GROUP_CHATS_H +#define C_TOXCORE_TOXCORE_GROUP_CHATS_H #include #include @@ -805,4 +805,4 @@ GC_Chat *gc_get_group_by_public_key(const GC_Session *c, const uint8_t *public_k non_null() int gc_add_peers_from_announces(GC_Chat *chat, const GC_Announce *announces, uint8_t gc_announces_count); -#endif // GROUP_CHATS_H +#endif // C_TOXCORE_TOXCORE_GROUP_CHATS_H diff --git a/toxcore/group_common.h b/toxcore/group_common.h index 7daec3030..49c213692 100644 --- a/toxcore/group_common.h +++ b/toxcore/group_common.h @@ -6,8 +6,8 @@ * Common groupchat data structures. */ -#ifndef GROUP_COMMON_H -#define GROUP_COMMON_H +#ifndef C_TOXCORE_TOXCORE_GROUP_COMMON_H +#define C_TOXCORE_TOXCORE_GROUP_COMMON_H #include #include @@ -410,4 +410,4 @@ int unpack_gc_saved_peers(GC_Chat *chat, const uint8_t *data, uint16_t length); non_null(1, 2) nullable(4) int pack_gc_saved_peers(const GC_Chat *chat, uint8_t *data, uint16_t length, uint16_t *processed); -#endif // GROUP_COMMON_H +#endif // C_TOXCORE_TOXCORE_GROUP_COMMON_H diff --git a/toxcore/group_connection.h b/toxcore/group_connection.h index 2202c7ab3..5987f010b 100644 --- a/toxcore/group_connection.h +++ b/toxcore/group_connection.h @@ -7,8 +7,8 @@ * An implementation of massive text only group chats. */ -#ifndef GROUP_CONNECTION_H -#define GROUP_CONNECTION_H +#ifndef C_TOXCORE_TOXCORE_GROUP_CONNECTION_H +#define C_TOXCORE_TOXCORE_GROUP_CONNECTION_H #include "group_common.h" @@ -186,4 +186,4 @@ void gcc_peer_cleanup(GC_Connection *gconn); non_null() void gcc_cleanup(const GC_Chat *chat); -#endif // GROUP_CONNECTION_H +#endif // C_TOXCORE_TOXCORE_GROUP_CONNECTION_H diff --git a/toxcore/group_pack.h b/toxcore/group_pack.h index deea3fabe..70b0df8d0 100644 --- a/toxcore/group_pack.h +++ b/toxcore/group_pack.h @@ -7,8 +7,8 @@ * Packer and unpacker functions for saving and loading groups. */ -#ifndef GROUP_PACK_H -#define GROUP_PACK_H +#ifndef C_TOXCORE_TOXCORE_GROUP_PACK_H +#define C_TOXCORE_TOXCORE_GROUP_PACK_H #include @@ -37,4 +37,4 @@ bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out); non_null() bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out); -#endif // GROUP_PACK_H +#endif // C_TOXCORE_TOXCORE_GROUP_PACK_H diff --git a/toxcore/onion_client.h b/toxcore/onion_client.h index d8a2e8752..0b8fbffbd 100644 --- a/toxcore/onion_client.h +++ b/toxcore/onion_client.h @@ -228,13 +228,13 @@ Onion_Connection_Status onion_connection_status(const Onion_Client *onion_c); typedef struct Onion_Friend Onion_Friend; -non_null() uint16_t onion_get_friend_count(const Onion_Client *const onion_c); -non_null() Onion_Friend *onion_get_friend(const Onion_Client *const onion_c, uint16_t friend_num); -non_null() const uint8_t *onion_friend_get_gc_public_key(const Onion_Friend *const onion_friend); -non_null() const uint8_t *onion_friend_get_gc_public_key_num(const Onion_Client *const onion_c, uint32_t num); -non_null() void onion_friend_set_gc_public_key(Onion_Friend *const onion_friend, const uint8_t *public_key); +non_null() uint16_t onion_get_friend_count(const Onion_Client *onion_c); +non_null() Onion_Friend *onion_get_friend(const Onion_Client *onion_c, uint16_t friend_num); +non_null() const uint8_t *onion_friend_get_gc_public_key(const Onion_Friend *onion_friend); +non_null() const uint8_t *onion_friend_get_gc_public_key_num(const Onion_Client *onion_c, uint32_t num); +non_null() void onion_friend_set_gc_public_key(Onion_Friend *onion_friend, const uint8_t *public_key); non_null(1) nullable(2) -void onion_friend_set_gc_data(Onion_Friend *const onion_friend, const uint8_t *gc_data, uint16_t gc_data_length); -non_null() bool onion_friend_is_groupchat(const Onion_Friend *const onion_friend); +void onion_friend_set_gc_data(Onion_Friend *onion_friend, const uint8_t *gc_data, uint16_t gc_data_length); +non_null() bool onion_friend_is_groupchat(const Onion_Friend *onion_friend); #endif