Enable warnings, clang edition.

This commit is contained in:
Chris Marsh 2017-10-12 16:08:08 -07:00
parent 6fa00223ad
commit 990c8d4be6
8 changed files with 35 additions and 17 deletions

View file

@ -64,14 +64,14 @@ DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
DiscordEventHandlers* handlers, DiscordEventHandlers* handlers,
int autoRegister, int autoRegister,
const char* optionalSteamId); const char* optionalSteamId);
DISCORD_EXPORT void Discord_Shutdown(); DISCORD_EXPORT void Discord_Shutdown(void);
/* checks for incoming messages, dispatches callbacks */ /* checks for incoming messages, dispatches callbacks */
DISCORD_EXPORT void Discord_RunCallbacks(); DISCORD_EXPORT void Discord_RunCallbacks(void);
/* If you disable the lib starting its own io thread, you'll need to call this from your own */ /* If you disable the lib starting its own io thread, you'll need to call this from your own */
#ifdef DISCORD_DISABLE_IO_THREAD #ifdef DISCORD_DISABLE_IO_THREAD
DISCORD_EXPORT void Discord_UpdateConnection(); DISCORD_EXPORT void Discord_UpdateConnection(void);
#endif #endif
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence); DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);

View file

@ -55,7 +55,19 @@ if(UNIX)
add_library(discord-rpc ${RPC_LIBRARY_TYPE} ${BASE_RPC_SRC}) add_library(discord-rpc ${RPC_LIBRARY_TYPE} ${BASE_RPC_SRC})
target_link_libraries(discord-rpc PUBLIC pthread) target_link_libraries(discord-rpc PUBLIC pthread)
target_compile_options(discord-rpc PRIVATE -g -Wall) target_compile_options(discord-rpc PRIVATE
-g
-Weverything
-Wno-unknown-pragmas # pragma push thing doesn't work on clang
-Wno-old-style-cast # it's fine
-Wno-c++98-compat # that was almost 2 decades ago
-Wno-c++98-compat-pedantic
-Wno-missing-noreturn
-Wno-padded # structure padding
-Wno-covered-switch-default
-Wno-exit-time-destructors # not sure about these
-Wno-global-constructors
)
target_compile_options(discord-rpc PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-std=c++14>) target_compile_options(discord-rpc PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-std=c++14>)
if (APPLE) if (APPLE)

View file

@ -111,7 +111,7 @@ bool BaseConnection::Read(void* data, size_t length)
return false; return false;
} }
int res = recv(self->sock, data, length, MsgFlags); int res = (int)recv(self->sock, data, length, MsgFlags);
if (res < 0) { if (res < 0) {
if (errno == EAGAIN) { if (errno == EAGAIN) {
return false; return false;

View file

@ -47,8 +47,8 @@ static int LastDisconnectErrorCode{0};
static char LastDisconnectErrorMessage[256]; static char LastDisconnectErrorMessage[256];
static std::mutex PresenceMutex; static std::mutex PresenceMutex;
static QueuedMessage QueuedPresence{}; static QueuedMessage QueuedPresence{};
MsgQueue<QueuedMessage, MessageQueueSize> SendQueue; static MsgQueue<QueuedMessage, MessageQueueSize> SendQueue;
MsgQueue<DiscordJoinRequest, MessageQueueSize> JoinAskQueue; static MsgQueue<DiscordJoinRequest, JoinQueueSize> JoinAskQueue;
// We want to auto connect, and retry on failure, but not as fast as possible. This does expoential // We want to auto connect, and retry on failure, but not as fast as possible. This does expoential
// backoff from 0.5 seconds to 1 minute // backoff from 0.5 seconds to 1 minute
@ -70,7 +70,11 @@ static void UpdateReconnectTime()
std::chrono::duration<int64_t, std::milli>{ReconnectTimeMs.nextDelay()}; std::chrono::duration<int64_t, std::milli>{ReconnectTimeMs.nextDelay()};
} }
DISCORD_EXPORT void Discord_UpdateConnection() #ifdef DISCORD_DISABLE_IO_THREAD
DISCORD_EXPORT void Discord_UpdateConnection(void)
#else
static void Discord_UpdateConnection(void)
#endif
{ {
if (!Connection) { if (!Connection) {
return; return;
@ -173,7 +177,7 @@ DISCORD_EXPORT void Discord_UpdateConnection()
} }
#ifndef DISCORD_DISABLE_IO_THREAD #ifndef DISCORD_DISABLE_IO_THREAD
void DiscordRpcIo() static void DiscordRpcIo(void)
{ {
const std::chrono::duration<int64_t, std::milli> maxWait{500LL}; const std::chrono::duration<int64_t, std::milli> maxWait{500LL};
@ -186,14 +190,14 @@ void DiscordRpcIo()
} }
#endif #endif
void SignalIOActivity() static void SignalIOActivity()
{ {
#ifndef DISCORD_DISABLE_IO_THREAD #ifndef DISCORD_DISABLE_IO_THREAD
WaitForIOActivity.notify_all(); WaitForIOActivity.notify_all();
#endif #endif
} }
bool RegisterForEvent(const char* evtName) static bool RegisterForEvent(const char* evtName)
{ {
auto qmessage = SendQueue.GetNextAddMessage(); auto qmessage = SendQueue.GetNextAddMessage();
if (qmessage) { if (qmessage) {

View file

@ -3,6 +3,8 @@
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#include "discord_register.h"
static bool Mkdir(const char* path) static bool Mkdir(const char* path)
{ {
int result = mkdir(path, 0755); int result = mkdir(path, 0755);
@ -39,7 +41,7 @@ static void RegisterCommand(const char* applicationId, const char* command)
if (f) { if (f) {
char jsonBuffer[2048]; char jsonBuffer[2048];
int len = snprintf(jsonBuffer, sizeof(jsonBuffer), "{\"command\": \"%s\"}", command); int len = snprintf(jsonBuffer, sizeof(jsonBuffer), "{\"command\": \"%s\"}", command);
fwrite(jsonBuffer, len, 1, f); fwrite(jsonBuffer, (size_t)len, 1, f);
fclose(f); fclose(f);
} }
} }

View file

@ -13,7 +13,7 @@ class MsgQueue {
std::atomic_uint pendingSends_{0}; std::atomic_uint pendingSends_{0};
public: public:
MsgQueue(){}; MsgQueue(){}
ElementType* GetNextAddMessage() ElementType* GetNextAddMessage()
{ {

View file

@ -72,7 +72,7 @@ void WriteOptionalString(JsonWriter& w, T& k, const char* value)
} }
} }
void JsonWriteNonce(JsonWriter& writer, int nonce) static void JsonWriteNonce(JsonWriter& writer, int nonce)
{ {
WriteKey(writer, "nonce"); WriteKey(writer, "nonce");
char nonceBuffer[32]; char nonceBuffer[32];