From 33bfaf7ecdc0ade78e81ffeb5a14fa8082579f58 Mon Sep 17 00:00:00 2001 From: Michael Thorpe Date: Wed, 7 Nov 2018 15:30:22 +0000 Subject: [PATCH] Enable -Wextra test criteria: - test build on macOS - test build in debian docker container - test build in fedora docker container --- .vscode/launch.json | 27 +- .vscode/settings.json | 3 +- CMakeLists.txt | 2 +- client/main.cpp | 2 +- crypto/libntrup/src/avx/mult.c | 4 +- include/llarp/buffer.h | 2 +- include/llarp/codel.hpp | 2 +- include/llarp/link/server.hpp | 2 +- include/llarp/messages/discard.hpp | 5 +- include/llarp/path.hpp | 3 +- include/llarp/pathset.hpp | 27 +- include/llarp/router_contact.hpp | 4 +- include/llarp/service/Info.hpp | 3 +- include/llarp/service/Intro.hpp | 2 +- include/llarp/service/IntroSet.hpp | 4 +- include/llarp/service/endpoint.hpp | 22 +- include/llarp/service/lookup.hpp | 3 +- include/llarp/threading.hpp | 2 +- libabyss/main.cpp | 12 +- libabyss/src/client.cpp | 4 +- libutp/utp_hash.h | 175 ++++++---- libutp/utp_internal.cpp | 1 + libutp/utp_utils.cpp | 308 ++++++++++-------- llarp/context.cpp | 9 +- llarp/dht/context.cpp | 16 +- llarp/dht/got_intro.cpp | 2 + llarp/dht/got_router.cpp | 1 + llarp/dns_dotlokilookup.cpp | 3 +- llarp/dns_iptracker.cpp | 1 + llarp/dnsc.cpp | 11 +- llarp/dnsd.cpp | 4 +- llarp/ev.hpp | 4 +- llarp/ev_epoll.hpp | 4 +- llarp/ev_kqueue.hpp | 12 +- llarp/exit_info.cpp | 3 +- llarp/handlers/tun.cpp | 2 +- llarp/ip.cpp | 21 +- llarp/link/curvecp.cpp | 2 +- llarp/link/utp.cpp | 2 +- llarp/mem.cpp | 4 +- llarp/net.cpp | 3 +- llarp/path.cpp | 13 +- llarp/proofofwork.cpp | 5 +- llarp/router.cpp | 5 +- llarp/rpc.cpp | 16 +- llarp/service/context.cpp | 5 +- llarp/service/endpoint.cpp | 19 +- llarp/service/protocol.cpp | 2 +- llarp/threadpool.cpp | 7 +- llarp/transit_hop.cpp | 8 +- test/jsonrpc_unittest.cpp | 10 +- test/test_dns_unit.cpp | 84 ++--- test/test_dnsd_unit.cpp | 67 ++-- .../lib/fs/create_directory.cpp | 5 +- vendor/cppbackport-master/lib/fs/diriter.cpp | 8 +- .../cppbackport-master/lib/fs/filestatus.cpp | 2 +- vendor/libtuntap-master/tuntap-unix-darwin.c | 7 +- vendor/libtuntap-master/tuntap-unix.c | 1 + vendor/libtuntap-master/tuntap.cpp | 1 + 59 files changed, 587 insertions(+), 401 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 43a9f6710..8380cc172 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -3,7 +3,18 @@ // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", - "configurations": [ + "configurations": [{ + "name": "(lldb) Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/lokinet", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "lldb" + }, { "name": "(gdb) Launch", "type": "cppdbg", @@ -15,13 +26,11 @@ "environment": [], "externalConsole": true, "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ] + "setupCommands": [{ + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }] } ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index bb21fe89d..de98d6665 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -68,6 +68,7 @@ "complex": "cpp", "variant": "cpp", "any": "cpp", - "tuntap.h": "c" + "tuntap.h": "c", + "hashtable": "cpp" } } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ebce6aed..ee9c2c757 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) # turns off those annoying warnings for # target-specific crypto code paths not # applicable to the host's FPU -rick -add_compile_options(-Wall -Werror -Wno-unknown-pragmas) +add_compile_options(-Wall -Wextra -Werror -Wno-unknown-pragmas) add_compile_options($<$:-fpermissive>) add_compile_options(-Wno-unused-function -Wno-deprecated-declarations -Wno-unknown-pragmas) diff --git a/client/main.cpp b/client/main.cpp index 33fe49995..f1879ae64 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -1,6 +1,6 @@ int -main(int argc, char* argv[]) +main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { return 0; } diff --git a/crypto/libntrup/src/avx/mult.c b/crypto/libntrup/src/avx/mult.c index ce6313128..237bb240b 100644 --- a/crypto/libntrup/src/avx/mult.c +++ b/crypto/libntrup/src/avx/mult.c @@ -400,7 +400,7 @@ mult96x16(__m256i h[192], const __m256i f[96], const __m256i g[96]) static void transpose16(__m256i x[16]) { - const static int rev[4] = {0, 4, 2, 6}; + static const int rev[4] = {0, 4, 2, 6}; int i; __m256i y[16]; @@ -449,7 +449,7 @@ transpose16(__m256i x[16]) static void transpose32(__m256i x[32]) { - const static int rev[4] = {0, 8, 4, 12}; + static const int rev[4] = {0, 8, 4, 12}; int i; __m256i y[32]; diff --git a/include/llarp/buffer.h b/include/llarp/buffer.h index 52bb5d549..0bd6211b4 100644 --- a/include/llarp/buffer.h +++ b/include/llarp/buffer.h @@ -62,7 +62,7 @@ typedef struct llarp_buffer_t size_t sz; #ifdef __cplusplus - const byte_t operator[](size_t x) + byte_t operator[](size_t x) { return *(this->base + x); } diff --git a/include/llarp/codel.hpp b/include/llarp/codel.hpp index 3c1c6231c..80de73fb1 100644 --- a/include/llarp/codel.hpp +++ b/include/llarp/codel.hpp @@ -22,7 +22,7 @@ namespace llarp struct DummyLock { - DummyLock(const DummyMutex& mtx){}; + DummyLock(__attribute__((unused)) const DummyMutex& mtx){}; ~DummyLock() { diff --git a/include/llarp/link/server.hpp b/include/llarp/link/server.hpp index 01cf2c8dc..5d622c98d 100644 --- a/include/llarp/link/server.hpp +++ b/include/llarp/link/server.hpp @@ -111,7 +111,7 @@ namespace llarp MapAddr(const PubKey& pk, ILinkSession* s); virtual void - Tick(llarp_time_t now) + Tick(__attribute__((unused)) llarp_time_t now) { } diff --git a/include/llarp/messages/discard.hpp b/include/llarp/messages/discard.hpp index 72851f9f8..74778f1b8 100644 --- a/include/llarp/messages/discard.hpp +++ b/include/llarp/messages/discard.hpp @@ -36,13 +36,14 @@ namespace llarp } bool - DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override + DecodeKey(__attribute__((unused)) llarp_buffer_t key, + __attribute__((unused)) llarp_buffer_t* buf) override { return false; } bool - HandleMessage(llarp_router* router) const override + HandleMessage(__attribute__((unused)) llarp_router* router) const override { return true; } diff --git a/include/llarp/path.hpp b/include/llarp/path.hpp index f1785391a..02c822968 100644 --- a/include/llarp/path.hpp +++ b/include/llarp/path.hpp @@ -181,7 +181,8 @@ namespace llarp llarp_router* r); bool - HandleHiddenServiceFrame(const llarp::service::ProtocolFrame* frame) + HandleHiddenServiceFrame(__attribute__((unused)) + const llarp::service::ProtocolFrame* frame) { /// TODO: implement me llarp::LogWarn("Got hidden service data on transit hop"); diff --git a/include/llarp/pathset.hpp b/include/llarp/pathset.hpp index 1a8d0fc6a..9455e8bf9 100644 --- a/include/llarp/pathset.hpp +++ b/include/llarp/pathset.hpp @@ -46,10 +46,10 @@ namespace llarp RemovePath(Path* path); virtual void - HandlePathBuilt(Path* path); + HandlePathBuilt(__attribute__((unused)) Path* path); virtual void - HandlePathBuildTimeout(Path* path); + HandlePathBuildTimeout(__attribute__((unused)) Path* path); bool GetNewestIntro(service::Introduction& intro) const; @@ -76,22 +76,23 @@ namespace llarp /// return true if we should publish a new hidden service descriptor virtual bool - ShouldPublishDescriptors(llarp_time_t now) const - { - (void)now; - return false; - } - - /// override me in subtype - virtual bool - HandleGotIntroMessage(const llarp::dht::GotIntroMessage* msg) + ShouldPublishDescriptors(__attribute__((unused)) llarp_time_t now) const { return false; } /// override me in subtype virtual bool - HandleGotRouterMessage(const llarp::dht::GotRouterMessage* msg) + HandleGotIntroMessage(__attribute__((unused)) + const llarp::dht::GotIntroMessage* msg) + { + return false; + } + + /// override me in subtype + virtual bool + HandleGotRouterMessage(__attribute__((unused)) + const llarp::dht::GotRouterMessage* msg) { return false; } @@ -128,7 +129,7 @@ namespace llarp std::set< llarp::service::Introduction >& intros) const; virtual bool - PublishIntroSet(llarp_router* r) + PublishIntroSet(__attribute__((unused)) llarp_router* r) { return false; } diff --git a/include/llarp/router_contact.hpp b/include/llarp/router_contact.hpp index 149cd6442..8f3e69528 100644 --- a/include/llarp/router_contact.hpp +++ b/include/llarp/router_contact.hpp @@ -20,14 +20,14 @@ namespace llarp } RouterContact(const RouterContact &other) - : addrs(other.addrs) + : IBEncodeMessage() + , addrs(other.addrs) , enckey(other.enckey) , pubkey(other.pubkey) , exits(other.exits) , signature(other.signature) , nickname(other.nickname) , last_updated(other.last_updated) - { version = other.version; } diff --git a/include/llarp/service/Info.hpp b/include/llarp/service/Info.hpp index a95328a12..556fba7f2 100644 --- a/include/llarp/service/Info.hpp +++ b/include/llarp/service/Info.hpp @@ -30,7 +30,8 @@ namespace llarp */ ServiceInfo(const ServiceInfo& other) - : enckey(other.enckey) + : IBEncodeMessage(other.version) + , enckey(other.enckey) , signkey(other.signkey) , vanity(other.vanity) , m_CachedAddr(other.m_CachedAddr) diff --git a/include/llarp/service/Intro.hpp b/include/llarp/service/Intro.hpp index 9158c8940..178c4dcee 100644 --- a/include/llarp/service/Intro.hpp +++ b/include/llarp/service/Intro.hpp @@ -19,7 +19,7 @@ namespace llarp uint64_t expiresAt = 0; Introduction() = default; - Introduction(const Introduction& other) + Introduction(const Introduction& other) : IBEncodeMessage(other.version) { router = other.router; pathID = other.pathID; diff --git a/include/llarp/service/IntroSet.hpp b/include/llarp/service/IntroSet.hpp index 7e20dc831..66afedaba 100644 --- a/include/llarp/service/IntroSet.hpp +++ b/include/llarp/service/IntroSet.hpp @@ -31,7 +31,7 @@ namespace llarp IntroSet() = default; - IntroSet(IntroSet&& other) + IntroSet(IntroSet&& other) : IBEncodeMessage(other.version) { A = std::move(other.A); I = std::move(other.I); @@ -43,7 +43,7 @@ namespace llarp Z = std::move(other.Z); } - IntroSet(const IntroSet& other) + IntroSet(const IntroSet& other) : IBEncodeMessage(other.version) { A = other.A; I = other.I; diff --git a/include/llarp/service/endpoint.hpp b/include/llarp/service/endpoint.hpp index 239ee28b6..6c472a05d 100644 --- a/include/llarp/service/endpoint.hpp +++ b/include/llarp/service/endpoint.hpp @@ -108,16 +108,18 @@ namespace llarp HasPathToService(const Address& remote) const; virtual huint32_t - ObtainIPForAddr(const llarp::service::Address& remote) + ObtainIPForAddr(__attribute__((unused)) + const llarp::service::Address& remote) { return {0}; } virtual bool - HasAddress(const Address& remote) const + HasAddress(__attribute__((unused)) const Address& remote) const { return false; } + /// return true if we have a pending job to build to a hidden service but /// it's not done yet bool @@ -132,7 +134,7 @@ namespace llarp HandleDataMessage(const PathID_t&, ProtocolMessage* msg); virtual bool - ProcessDataMessage(ProtocolMessage* msg) + ProcessDataMessage(__attribute__((unused)) ProtocolMessage* msg) { return true; } @@ -217,22 +219,17 @@ namespace llarp }; virtual void - UpdateIntroSet(bool randomizePath = false){}; + UpdateIntroSet(bool randomizePath = false) = 0; virtual bool - MarkCurrentIntroBad(llarp_time_t now) - { - return true; - }; + MarkCurrentIntroBad(llarp_time_t now) = 0; private: void EncryptAndSendTo(llarp_buffer_t payload, ProtocolType t); virtual void - AsyncGenIntro(llarp_buffer_t payload, ProtocolType t) - { - } + AsyncGenIntro(llarp_buffer_t payload, ProtocolType t) = 0; }; static void @@ -332,7 +329,8 @@ namespace llarp uint64_t timeoutMS, bool lookupOnRandomPath = false); virtual bool - HandleAuthenticatedDataFrom(const Address& remote, llarp_buffer_t data) + HandleAuthenticatedDataFrom(__attribute__((unused)) const Address& remote, + __attribute__((unused)) llarp_buffer_t data) { /// TODO: imlement me return true; diff --git a/include/llarp/service/lookup.hpp b/include/llarp/service/lookup.hpp index 3802854f8..87f32f5ab 100644 --- a/include/llarp/service/lookup.hpp +++ b/include/llarp/service/lookup.hpp @@ -25,7 +25,8 @@ namespace llarp /// handle lookup result virtual bool - HandleResponse(const std::set< IntroSet >& results) + HandleResponse(__attribute__((unused)) + const std::set< IntroSet >& results) { return false; } diff --git a/include/llarp/threading.hpp b/include/llarp/threading.hpp index e31e5a746..a20aeaf5a 100644 --- a/include/llarp/threading.hpp +++ b/include/llarp/threading.hpp @@ -25,7 +25,7 @@ namespace llarp /// a lock that does nothing struct NullLock { - NullLock(NullMutex& mtx) + NullLock(__attribute__((unused)) NullMutex& mtx) { } }; diff --git a/libabyss/main.cpp b/libabyss/main.cpp index a75980e05..7e936f16f 100644 --- a/libabyss/main.cpp +++ b/libabyss/main.cpp @@ -11,7 +11,8 @@ struct DemoHandler : public abyss::httpd::IRPCHandler } bool - HandleJSONRPC(Method_t method, const Params& params, Response& resp) + HandleJSONRPC(Method_t method, __attribute__((unused)) const Params& params, + Response& resp) override { llarp::LogInfo("method: ", method); resp.AddMember("result", abyss::json::Value().SetInt(1), @@ -28,7 +29,7 @@ struct DemoCall : public abyss::http::IRPCClientHandler } bool - HandleResponse(const abyss::http::RPC_Response& resp) + HandleResponse(const abyss::http::RPC_Response& resp) override { std::string body; abyss::json::ToString(resp, body); @@ -37,12 +38,13 @@ struct DemoCall : public abyss::http::IRPCClientHandler } void - PopulateReqHeaders(abyss::http::Headers_t& hdr) + PopulateReqHeaders(__attribute__((unused)) + abyss::http::Headers_t& hdr) override { } void - HandleError() + HandleError() override { llarp::LogError("error while handling call: ", strerror(errno)); } @@ -81,7 +83,7 @@ struct DemoServer : public abyss::httpd::BaseReqHandler }; int -main(int argc, char* argv[]) +main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { // Ignore on Windows, we don't even get SIGPIPE (even though native *and* // emulated UNIX pipes exist - CreatePipe(2), pipe(3)) diff --git a/libabyss/src/client.cpp b/libabyss/src/client.cpp index 5d4aab1aa..dfa1aabca 100644 --- a/libabyss/src/client.cpp +++ b/libabyss/src/client.cpp @@ -67,7 +67,7 @@ namespace abyss } static void - OnTick(llarp_tcp_conn* conn) + OnTick(__attribute__((unused)) llarp_tcp_conn* conn) { } @@ -396,4 +396,4 @@ namespace abyss } } // namespace http -} // namespace abyss \ No newline at end of file +} // namespace abyss diff --git a/libutp/utp_hash.h b/libutp/utp_hash.h index 72c17e3bd..17e51f31a 100644 --- a/libutp/utp_hash.h +++ b/libutp/utp_hash.h @@ -23,8 +23,8 @@ #ifndef __UTP_HASH_H__ #define __UTP_HASH_H__ -#include // memset -#include // malloc +#include // memset +#include // malloc #include "utp_types.h" #include "utp_templates.h" @@ -33,12 +33,14 @@ typedef uint32 utp_link_t; #ifdef _MSC_VER -// Silence the warning about the C99-compliant zero-length array at the end of the structure -#pragma warning (disable: 4200) +// Silence the warning about the C99-compliant zero-length array at the end of +// the structure +#pragma warning(disable : 4200) #endif typedef uint32 (*utp_hash_compute_t)(const void *keyp, size_t keysize); -typedef uint (*utp_hash_equal_t)(const void *key_a, const void *key_b, size_t keysize); +typedef uint (*utp_hash_equal_t)(const void *key_a, const void *key_b, + size_t keysize); // In memory the HashTable is laid out as follows: // ---------------------------- low @@ -74,73 +76,132 @@ typedef uint (*utp_hash_equal_t)(const void *key_a, const void *key_b, size_t ke // // N is the number of buckets. // -struct utp_hash_t { - utp_link_t N; - byte K; - byte E; - size_t count; - utp_hash_compute_t hash_compute; - utp_hash_equal_t hash_equal; - utp_link_t allocated; - utp_link_t used; - utp_link_t free; - utp_link_t inits[0]; +struct utp_hash_t +{ + utp_link_t N; + byte K; + byte E; + size_t count; + utp_hash_compute_t hash_compute; + utp_hash_equal_t hash_equal; + utp_link_t allocated; + utp_link_t used; + utp_link_t free; + utp_link_t inits[0]; }; #ifdef _MSC_VER -#pragma warning (default: 4200) +#pragma warning(default : 4200) #endif -struct utp_hash_iterator_t { - utp_link_t bucket; - utp_link_t elem; +struct utp_hash_iterator_t +{ + utp_link_t bucket; + utp_link_t elem; - utp_hash_iterator_t() : bucket(0xffffffff), elem(0xffffffff) {} + utp_hash_iterator_t() : bucket(0xffffffff), elem(0xffffffff) + { + } }; -uint utp_hash_mem(const void *keyp, size_t keysize); -uint utp_hash_comp(const void *key_a, const void *key_b, size_t keysize); +uint +utp_hash_mem(const void *keyp, size_t keysize); +uint +utp_hash_comp(const void *key_a, const void *key_b, size_t keysize); -utp_hash_t *utp_hash_create(int N, int key_size, int total_size, int initial, utp_hash_compute_t hashfun = utp_hash_mem, utp_hash_equal_t eqfun = NULL); -void *utp_hash_lookup(utp_hash_t *hash, const void *key); -void *utp_hash_add(utp_hash_t **hashp, const void *key); -void *utp_hash_del(utp_hash_t *hash, const void *key); +utp_hash_t * +utp_hash_create(int N, int key_size, int total_size, int initial, + utp_hash_compute_t hashfun = utp_hash_mem, + utp_hash_equal_t eqfun = NULL); +void * +utp_hash_lookup(utp_hash_t *hash, const void *key); +void * +utp_hash_add(utp_hash_t **hashp, const void *key); +void * +utp_hash_del(utp_hash_t *hash, const void *key); -void *utp_hash_iterate(utp_hash_t *hash, utp_hash_iterator_t *iter); -void utp_hash_free_mem(utp_hash_t *hash); +void * +utp_hash_iterate(utp_hash_t *hash, utp_hash_iterator_t *iter); +void +utp_hash_free_mem(utp_hash_t *hash); /* - This HashTable requires that T have at least sizeof(K)+sizeof(utp_link_t) bytes. - Usually done like this: + This HashTable requires that T have at least + sizeof(K)+sizeof(utp_link_t) bytes. Usually done like this: - struct K { - int whatever; - }; + struct K { + int whatever; + }; - struct T { - K wtf; - utp_link_t link; // also wtf - }; + struct T { + K wtf; + utp_link_t link; // also wtf + }; */ -template class utpHashTable { - utp_hash_t *hash; -public: - static uint compare(const void *k1, const void *k2, size_t ks) { - return *((K*)k1) == *((K*)k2); - } - static uint32 compute_hash(const void *k, size_t ks) { - return ((K*)k)->compute_hash(); - } - void Init() { hash = NULL; } - bool Allocated() { return (hash != NULL); } - void Free() { utp_hash_free_mem(hash); hash = NULL; } - void Create(int N, int initial) { hash = utp_hash_create(N, sizeof(K), sizeof(T), initial, &compute_hash, &compare); } - T *Lookup(const K &key) { return (T*)utp_hash_lookup(hash, &key); } - T *Add(const K &key) { return (T*)utp_hash_add(&hash, &key); } - T *Delete(const K &key) { return (T*)utp_hash_del(hash, &key); } - T *Iterate(utp_hash_iterator_t &iterator) { return (T*)utp_hash_iterate(hash, &iterator); } - size_t GetCount() { return hash->count; } +template < typename K, typename T > +class utpHashTable +{ + utp_hash_t *hash; + + public: + static uint + compare(const void *k1, const void *k2, __attribute__((unused)) size_t ks) + { + return *((K *)k1) == *((K *)k2); + } + static uint32 + compute_hash(const void *k, __attribute__((unused)) size_t ks) + { + return ((K *)k)->compute_hash(); + } + void + Init() + { + hash = NULL; + } + bool + Allocated() + { + return (hash != NULL); + } + void + Free() + { + utp_hash_free_mem(hash); + hash = NULL; + } + void + Create(int N, int initial) + { + hash = utp_hash_create(N, sizeof(K), sizeof(T), initial, &compute_hash, + &compare); + } + T * + Lookup(const K &key) + { + return (T *)utp_hash_lookup(hash, &key); + } + T * + Add(const K &key) + { + return (T *)utp_hash_add(&hash, &key); + } + T * + Delete(const K &key) + { + return (T *)utp_hash_del(hash, &key); + } + T * + Iterate(utp_hash_iterator_t &iterator) + { + return (T *)utp_hash_iterate(hash, &iterator); + } + size_t + GetCount() + { + return hash->count; + } }; -#endif //__UTP_HASH_H__ +#endif //__UTP_HASH_H__ diff --git a/libutp/utp_internal.cpp b/libutp/utp_internal.cpp index 05a9c9d44..757070ba8 100644 --- a/libutp/utp_internal.cpp +++ b/libutp/utp_internal.cpp @@ -3487,6 +3487,7 @@ utp_socket_stats* utp_get_stats(utp_socket *socket) socket->_stats.mtu_guess = socket->mtu_last ? socket->mtu_last : socket->mtu_ceiling; return &socket->_stats; #else + (void)socket; return NULL; #endif } diff --git a/libutp/utp_utils.cpp b/libutp/utp_utils.cpp index 9cc5082f7..fd81f528c 100644 --- a/libutp/utp_utils.cpp +++ b/libutp/utp_utils.cpp @@ -27,25 +27,25 @@ #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN #endif - #include - #include - #include -#else //!WIN32 - #include - #include // Linux needs both time.h and sys/time.h +#include +#include +#include +#else //! WIN32 +#include +#include // Linux needs both time.h and sys/time.h #endif #if defined(__APPLE__) - #include +#include #endif #include "utp_utils.h" #ifdef WIN32 -typedef ULONGLONG (WINAPI GetTickCount64Proc)(void); +typedef ULONGLONG(WINAPI GetTickCount64Proc)(void); static GetTickCount64Proc *pt2GetTickCount64; static GetTickCount64Proc *pt2RealGetTickCount; @@ -54,160 +54,189 @@ static uint64 startGetTickCount; // MSVC 6 standard doesn't like division with uint64s static double counterPerMicrosecond; -static uint64 UTGetTickCount64() +static uint64 +UTGetTickCount64() { - if (pt2GetTickCount64) { - return pt2GetTickCount64(); - } - if (pt2RealGetTickCount) { - uint64 v = pt2RealGetTickCount(); - // fix return value from GetTickCount - return (DWORD)v | ((v >> 0x18) & 0xFFFFFFFF00000000); - } - return (uint64)GetTickCount(); + if(pt2GetTickCount64) + { + return pt2GetTickCount64(); + } + if(pt2RealGetTickCount) + { + uint64 v = pt2RealGetTickCount(); + // fix return value from GetTickCount + return (DWORD)v | ((v >> 0x18) & 0xFFFFFFFF00000000); + } + return (uint64)GetTickCount(); } -static void Time_Initialize() +static void +Time_Initialize() { - HMODULE kernel32 = GetModuleHandleA("kernel32.dll"); - pt2GetTickCount64 = (GetTickCount64Proc*)GetProcAddress(kernel32, "GetTickCount64"); - // not a typo. GetTickCount actually returns 64 bits - pt2RealGetTickCount = (GetTickCount64Proc*)GetProcAddress(kernel32, "GetTickCount"); + HMODULE kernel32 = GetModuleHandleA("kernel32.dll"); + pt2GetTickCount64 = + (GetTickCount64Proc *)GetProcAddress(kernel32, "GetTickCount64"); + // not a typo. GetTickCount actually returns 64 bits + pt2RealGetTickCount = + (GetTickCount64Proc *)GetProcAddress(kernel32, "GetTickCount"); - uint64 frequency; - QueryPerformanceCounter((LARGE_INTEGER*)&startPerformanceCounter); - QueryPerformanceFrequency((LARGE_INTEGER*)&frequency); - counterPerMicrosecond = (double)frequency / 1000000.0f; - startGetTickCount = UTGetTickCount64(); + uint64 frequency; + QueryPerformanceCounter((LARGE_INTEGER *)&startPerformanceCounter); + QueryPerformanceFrequency((LARGE_INTEGER *)&frequency); + counterPerMicrosecond = (double)frequency / 1000000.0f; + startGetTickCount = UTGetTickCount64(); } -static int64 abs64(int64 x) { return x < 0 ? -x : x; } - -static uint64 __GetMicroseconds() +static int64 +abs64(int64 x) { - static bool time_init = false; - if (!time_init) { - time_init = true; - Time_Initialize(); - } - - uint64 counter; - uint64 tick; - - QueryPerformanceCounter((LARGE_INTEGER*) &counter); - tick = UTGetTickCount64(); - - // unfortunately, QueryPerformanceCounter is not guaranteed - // to be monotonic. Make it so. - int64 ret = (int64)(((int64)counter - (int64)startPerformanceCounter) / counterPerMicrosecond); - // if the QPC clock leaps more than one second off GetTickCount64() - // something is seriously fishy. Adjust QPC to stay monotonic - int64 tick_diff = tick - startGetTickCount; - if (abs64(ret / 100000 - tick_diff / 100) > 10) { - startPerformanceCounter -= (uint64)((int64)(tick_diff * 1000 - ret) * counterPerMicrosecond); - ret = (int64)((counter - startPerformanceCounter) / counterPerMicrosecond); - } - return ret; + return x < 0 ? -x : x; } -static inline uint64 UTP_GetMilliseconds() +static uint64 +__GetMicroseconds() { - return GetTickCount(); + static bool time_init = false; + if(!time_init) + { + time_init = true; + Time_Initialize(); + } + + uint64 counter; + uint64 tick; + + QueryPerformanceCounter((LARGE_INTEGER *)&counter); + tick = UTGetTickCount64(); + + // unfortunately, QueryPerformanceCounter is not guaranteed + // to be monotonic. Make it so. + int64 ret = (int64)(((int64)counter - (int64)startPerformanceCounter) + / counterPerMicrosecond); + // if the QPC clock leaps more than one second off GetTickCount64() + // something is seriously fishy. Adjust QPC to stay monotonic + int64 tick_diff = tick - startGetTickCount; + if(abs64(ret / 100000 - tick_diff / 100) > 10) + { + startPerformanceCounter -= + (uint64)((int64)(tick_diff * 1000 - ret) * counterPerMicrosecond); + ret = (int64)((counter - startPerformanceCounter) / counterPerMicrosecond); + } + return ret; } -#else //!WIN32 - -static inline uint64 UTP_GetMicroseconds(void); -static inline uint64 UTP_GetMilliseconds() +static inline uint64 +UTP_GetMilliseconds() { - return UTP_GetMicroseconds() / 1000; + return GetTickCount(); +} + +#else //! WIN32 + +static inline uint64 +UTP_GetMicroseconds(void); +static inline uint64 +UTP_GetMilliseconds() +{ + return UTP_GetMicroseconds() / 1000; } #if defined(__APPLE__) -static uint64 __GetMicroseconds() +static uint64 +__GetMicroseconds() { - // http://developer.apple.com/mac/library/qa/qa2004/qa1398.html - // http://www.macresearch.org/tutorial_performance_and_time - static mach_timebase_info_data_t sTimebaseInfo; - static uint64_t start_tick = 0; - uint64_t tick; - // Returns a counter in some fraction of a nanoseconds - tick = mach_absolute_time(); - if (sTimebaseInfo.denom == 0) { - // Get the timer ratio to convert mach_absolute_time to nanoseconds - mach_timebase_info(&sTimebaseInfo); - start_tick = tick; - } - // Calculate the elapsed time, convert it to microseconds and return it. - return ((tick - start_tick) * sTimebaseInfo.numer) / (sTimebaseInfo.denom * 1000); + // http://developer.apple.com/mac/library/qa/qa2004/qa1398.html + // http://www.macresearch.org/tutorial_performance_and_time + static mach_timebase_info_data_t sTimebaseInfo; + static uint64_t start_tick = 0; + uint64_t tick; + // Returns a counter in some fraction of a nanoseconds + tick = mach_absolute_time(); + if(sTimebaseInfo.denom == 0) + { + // Get the timer ratio to convert mach_absolute_time to nanoseconds + mach_timebase_info(&sTimebaseInfo); + start_tick = tick; + } + // Calculate the elapsed time, convert it to microseconds and return it. + return ((tick - start_tick) * sTimebaseInfo.numer) + / (sTimebaseInfo.denom * 1000); } -#else // !__APPLE__ +#else // !__APPLE__ -#if ! (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC)) - #warning "Using non-monotonic function gettimeofday() in UTP_GetMicroseconds()" +#if !(defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC)) +#warning "Using non-monotonic function gettimeofday() in UTP_GetMicroseconds()" #endif /* Unfortunately, #ifdef CLOCK_MONOTONIC is not enough to make sure that POSIX clocks work -- we could be running a recent libc with an ancient kernel (think OpenWRT). -- jch */ -static uint64_t __GetMicroseconds() +static uint64_t +__GetMicroseconds() { - struct timeval tv; + struct timeval tv; - #if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC) - static int have_posix_clocks = -1; - int rc; +#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC) + static int have_posix_clocks = -1; + int rc; - if (have_posix_clocks < 0) { - struct timespec ts; - rc = clock_gettime(CLOCK_MONOTONIC, &ts); - if (rc < 0) { - have_posix_clocks = 0; - } else { - have_posix_clocks = 1; - } - } + if(have_posix_clocks < 0) + { + struct timespec ts; + rc = clock_gettime(CLOCK_MONOTONIC, &ts); + if(rc < 0) + { + have_posix_clocks = 0; + } + else + { + have_posix_clocks = 1; + } + } - if (have_posix_clocks) { - struct timespec ts; - rc = clock_gettime(CLOCK_MONOTONIC, &ts); - return uint64(ts.tv_sec) * 1000000 + uint64(ts.tv_nsec) / 1000; - } - #endif + if(have_posix_clocks) + { + struct timespec ts; + rc = clock_gettime(CLOCK_MONOTONIC, &ts); + return uint64(ts.tv_sec) * 1000000 + uint64(ts.tv_nsec) / 1000; + } +#endif - gettimeofday(&tv, NULL); - return uint64(tv.tv_sec) * 1000000 + tv.tv_usec; + gettimeofday(&tv, NULL); + return uint64(tv.tv_sec) * 1000000 + tv.tv_usec; } -#endif //!__APPLE__ +#endif //!__APPLE__ -#endif //!WIN32 +#endif //! WIN32 /* * Whew. Okay. After that #ifdef maze above, we now know we have a working * __GetMicroseconds() implementation on all platforms. - * + * * Because there are a number of assertions in libutp that will cause a crash * if monotonic time isn't monotonic, now apply some safety checks. While in * principle we're already protecting ourselves in cases where non-monotonic * time is likely to happen, this protects all versions. */ -static inline uint64 UTP_GetMicroseconds() +static inline uint64 +UTP_GetMicroseconds() { - static uint64 offset = 0, previous = 0; + static uint64 offset = 0, previous = 0; - uint64 now = __GetMicroseconds() + offset; - if (previous > now) { - /* Eek! */ - offset += previous - now; - now = previous; - } - previous = now; - return now; + uint64 now = __GetMicroseconds() + offset; + if(previous > now) + { + /* Eek! */ + offset += previous - now; + now = previous; + } + previous = now; + return now; } #define ETHERNET_MTU 1500 @@ -227,30 +256,47 @@ static inline uint64 UTP_GetMicroseconds() #define UDP_IPV6_OVERHEAD (IPV6_HEADER_SIZE + UDP_HEADER_SIZE) #define UDP_TEREDO_OVERHEAD (UDP_IPV4_OVERHEAD + UDP_IPV6_OVERHEAD) -#define UDP_IPV4_MTU (ETHERNET_MTU - IPV4_HEADER_SIZE - UDP_HEADER_SIZE - GRE_HEADER_SIZE - PPPOE_HEADER_SIZE - MPPE_HEADER_SIZE - FUDGE_HEADER_SIZE) -#define UDP_IPV6_MTU (ETHERNET_MTU - IPV6_HEADER_SIZE - UDP_HEADER_SIZE - GRE_HEADER_SIZE - PPPOE_HEADER_SIZE - MPPE_HEADER_SIZE - FUDGE_HEADER_SIZE) +#define UDP_IPV4_MTU \ + (ETHERNET_MTU - IPV4_HEADER_SIZE - UDP_HEADER_SIZE - GRE_HEADER_SIZE \ + - PPPOE_HEADER_SIZE - MPPE_HEADER_SIZE - FUDGE_HEADER_SIZE) +#define UDP_IPV6_MTU \ + (ETHERNET_MTU - IPV6_HEADER_SIZE - UDP_HEADER_SIZE - GRE_HEADER_SIZE \ + - PPPOE_HEADER_SIZE - MPPE_HEADER_SIZE - FUDGE_HEADER_SIZE) #define UDP_TEREDO_MTU (TEREDO_MTU - IPV6_HEADER_SIZE - UDP_HEADER_SIZE) -uint64 utp_default_get_udp_mtu(utp_callback_arguments *args) { - // Since we don't know the local address of the interface, - // be conservative and assume all IPv6 connections are Teredo. - return (args->address->sa_family == AF_INET6) ? UDP_TEREDO_MTU : UDP_IPV4_MTU; +uint64 +utp_default_get_udp_mtu(utp_callback_arguments *args) +{ + // Since we don't know the local address of the interface, + // be conservative and assume all IPv6 connections are Teredo. + return (args->address->sa_family == AF_INET6) ? UDP_TEREDO_MTU : UDP_IPV4_MTU; } -uint64 utp_default_get_udp_overhead(utp_callback_arguments *args) { - // Since we don't know the local address of the interface, - // be conservative and assume all IPv6 connections are Teredo. - return (args->address->sa_family == AF_INET6) ? UDP_TEREDO_OVERHEAD : UDP_IPV4_OVERHEAD; +uint64 +utp_default_get_udp_overhead(utp_callback_arguments *args) +{ + // Since we don't know the local address of the interface, + // be conservative and assume all IPv6 connections are Teredo. + return (args->address->sa_family == AF_INET6) ? UDP_TEREDO_OVERHEAD + : UDP_IPV4_OVERHEAD; } -uint64 utp_default_get_random(utp_callback_arguments *args) { - return rand(); +uint64 +utp_default_get_random(__attribute__((unused)) utp_callback_arguments *args) +{ + return rand(); } -uint64 utp_default_get_milliseconds(utp_callback_arguments *args) { - return UTP_GetMilliseconds(); +uint64 +utp_default_get_milliseconds(__attribute__((unused)) + utp_callback_arguments *args) +{ + return UTP_GetMilliseconds(); } -uint64 utp_default_get_microseconds(utp_callback_arguments *args) { - return UTP_GetMicroseconds(); +uint64 +utp_default_get_microseconds(__attribute__((unused)) + utp_callback_arguments *args) +{ + return UTP_GetMicroseconds(); } diff --git a/llarp/context.cpp b/llarp/context.cpp index a86591bd2..44a384187 100644 --- a/llarp/context.cpp +++ b/llarp/context.cpp @@ -112,7 +112,7 @@ namespace llarp } bool - Context::PutDatabase(struct llarp::RouterContact &rc) + Context::PutDatabase(__attribute__((unused)) struct llarp::RouterContact &rc) { // FIXME // return llarp_nodedb_put_rc(nodedb, rc); @@ -120,7 +120,7 @@ namespace llarp } llarp::RouterContact * - Context::GetDatabase(const byte_t *pk) + Context::GetDatabase(__attribute__((unused)) const byte_t *pk) { // FIXME // return llarp_nodedb_get_rc(nodedb, pk); @@ -379,7 +379,7 @@ extern "C" } llarp::RouterContact * - llarp_main_getLocalRC(struct llarp_main *ptr) + llarp_main_getLocalRC(__attribute__((unused)) struct llarp_main *ptr) { // /* @@ -402,7 +402,8 @@ extern "C" } void - llarp_main_checkOnline(void *u, uint64_t orig, uint64_t left) + llarp_main_checkOnline(void *u, __attribute__((unused)) uint64_t orig, + uint64_t left) { // llarp::Info("checkOnline - check ", left); if(left) diff --git a/llarp/dht/context.cpp b/llarp/dht/context.cpp index 10975aedd..71327b71f 100644 --- a/llarp/dht/context.cpp +++ b/llarp/dht/context.cpp @@ -104,7 +104,9 @@ namespace llarp } void - Context::handle_cleaner_timer(void *u, uint64_t orig, uint64_t left) + Context::handle_cleaner_timer(void *u, + __attribute__((unused)) uint64_t orig, + uint64_t left) { if(left) return; @@ -397,7 +399,7 @@ namespace llarp LocalServiceAddressLookup(const PathID_t &pathid, uint64_t txid, const service::Address &addr, Context *ctx, - const Key_t &askpeer) + __attribute__((unused)) const Key_t &askpeer) : ServiceAddressLookup(TXOwner{ctx->OurKey(), txid}, addr, ctx, 5, nullptr) , localPath(pathid) @@ -568,13 +570,14 @@ namespace llarp } bool - GetNextPeer(Key_t &nextpeer, const std::set< Key_t > &exclude) + GetNextPeer(__attribute__((unused)) Key_t &nextpeer, + __attribute__((unused)) const std::set< Key_t > &exclude) { return false; } void - DoNextRequest(const Key_t &nextPeer) + DoNextRequest(__attribute__((unused)) const Key_t &nextPeer) { } @@ -718,14 +721,15 @@ namespace llarp } bool - GetNextPeer(Key_t &next, const std::set< Key_t > &exclude) + GetNextPeer(__attribute__((unused)) Key_t &next, + __attribute__((unused)) const std::set< Key_t > &exclude) { // TODO: implement iterative (?) return false; } void - DoNextRequest(const Key_t &next) + DoNextRequest(__attribute__((unused)) const Key_t &next) { } diff --git a/llarp/dht/got_intro.cpp b/llarp/dht/got_intro.cpp index ff94abd75..bc1bf7282 100644 --- a/llarp/dht/got_intro.cpp +++ b/llarp/dht/got_intro.cpp @@ -21,6 +21,7 @@ namespace llarp bool GotIntroMessage::HandleMessage( llarp_dht_context *ctx, + __attribute__((unused)) std::vector< std::unique_ptr< IMessage > > &replies) const { auto &dht = ctx->impl; @@ -58,6 +59,7 @@ namespace llarp bool RelayedGotIntroMessage::HandleMessage( llarp_dht_context *ctx, + __attribute__((unused)) std::vector< std::unique_ptr< IMessage > > &replies) const { // TODO: implement me better? diff --git a/llarp/dht/got_router.cpp b/llarp/dht/got_router.cpp index aae028666..c9427198d 100644 --- a/llarp/dht/got_router.cpp +++ b/llarp/dht/got_router.cpp @@ -68,6 +68,7 @@ namespace llarp bool GotRouterMessage::HandleMessage( llarp_dht_context *ctx, + __attribute__((unused)) std::vector< std::unique_ptr< IMessage > > &replies) const { auto &dht = ctx->impl; diff --git a/llarp/dns_dotlokilookup.cpp b/llarp/dns_dotlokilookup.cpp index d93aea1eb..4e868e713 100644 --- a/llarp/dns_dotlokilookup.cpp +++ b/llarp/dns_dotlokilookup.cpp @@ -31,7 +31,8 @@ std::unordered_map< std::string, struct dnsd_query_hook_response * > loki_tld_lookup_cache; void -llarp_dotlokilookup_checkQuery(void *u, uint64_t orig, uint64_t left) +llarp_dotlokilookup_checkQuery(void *u, __attribute__((unused)) uint64_t orig, + uint64_t left) { if(left) return; diff --git a/llarp/dns_iptracker.cpp b/llarp/dns_iptracker.cpp index 2986d99eb..f1464b8b0 100644 --- a/llarp/dns_iptracker.cpp +++ b/llarp/dns_iptracker.cpp @@ -24,6 +24,7 @@ dns_iptracker_init() // not sure we want tunGatewayIP... we'll know when we get further bool dns_iptracker_setup_dotLokiLookup(dotLokiLookup *dll, + __attribute__((unused)) llarp::huint32_t tunGatewayIp) { dll->ip_tracker = &g_dns_iptracker; diff --git a/llarp/dnsc.cpp b/llarp/dnsc.cpp index c5ad99d15..fadf588e4 100644 --- a/llarp/dnsc.cpp +++ b/llarp/dnsc.cpp @@ -151,13 +151,14 @@ answer_request_alloc(struct dnsc_context *dnsc, void *sock, const char *url, /// generic dnsc handler void generic_handle_dnsc_recvfrom(dnsc_answer_request *request, - const struct sockaddr *saddr, const void *buf, - ssize_t sz) + __attribute__((unused)) + const struct sockaddr *saddr, + const void *buf, ssize_t sz) { // llarp::LogInfo("got a response, udp user is ", udp->user); - unsigned char *castBuf = (unsigned char *)buf; - char *const castBufc = (char *const)buf; + unsigned char *castBuf = (unsigned char *)buf; + const char *const castBufc = (const char *)buf; // auto buffer = llarp::StackBuffer< decltype(castBuf) >(castBuf); dns_msg_header *hdr = decode_hdr((const char *)castBuf); @@ -728,7 +729,7 @@ llarp_dnsc_init(struct dnsc_context *const dnsc, } bool -llarp_dnsc_stop(struct dnsc_context *const dnsc) +llarp_dnsc_stop(__attribute__((unused)) struct dnsc_context *const dnsc) { // delete(sockaddr_in *)dnsc->server; // deallocation return true; diff --git a/llarp/dnsd.cpp b/llarp/dnsd.cpp index aee88c1be..bed8b0805 100644 --- a/llarp/dnsd.cpp +++ b/llarp/dnsd.cpp @@ -387,8 +387,8 @@ handle_dnsc_result(dnsc_answer_request *client_request) // our generic version void -handle_recvfrom(const char *buffer, ssize_t nbytes, const struct sockaddr *from, - dnsd_question_request *request) +handle_recvfrom(const char *buffer, __attribute__((unused)) ssize_t nbytes, + const struct sockaddr *from, dnsd_question_request *request) { const size_t HDR_OFFSET = 12; const char *p_buffer = buffer; diff --git a/llarp/ev.hpp b/llarp/ev.hpp index f09fd0054..2d01310c8 100644 --- a/llarp/ev.hpp +++ b/llarp/ev.hpp @@ -317,7 +317,9 @@ namespace llarp read(void* buf, size_t sz) = 0; virtual int - sendto(const sockaddr* dst, const void* data, size_t sz) + sendto(__attribute__((unused)) const sockaddr* dst, + __attribute__((unused)) const void* data, + __attribute__((unused)) size_t sz) { return -1; }; diff --git a/llarp/ev_epoll.hpp b/llarp/ev_epoll.hpp index a56c383c9..49f35342b 100644 --- a/llarp/ev_epoll.hpp +++ b/llarp/ev_epoll.hpp @@ -181,7 +181,9 @@ namespace llarp }; int - sendto(const sockaddr* to, const void* data, size_t sz) + sendto(__attribute__((unused)) const sockaddr* to, + __attribute__((unused)) const void* data, + __attribute__((unused)) size_t sz) { return -1; } diff --git a/llarp/ev_kqueue.hpp b/llarp/ev_kqueue.hpp index a5a776329..d8c2d3695 100644 --- a/llarp/ev_kqueue.hpp +++ b/llarp/ev_kqueue.hpp @@ -167,12 +167,12 @@ namespace llarp socklen_t slen = sizeof(sockaddr_in6); sockaddr* addr = (sockaddr*)&src; ssize_t ret = ::recvfrom(fd, buf, sz, 0, addr, &slen); - if(ret == -1) + if(ret < 0) { llarp::LogWarn("recvfrom failed"); return -1; } - if(ret > sz) + if(static_cast< size_t >(ret) > sz) { llarp::LogWarn("ret > sz"); return -1; @@ -226,7 +226,9 @@ namespace llarp , tunif(tuntap_init()){}; int - sendto(const sockaddr* to, const void* data, size_t sz) + sendto(__attribute__((unused)) const sockaddr* to, + __attribute__((unused)) const void* data, + __attribute__((unused)) size_t sz) { return -1; } @@ -269,9 +271,9 @@ namespace llarp read(void* buf, size_t sz) { #ifdef __APPLE__ - const size_t offset = 4; + const ssize_t offset = 4; #else - const size_t offset = 0; + const ssize_t offset = 0; #endif ssize_t ret = tuntap_read(tunif, buf, sz); if(ret > offset && t->recvpkt) diff --git a/llarp/exit_info.cpp b/llarp/exit_info.cpp index eed9cd188..af9626521 100644 --- a/llarp/exit_info.cpp +++ b/llarp/exit_info.cpp @@ -51,7 +51,8 @@ namespace llarp } bool - ExitInfo::DecodeKey(llarp_buffer_t k, llarp_buffer_t* buf) + ExitInfo::DecodeKey(__attribute__((unused)) llarp_buffer_t k, + __attribute__((unused)) llarp_buffer_t* buf) { bool read = false; // TODO: implement me diff --git a/llarp/handlers/tun.cpp b/llarp/handlers/tun.cpp index 9b81ec06f..eadfebb1d 100644 --- a/llarp/handlers/tun.cpp +++ b/llarp/handlers/tun.cpp @@ -457,7 +457,7 @@ namespace llarp } void - TunEndpoint::TickTun(llarp_time_t now) + TunEndpoint::TickTun(__attribute__((unused)) llarp_time_t now) { // called in the isolated thread } diff --git a/llarp/ip.cpp b/llarp/ip.cpp index 3e0c6d968..a3042a352 100644 --- a/llarp/ip.cpp +++ b/llarp/ip.cpp @@ -91,9 +91,9 @@ namespace llarp } static void - checksumDstIPv4TCP(byte_t *pld, size_t psz, size_t fragoff, - size_t chksumoff, nuint32_t oSrcIP, nuint32_t oDstIP, - nuint32_t nSrcIP, nuint32_t nDstIP) + checksumDstIPv4TCP(byte_t *pld, __attribute__((unused)) size_t psz, + size_t fragoff, size_t chksumoff, nuint32_t oSrcIP, + nuint32_t oDstIP, nuint32_t nSrcIP, nuint32_t nDstIP) { if(fragoff > chksumoff) return; @@ -110,9 +110,9 @@ namespace llarp } static void - checksumDstIPv4UDP(byte_t *pld, size_t psz, size_t fragoff, - nuint32_t oSrcIP, nuint32_t oDstIP, nuint32_t nSrcIP, - nuint32_t nDstIP) + checksumDstIPv4UDP(byte_t *pld, __attribute__((unused)) size_t psz, + size_t fragoff, nuint32_t oSrcIP, nuint32_t oDstIP, + nuint32_t nSrcIP, nuint32_t nDstIP) { if(fragoff > 6) return; @@ -179,8 +179,9 @@ namespace llarp } static void - checksumSrcIPv4TCP(byte_t *pld, size_t psz, size_t fragoff, - size_t chksumoff, nuint32_t oSrcIP, nuint32_t oDstIP) + checksumSrcIPv4TCP(byte_t *pld, __attribute__((unused)) size_t psz, + size_t fragoff, size_t chksumoff, nuint32_t oSrcIP, + nuint32_t oDstIP) { if(fragoff > chksumoff) return; @@ -198,8 +199,8 @@ namespace llarp } static void - checksumSrcIPv4UDP(byte_t *pld, size_t psz, size_t fragoff, - nuint32_t oSrcIP, nuint32_t oDstIP) + checksumSrcIPv4UDP(byte_t *pld, __attribute__((unused)) size_t psz, + size_t fragoff, nuint32_t oSrcIP, nuint32_t oDstIP) { if(fragoff > 6) return; diff --git a/llarp/link/curvecp.cpp b/llarp/link/curvecp.cpp index 5936a5394..6f31f4b1c 100644 --- a/llarp/link/curvecp.cpp +++ b/llarp/link/curvecp.cpp @@ -7,7 +7,7 @@ namespace llarp namespace curvecp { std::unique_ptr< ILinkLayer > - NewServer(llarp_router* r) + NewServer(__attribute__((unused)) llarp_router* r) { return nullptr; } diff --git a/llarp/link/utp.cpp b/llarp/link/utp.cpp index d4a6e54bb..50fbf7972 100644 --- a/llarp/link/utp.cpp +++ b/llarp/link/utp.cpp @@ -227,7 +227,7 @@ namespace llarp } void - TickImpl(llarp_time_t now) + TickImpl(__attribute__((unused)) llarp_time_t now) { } diff --git a/llarp/mem.cpp b/llarp/mem.cpp index 8d4757ade..d38b08f5b 100644 --- a/llarp/mem.cpp +++ b/llarp/mem.cpp @@ -17,7 +17,9 @@ namespace llarp } // namespace llarp void -llarp_mem_slab(struct llarp_alloc *mem, uint32_t *buf, size_t sz) +llarp_mem_slab(__attribute__((unused)) struct llarp_alloc *mem, + __attribute__((unused)) uint32_t *buf, + __attribute__((unused)) size_t sz) { // not implemented abort(); diff --git a/llarp/net.cpp b/llarp/net.cpp index 84a12ee27..043d966a6 100644 --- a/llarp/net.cpp +++ b/llarp/net.cpp @@ -977,7 +977,8 @@ namespace llarp } bool - IsBogonRange(const in6_addr& host, const in6_addr& netmask) + IsBogonRange(__attribute__((unused)) const in6_addr& host, + __attribute__((unused)) const in6_addr& netmask) { // TODO: implement me return true; diff --git a/llarp/path.cpp b/llarp/path.cpp index 3d2ba9220..ef828d347 100644 --- a/llarp/path.cpp +++ b/llarp/path.cpp @@ -153,7 +153,7 @@ namespace llarp PathContext::GetByUpstream(const RouterID& remote, const PathID_t& id) { auto own = MapGet(m_OurPaths, id, - [](const PathSet* s) -> bool { + [](__attribute__((unused)) const PathSet* s) -> bool { // TODO: is this right? return true; }, @@ -559,16 +559,18 @@ namespace llarp bool Path::HandlePathTransferMessage( - const llarp::routing::PathTransferMessage* msg, llarp_router* r) + __attribute__((unused)) const llarp::routing::PathTransferMessage* msg, + __attribute__((unused)) llarp_router* r) { - llarp::LogWarn("unwarrented path transfer message on tx=", TXID(), + llarp::LogWarn("unwarranted path transfer message on tx=", TXID(), " rx=", RXID()); return false; } bool Path::HandleDataDiscardMessage( - const llarp::routing::DataDiscardMessage* msg, llarp_router* r) + const llarp::routing::DataDiscardMessage* msg, + __attribute__((unused)) llarp_router* r) { if(m_DropHandler) return m_DropHandler(this, msg->P, msg->S); @@ -577,7 +579,8 @@ namespace llarp bool Path::HandlePathConfirmMessage( - const llarp::routing::PathConfirmMessage* msg, llarp_router* r) + __attribute__((unused)) const llarp::routing::PathConfirmMessage* msg, + llarp_router* r) { auto now = r->Now(); if(_status == ePathBuilding) diff --git a/llarp/proofofwork.cpp b/llarp/proofofwork.cpp index 061f7482b..f5bf8b5a8 100644 --- a/llarp/proofofwork.cpp +++ b/llarp/proofofwork.cpp @@ -10,7 +10,8 @@ namespace llarp } bool - PoW::DecodeKey(llarp_buffer_t k, llarp_buffer_t* val) + PoW::DecodeKey(__attribute__((unused)) llarp_buffer_t k, + __attribute__((unused)) llarp_buffer_t* val) { // TODO: implement me return false; @@ -53,4 +54,4 @@ namespace llarp return true; } -} // namespace llarp \ No newline at end of file +} // namespace llarp diff --git a/llarp/router.cpp b/llarp/router.cpp index 09d7f9733..920133c73 100644 --- a/llarp/router.cpp +++ b/llarp/router.cpp @@ -875,7 +875,8 @@ llarp_router::InitServiceNode() } void -llarp_router::ConnectAll(void *user, uint64_t orig, uint64_t left) +llarp_router::ConnectAll(void *user, __attribute__((unused)) uint64_t orig, + uint64_t left) { if(left) return; @@ -916,7 +917,7 @@ llarp_router::ConnectToRandomRouters(int want) } bool -llarp_router::ReloadConfig(const llarp_config *conf) +llarp_router::ReloadConfig(__attribute__((unused)) const llarp_config *conf) { return true; } diff --git a/llarp/rpc.cpp b/llarp/rpc.cpp index 3693abc72..05788628c 100644 --- a/llarp/rpc.cpp +++ b/llarp/rpc.cpp @@ -22,7 +22,7 @@ namespace llarp } void - PopulateReqHeaders(abyss::http::Headers_t& hdr) + PopulateReqHeaders(__attribute__((unused)) abyss::http::Headers_t& hdr) { } }; @@ -43,7 +43,8 @@ namespace llarp } bool - HandleResponse(const ::abyss::http::RPC_Response& response) + HandleResponse(__attribute__((unused)) + const ::abyss::http::RPC_Response& response) { handler(pk, true); return true; @@ -139,7 +140,9 @@ namespace llarp } bool - HandleJSONRPC(Method_t method, const Params& params, Response& response) + HandleJSONRPC(Method_t method, + __attribute__((unused)) const Params& params, + Response& response) { if(method == "llarp.admin.link.neighboors") { @@ -198,9 +201,10 @@ namespace llarp #else struct ServerImpl { - ServerImpl(llarp_router* r){}; + ServerImpl(__attribute__((unused)) llarp_router* r){}; + bool - Start(const std::string& addr) + Start(__attribute__((unused)) const std::string& addr) { return true; } @@ -208,7 +212,7 @@ namespace llarp struct CallerImpl { - CallerImpl(llarp_router* r) + CallerImpl(__attribute__((unused)) llarp_router* r) { } diff --git a/llarp/service/context.cpp b/llarp/service/context.cpp index 076580f80..b5d32a35b 100644 --- a/llarp/service/context.cpp +++ b/llarp/service/context.cpp @@ -135,7 +135,10 @@ namespace llarp // HiddenServiceEndpoint(tunEndpoint, callback, addr, // tunEndpoint->GenTXID()); return tunEndpoint->EnsurePathToService( - addr, [](Address addr, void *ctx) {}, 10000); + addr, + [](__attribute__((unused)) Address addr, + __attribute__((unused)) void *ctx) {}, + 10000); } huint32_t diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index fc912dfeb..f52d61475 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -180,7 +180,10 @@ namespace llarp if(!HasPathToService(addr)) { if(!EnsurePathToService( - addr, [](Address addr, OutboundContext* ctx) {}, 10000)) + addr, + [](__attribute__((unused)) Address addr, + __attribute__((unused)) OutboundContext* ctx) {}, + 10000)) { llarp::LogWarn("failed to ensure path to ", addr); } @@ -780,7 +783,8 @@ namespace llarp } bool - Endpoint::HandleDataMessage(const PathID_t& src, ProtocolMessage* msg) + Endpoint::HandleDataMessage(__attribute__((unused)) const PathID_t& src, + ProtocolMessage* msg) { msg->sender.UpdateAddr(); PutIntroFor(msg->tag, msg->introReply); @@ -834,7 +838,8 @@ namespace llarp } bool - Endpoint::CheckPathIsDead(path::Path* p, llarp_time_t latency) + Endpoint::CheckPathIsDead(__attribute__((unused)) path::Path* p, + llarp_time_t latency) { if(latency >= m_MinPathLatency) { @@ -874,7 +879,9 @@ namespace llarp bool Endpoint::EnsurePathToService(const Address& remote, PathEnsureHook hook, - llarp_time_t timeoutMS, bool randomPath) + __attribute__((unused)) + llarp_time_t timeoutMS, + bool randomPath) { path::Path* path = nullptr; if(randomPath) @@ -991,7 +998,8 @@ namespace llarp } bool - Endpoint::OutboundContext::OnIntroSetUpdate(const Address& addr, + Endpoint::OutboundContext::OnIntroSetUpdate(__attribute__((unused)) + const Address& addr, const IntroSet* i, const RouterID& endpoint) { @@ -1371,6 +1379,7 @@ namespace llarp void Endpoint::OutboundContext::AsyncGenIntro(llarp_buffer_t payload, + __attribute__((unused)) ProtocolType t) { auto path = m_PathSet->GetPathByRouter(remoteIntro.router); diff --git a/llarp/service/protocol.cpp b/llarp/service/protocol.cpp index 797fcdb0e..ccb6f5706 100644 --- a/llarp/service/protocol.cpp +++ b/llarp/service/protocol.cpp @@ -385,7 +385,7 @@ namespace llarp bool ProtocolFrame::HandleMessage(llarp::routing::IMessageHandler* h, - llarp_router* r) const + __attribute__((unused)) llarp_router* r) const { return h->HandleHiddenServiceFrame(this); } diff --git a/llarp/threadpool.cpp b/llarp/threadpool.cpp index 42daa27b2..e2c06da76 100644 --- a/llarp/threadpool.cpp +++ b/llarp/threadpool.cpp @@ -193,8 +193,9 @@ struct llarp_threadpool std::queue< llarp::thread::Pool::Job_t > jobs; llarp_threadpool(int workers, const char *name, bool isolate, - setup_net_func setup = nullptr, - run_main_func runmain = nullptr, void *user = nullptr) + __attribute__((unused)) setup_net_func setup = nullptr, + __attribute__((unused)) run_main_func runmain = nullptr, + __attribute__((unused)) void *user = nullptr) { #ifdef NET_ISOLATION_SUPPORTED if(isolate) @@ -245,7 +246,7 @@ llarp_threadpool_join(struct llarp_threadpool *pool) } void -llarp_threadpool_start(struct llarp_threadpool *pool) +llarp_threadpool_start(__attribute__((unused)) struct llarp_threadpool *pool) { /** no op */ } diff --git a/llarp/transit_hop.cpp b/llarp/transit_hop.cpp index 98e9f6d25..4b86ae6fa 100644 --- a/llarp/transit_hop.cpp +++ b/llarp/transit_hop.cpp @@ -133,15 +133,17 @@ namespace llarp bool TransitHop::HandlePathConfirmMessage( - const llarp::routing::PathConfirmMessage* msg, llarp_router* r) + __attribute__((unused)) const llarp::routing::PathConfirmMessage* msg, + __attribute__((unused)) llarp_router* r) { - llarp::LogWarn("unwarrented path confirm message on ", info); + llarp::LogWarn("unwarranted path confirm message on ", info); return false; } bool TransitHop::HandleDataDiscardMessage( - const llarp::routing::DataDiscardMessage* msg, llarp_router* r) + __attribute__((unused)) const llarp::routing::DataDiscardMessage* msg, + __attribute__((unused)) llarp_router* r) { llarp::LogWarn("unwarranted path data discard message on ", info); return false; diff --git a/test/jsonrpc_unittest.cpp b/test/jsonrpc_unittest.cpp index c852f69e0..b1bce93e6 100644 --- a/test/jsonrpc_unittest.cpp +++ b/test/jsonrpc_unittest.cpp @@ -29,7 +29,7 @@ struct AbyssTestBase : public ::testing::Test } static void - CancelIt(void* u, uint64_t orig, uint64_t left) + CancelIt(void* u, __attribute__((unused)) uint64_t orig, uint64_t left) { if(left) return; @@ -97,12 +97,13 @@ struct ClientHandler : public abyss::http::IRPCClientHandler } void - PopulateReqHeaders(abyss::http::Headers_t& hdr) + PopulateReqHeaders(__attribute__((unused)) abyss::http::Headers_t& hdr) { } bool - HandleResponse(const abyss::http::RPC_Response& response) + HandleResponse(__attribute__((unused)) + const abyss::http::RPC_Response& response) { test->Stop(); return true; @@ -118,7 +119,8 @@ struct ServerHandler : public abyss::httpd::IRPCHandler } bool - HandleJSONRPC(Method_t method, const Params& params, Response& response) + HandleJSONRPC(Method_t method, __attribute__((unused)) const Params& params, + __attribute__((unused)) Response& response) { test->AssertMethod(method); test->called = true; diff --git a/test/test_dns_unit.cpp b/test/test_dns_unit.cpp index 1069d839d..adae07886 100644 --- a/test/test_dns_unit.cpp +++ b/test/test_dns_unit.cpp @@ -1,47 +1,47 @@ #include -#include // for llarp_main_init -#include // for threadpool/llarp_logic +#include // for llarp_main_init +#include // for threadpool/llarp_logic #include "llarp/net.hpp" // for llarp::Addr #include "llarp/dns.hpp" #include "llarp/dnsc.hpp" struct DNSTest : public ::testing::Test { - unsigned char buf[47] = { - 0x00,0x01, // first short - 0x01,0x00,0x00, // combined fields - 0x01,0x00,0x01,0x00,0x00,0x00,0x00, // last 4 shorts - // question (is 18 bytes long) - 0x04, // 4 letters - 0x6C,0x6F,0x6B,0x69, // loki - 0x07, // 7 letters - 0x6E,0x65,0x74,0x77,0x6F,0x72,0x6B, // network - 0x00, // end - 0x00,0x01, // type (a 1/ptr 12) - 0x00,0x01, // class (1 = internet) - // 30th byte - // Answer (is 16 bytes long) - 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, // name, type, class - 0x00, 0x00, 0x08, 0x4b, // ttl 2123 - 0x00, 0x04, // rdLen - 0x45, 0x10, 0xd1, 0x02, // an ip address - // extra - 0x00 // null terminator (probably don't need this, just added it) + 0x00, 0x01, // first short + 0x01, 0x00, 0x00, // combined fields + 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, // last 4 shorts + // question (is 18 bytes long) + 0x04, // 4 letters + 0x6C, 0x6F, 0x6B, 0x69, // loki + 0x07, // 7 letters + 0x6E, 0x65, 0x74, 0x77, 0x6F, 0x72, 0x6B, // network + 0x00, // end + 0x00, 0x01, // type (a 1/ptr 12) + 0x00, 0x01, // class (1 = internet) + // 30th byte + // Answer (is 16 bytes long) + 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, // name, type, class + 0x00, 0x00, 0x08, 0x4b, // ttl 2123 + 0x00, 0x04, // rdLen + 0x45, 0x10, 0xd1, 0x02, // an ip address + // extra + 0x00 // null terminator (probably don't need this, just added it) }; DNSTest() { - } void SetUp() { - llarp::SetLogLevel(llarp::eLogNone); // turn off logging to keep gtest output pretty + llarp::SetLogLevel( + llarp::eLogNone); // turn off logging to keep gtest output pretty /* const char *url = "loki.network"; - struct dns_query *packet = build_dns_packet((char *)url, 1, 1); // id 1, type 1 (A) + struct dns_query *packet = build_dns_packet((char *)url, 1, 1); // id 1, + type 1 (A) unsigned int length = packet->length; char *buffer = (char *)packet->request; @@ -52,7 +52,6 @@ struct DNSTest : public ::testing::Test printf("Generated [%u] bytes: [%s]\n", length, hex_buffer); */ } - }; // test puts/gets @@ -60,8 +59,8 @@ struct DNSTest : public ::testing::Test TEST_F(DNSTest, TestDecodeDNSstring) { char *buffer = (char *)this->buf; - buffer += 12; // skip header - uint32_t pos = 0; + buffer += 12; // skip header + uint32_t pos = 0; std::string res = getDNSstring(buffer, &pos); ASSERT_TRUE(res == "loki.network"); } @@ -71,16 +70,17 @@ TEST_F(DNSTest, TestCodeDomain) char buffer[16]; llarp::Zero(buffer, 16); char *write_buffer = buffer; - std::string url = "bob.com"; + std::string url = "bob.com"; code_domain(write_buffer, url); char hex_buffer[16 * 3 + 1]; hex_buffer[16 * 3] = 0; for(unsigned int j = 0; j < 16; j++) sprintf(&hex_buffer[3 * j], "%02X ", ((const char *)buffer)[j]); - //printf("first 16 [%s]", hex_buffer); + // printf("first 16 [%s]", hex_buffer); - std::string expected_result = "03 62 6F 62 03 63 6F 6D 00 00 00 00 00 00 00 00 "; + std::string expected_result = + "03 62 6F 62 03 63 6F 6D 00 00 00 00 00 00 00 00 "; ASSERT_TRUE(hex_buffer == expected_result); } @@ -125,12 +125,12 @@ TEST_F(DNSTest, TestDecodeHdr) TEST_F(DNSTest, TestDecodeQuestion) { char *buffer = (char *)this->buf; - buffer += 12; // skip header - uint32_t pos = 0; + buffer += 12; // skip header + uint32_t pos = 0; dns_msg_question *question = decode_question(buffer, &pos); - //printf("name[%s]", question->name.c_str()); - //printf("type[%d]", question->type); - //printf("qClass[%d]", question->qClass); + // printf("name[%s]", question->name.c_str()); + // printf("type[%d]", question->type); + // printf("qClass[%d]", question->qClass); std::string url = "loki.network"; ASSERT_TRUE(question->name == url); ASSERT_TRUE(question->type == 1); @@ -139,10 +139,10 @@ TEST_F(DNSTest, TestDecodeQuestion) TEST_F(DNSTest, TestDecodeAnswer) { - const char * const buffer = (const char * const)this->buf; - uint32_t pos = 12; - std::string url = "loki.network"; - pos += url.length() + 2 + 4; // skip question (string + 2 shorts) + const char *const buffer = (const char *)this->buf; + uint32_t pos = 12; + std::string url = "loki.network"; + pos += url.length() + 2 + 4; // skip question (string + 2 shorts) dns_msg_answer *answer = decode_answer(buffer, &pos); /* @@ -150,7 +150,8 @@ TEST_F(DNSTest, TestDecodeAnswer) printf("aClass[%d]", answer->aClass); printf("ttl[%d]", answer->ttl); printf("rdLen[%d]", answer->rdLen); - printf("[%hhu].[%hhu].[%hhu].[%hhu]", answer->rData[0], answer->rData[1], answer->rData[2], answer->rData[3]); + printf("[%hhu].[%hhu].[%hhu].[%hhu]", answer->rData[0], answer->rData[1], + answer->rData[2], answer->rData[3]); */ ASSERT_TRUE(answer->name == url); ASSERT_TRUE(answer->type == 1); @@ -191,5 +192,4 @@ TEST_F(DNSTest, handleDNSrecvFrom) llarp_handle_dns_recvfrom((llarp_udp_io *)&udp, &addr, buffer, sz); // llarp_handle_dnsc_recvfrom // llarp_handle_dnsd_recvfrom - } diff --git a/test/test_dnsd_unit.cpp b/test/test_dnsd_unit.cpp index b77777bd6..c3681d1b4 100644 --- a/test/test_dnsd_unit.cpp +++ b/test/test_dnsd_unit.cpp @@ -1,19 +1,22 @@ #include -#include // for llarp_main_init -#include // for threadpool/llarp_logic +#include // for llarp_main_init +#include // for threadpool/llarp_logic #include "llarp/net.hpp" // for llarp::Addr #include "llarp/dnsd.hpp" unsigned int g_length = 0; -std::string g_result = ""; +std::string g_result = ""; -ssize_t test_sendto_dns_hook(void *sock, const struct sockaddr *from, - const void *buffer, size_t length) { +ssize_t +test_sendto_dns_hook(__attribute__((unused)) void *sock, + __attribute__((unused)) const struct sockaddr *from, + const void *buffer, size_t length) +{ char hex_buffer[length * 3 + 1]; hex_buffer[length * 3] = 0; for(unsigned int j = 0; j < length; j++) sprintf(&hex_buffer[3 * j], "%02X ", ((const char *)buffer)[j]); - //printf("Got [%zu] bytes: [%s]\n", length, hex_buffer); + // printf("Got [%zu] bytes: [%s]\n", length, hex_buffer); g_result = hex_buffer; g_length = length; return length; @@ -22,34 +25,36 @@ ssize_t test_sendto_dns_hook(void *sock, const struct sockaddr *from, struct llarpDNSdTest : public ::testing::Test { dnsd_question_request test_request; - + llarpDNSdTest() { - } void SetUp() { - test_request.id = 0; - test_request.llarp = true; // we don't care about raw atm - test_request.from = nullptr; - test_request.context = nullptr; - test_request.sendto_hook = &test_sendto_dns_hook; + test_request.id = 0; + test_request.llarp = true; // we don't care about raw atm + test_request.from = nullptr; + test_request.context = nullptr; + test_request.sendto_hook = &test_sendto_dns_hook; test_request.question.name = "loki.network"; test_request.question.type = 1; test_request.question.qClass = 1; - g_result = ""; // reset test global - g_length = 0; - llarp::SetLogLevel(llarp::eLogNone); // turn off logging to keep gtest output pretty + g_result = ""; // reset test global + g_length = 0; + llarp::SetLogLevel( + llarp::eLogNone); // turn off logging to keep gtest output pretty } - }; TEST_F(llarpDNSdTest, TestNxDomain) { write404_dnss_response(nullptr, &test_request); ASSERT_TRUE(g_length == 55); - std::string expected_output = "00 00 FFF03 00 01 00 01 00 00 00 00 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 01 00 01 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 01 00 01 00 00 00 01 00 01 00 "; + std::string expected_output = + "00 00 FFF03 00 01 00 01 00 00 00 00 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 " + "6B 00 00 01 00 01 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 01 00 01 " + "00 00 00 01 00 01 00 "; ASSERT_TRUE(expected_output == g_result); } @@ -57,20 +62,25 @@ TEST_F(llarpDNSdTest, TestAResponse) { llarp::huint32_t hostRes; llarp::Zero(&hostRes.h, sizeof(uint32_t)); - //sockaddr hostRes; - //llarp::Zero(&hostRes, sizeof(sockaddr)); + // sockaddr hostRes; + // llarp::Zero(&hostRes, sizeof(sockaddr)); writesend_dnss_response(&hostRes, nullptr, &test_request); ASSERT_TRUE(g_length == 58); - std::string expected_output = "00 00 FFF00 00 01 00 01 00 00 00 00 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 01 00 01 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 01 00 01 00 00 00 01 00 04 00 00 00 00 "; + std::string expected_output = + "00 00 FFF00 00 01 00 01 00 00 00 00 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 " + "6B 00 00 01 00 01 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 01 00 01 " + "00 00 00 01 00 04 00 00 00 00 "; ASSERT_TRUE(expected_output == g_result); } TEST_F(llarpDNSdTest, TestPTRResponse) { - writesend_dnss_revresponse("loki.network", nullptr, - &test_request); + writesend_dnss_revresponse("loki.network", nullptr, &test_request); ASSERT_TRUE(g_length == 68); - std::string expected_output = "00 00 FFF00 00 01 00 01 00 00 00 00 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 01 00 01 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 01 00 01 00 00 00 01 00 0E 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 "; + std::string expected_output = + "00 00 FFF00 00 01 00 01 00 00 00 00 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 " + "6B 00 00 01 00 01 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 01 00 01 " + "00 00 00 01 00 0E 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 "; ASSERT_TRUE(expected_output == g_result); } @@ -78,7 +88,12 @@ TEST_F(llarpDNSdTest, TestCname) { writecname_dnss_response("test.cname", nullptr, &test_request); ASSERT_TRUE(g_length == 122); - std::string expected_output = "00 00 FFF00 00 01 00 01 00 01 00 01 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 01 00 01 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 05 00 01 00 00 00 01 00 0C 04 74 65 73 74 05 63 6E 61 6D 65 00 04 74 65 73 74 05 63 6E 61 6D 65 00 00 02 00 01 00 00 00 01 00 0A 03 6E 73 31 04 6C 6F 6B 69 00 03 6E 73 31 04 6C 6F 6B 69 00 00 01 00 01 00 00 00 01 00 04 7F 00 00 01 "; + std::string expected_output = + "00 00 FFF00 00 01 00 01 00 01 00 01 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 " + "6B 00 00 01 00 01 04 6C 6F 6B 69 07 6E 65 74 77 6F 72 6B 00 00 05 00 01 " + "00 00 00 01 00 0C 04 74 65 73 74 05 63 6E 61 6D 65 00 04 74 65 73 74 05 " + "63 6E 61 6D 65 00 00 02 00 01 00 00 00 01 00 0A 03 6E 73 31 04 6C 6F 6B " + "69 00 03 6E 73 31 04 6C 6F 6B 69 00 00 01 00 01 00 00 00 01 00 04 7F 00 " + "00 01 "; ASSERT_TRUE(expected_output == g_result); } - diff --git a/vendor/cppbackport-master/lib/fs/create_directory.cpp b/vendor/cppbackport-master/lib/fs/create_directory.cpp index 94433dcff..0ba34739d 100644 --- a/vendor/cppbackport-master/lib/fs/create_directory.cpp +++ b/vendor/cppbackport-master/lib/fs/create_directory.cpp @@ -44,7 +44,7 @@ namespace cpp17 namespace filesystem { bool - create_directory(const path& s, std::error_code& ec) + create_directory(const path& s, __attribute__((unused)) std::error_code& ec) { if(s.empty()) { @@ -55,7 +55,8 @@ namespace cpp17 } bool - create_directories(const path& s, std::error_code& ec) + create_directories(const path& s, + __attribute__((unused)) std::error_code& ec) { path p = s.parent_path(); diff --git a/vendor/cppbackport-master/lib/fs/diriter.cpp b/vendor/cppbackport-master/lib/fs/diriter.cpp index 01e7a8601..98afb9308 100644 --- a/vendor/cppbackport-master/lib/fs/diriter.cpp +++ b/vendor/cppbackport-master/lib/fs/diriter.cpp @@ -292,14 +292,8 @@ namespace cpp17 // is this right directory_iterator::directory_iterator(directory_iterator const& src) + : pimpl(new impl(src.pimpl->p.c_str())) { - // printf("directory_iterator::directory_iterator copy - pimpl[%x] - // from[%s]\n", pimpl, src->path().c_str()); - if(pimpl) - { - // delete pimpl; - } - pimpl = new impl(src.pimpl->p.c_str()); pimpl->seek(src.pimpl->pos); } diff --git a/vendor/cppbackport-master/lib/fs/filestatus.cpp b/vendor/cppbackport-master/lib/fs/filestatus.cpp index 3ea8d7743..900b42adc 100644 --- a/vendor/cppbackport-master/lib/fs/filestatus.cpp +++ b/vendor/cppbackport-master/lib/fs/filestatus.cpp @@ -182,7 +182,7 @@ namespace cpp17 } bool - exists(const path& p, std::error_code& ec) + exists(const path& p, __attribute__((unused)) std::error_code& ec) { return exists(status(p)); } diff --git a/vendor/libtuntap-master/tuntap-unix-darwin.c b/vendor/libtuntap-master/tuntap-unix-darwin.c index 519cf30c4..28525fa97 100644 --- a/vendor/libtuntap-master/tuntap-unix-darwin.c +++ b/vendor/libtuntap-master/tuntap-unix-darwin.c @@ -45,7 +45,8 @@ #define UTUN_OPT_IFNAME 2 static int -fucky_tuntap_sys_start(struct device *dev, int mode, int tun) +fucky_tuntap_sys_start(struct device *dev, __attribute__((unused)) int mode, + int tun) { uint32_t namesz = IFNAMSIZ; char name[IFNAMSIZ + 1]; @@ -197,7 +198,9 @@ tuntap_sys_set_ipv4(struct device *dev, t_tun_in_addr *s4, uint32_t bits) } int -tuntap_sys_set_descr(struct device *dev, const char *descr, size_t len) +tuntap_sys_set_descr(__attribute__((unused)) struct device *dev, + __attribute__((unused)) const char *descr, + __attribute__((unused)) size_t len) { tuntap_log(TUNTAP_LOG_NOTICE, "Your system does not support tuntap_set_descr()"); diff --git a/vendor/libtuntap-master/tuntap-unix.c b/vendor/libtuntap-master/tuntap-unix.c index b6f4bafc0..8049e7a20 100644 --- a/vendor/libtuntap-master/tuntap-unix.c +++ b/vendor/libtuntap-master/tuntap-unix.c @@ -360,6 +360,7 @@ tuntap_set_debug(struct device *dev, int set) } return 0; #else + (void)set; tuntap_log(TUNTAP_LOG_NOTICE, "Your system does not support tuntap_set_debug()"); return -1; diff --git a/vendor/libtuntap-master/tuntap.cpp b/vendor/libtuntap-master/tuntap.cpp index 5baf601cf..79644a176 100644 --- a/vendor/libtuntap-master/tuntap.cpp +++ b/vendor/libtuntap-master/tuntap.cpp @@ -149,6 +149,7 @@ extern "C" return -1; } #else + (void)daddr; return tuntap_sys_set_ipv4(dev, &baddr4, mask); #endif }