From bd16538a8ecf7ea4484f343890db84f1995d3c2c Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Fri, 1 Feb 2019 01:13:07 -0800 Subject: [PATCH] Fixed compiler warnings on MacOS --- meshconsole/main.c | 1 - meshcore/agentcore.c | 14 +++++++++++--- microscript/ILibDuktape_fs.c | 15 +++++++-------- microstack/ILibProcessPipe.c | 6 ++++-- microstack/ILibWebClient.c | 10 +++++----- microstack/ILibWebClient.h | 4 ++-- 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/meshconsole/main.c b/meshconsole/main.c index be9fd7f..9fb2819 100644 --- a/meshconsole/main.c +++ b/meshconsole/main.c @@ -95,7 +95,6 @@ extern void* kvm_server_mainloop(void *parm); extern void senddebug(int val); ILibTransport_DoneState kvm_serviceWriteSink(char *buffer, int bufferLen, void *reserved) { - int len; ignore_result(write(STDOUT_FILENO, (void*)buffer, bufferLen)); return ILibTransport_DoneState_COMPLETE; } diff --git a/meshcore/agentcore.c b/meshcore/agentcore.c index 8f81cbe..a9a8684 100644 --- a/meshcore/agentcore.c +++ b/meshcore/agentcore.c @@ -363,7 +363,10 @@ void MeshAgent_sendConsoleText(duk_context *ctx, char *txt) int MeshAgent_GetSystemProxy(MeshAgentHostContainer *agent, char *buffer, size_t bufferSize) { +#ifndef __APPLE__ int retVal = 0; +#endif + #ifdef _POSIX #ifndef __APPLE__ for (char **env = environ; *env; ++env) @@ -454,6 +457,10 @@ int MeshAgent_GetSystemProxy(MeshAgentHostContainer *agent, char *buffer, size_t return(0); } } + else + { + return(0); + } #endif #else char getProxy[] = "(function () {\ @@ -3352,8 +3359,9 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char ** int pLen; #endif #ifdef _POSIX +#ifndef __APPLE__ int options = 0; - +#endif if (paramLen >= 2) { if ((strcmp(param[1], "stop") == 0 || strcmp(param[1], "-s") == 0)) @@ -3972,7 +3980,7 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para #ifdef WIN32 int x; #elif defined(__APPLE__) - int len = 1024; + uint32_t len = 1024; #elif defined(NACL) // Do nothing #else @@ -3997,7 +4005,7 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para GetModuleFileName(NULL, exePath, sizeof(exePath)); #elif defined(__APPLE__) if (_NSGetExecutablePath(exePath, &len) != 0) ILIBCRITICALEXIT(247); - exePath[len] = 0; + exePath[(int)len] = 0; agentHost->exePath = exePath; #elif defined(NACL) #else diff --git a/microscript/ILibDuktape_fs.c b/microscript/ILibDuktape_fs.c index a044099..afc3679 100644 --- a/microscript/ILibDuktape_fs.c +++ b/microscript/ILibDuktape_fs.c @@ -925,7 +925,7 @@ duk_ret_t ILibDuktape_fs_watcher_close(duk_context *ctx) ((ILibDuktape_fs_descriptorInfo*)ILibMemory_Extra(d))->descriptor = data->wd.p; ((ILibDuktape_fs_descriptorInfo*)ILibMemory_Extra(d))->user = data; ((ILibDuktape_fs_descriptorInfo*)ILibMemory_Extra(d))->flags = ILibDuktape_fs_descriptorFlags_REMOVE; - watcher->descriptors = d; + watcher->descriptors = (ILibDuktape_fs_descriptorInfo**)d; write(watcher->unblocker[1], " ", 1); sem_wait(&(watcher->inputWaiter)); @@ -1188,7 +1188,7 @@ void ILibduktape_fs_watch_appleWorker(void *obj) struct kevent change[KEVENTBLOCKSIZE]; struct kevent event; int inCount = 1; - int n, i, x; + int n, i; char tmp[255]; EV_SET(&(change[0]), watcher->unblocker[0], EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, 0); @@ -1208,7 +1208,7 @@ void ILibduktape_fs_watch_appleWorker(void *obj) if ((watcher->descriptors[i]->flags & ILibDuktape_fs_descriptorFlags_ADD) == ILibDuktape_fs_descriptorFlags_ADD) { // Add Descriptor - EV_SET(&(change[inCount++]), watcher->descriptors[i]->descriptor, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB | NOTE_RENAME | NOTE_LINK, 0, watcher->descriptors[i]->user); + EV_SET(&(change[inCount++]), (uintptr_t)watcher->descriptors[i]->descriptor, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB | NOTE_RENAME | NOTE_LINK, 0, watcher->descriptors[i]->user); if (inCount == KEVENTBLOCKSIZE) { // Change List is full, let's set it to kevent now @@ -1219,7 +1219,7 @@ void ILibduktape_fs_watch_appleWorker(void *obj) if ((watcher->descriptors[i]->flags & ILibDuktape_fs_descriptorFlags_REMOVE) == ILibDuktape_fs_descriptorFlags_REMOVE) { // Remove Descriptor - EV_SET(&(change[inCount++]), watcher->descriptors[i]->descriptor, EVFILT_VNODE, EV_DELETE | EV_DISABLE, 0, 0, NULL); + EV_SET(&(change[inCount++]), (uintptr_t)watcher->descriptors[i]->descriptor, EVFILT_VNODE, EV_DELETE | EV_DISABLE, 0, 0, NULL); if (inCount == KEVENTBLOCKSIZE) { // Change List is full, let's set it to kevent now @@ -1233,9 +1233,6 @@ void ILibduktape_fs_watch_appleWorker(void *obj) else { // One of the descriptors triggered! - char test[4096]; - int testLen = 4096; - if ((event.fflags & NOTE_ATTRIB) == NOTE_ATTRIB) { ILibChain_RunOnMicrostackThreadEx(watcher->chain, ILibduktape_fs_watch_appleWorker_ATTRIB, event.udata); @@ -1277,7 +1274,9 @@ duk_ret_t ILibDuktape_fs_watch(duk_context *ctx) int nargs = duk_get_top(ctx); int i; ILibDuktape_fs_watcherData *data; +#ifndef __APPLE__ void *chain = Duktape_GetChain(ctx); +#endif #if defined(WIN32) int recursive = 0; @@ -1419,7 +1418,7 @@ duk_ret_t ILibDuktape_fs_watch(duk_context *ctx) ((ILibDuktape_fs_descriptorInfo*)ILibMemory_Extra(d))->descriptor = data->wd.p; ((ILibDuktape_fs_descriptorInfo*)ILibMemory_Extra(d))->user = data; ((ILibDuktape_fs_descriptorInfo*)ILibMemory_Extra(d))->flags = ILibDuktape_fs_descriptorFlags_ADD; - watcher->descriptors = d; + watcher->descriptors = (ILibDuktape_fs_descriptorInfo**)d; write(watcher->unblocker[1], " ", 1); sem_wait(&(watcher->inputWaiter)); } diff --git a/microstack/ILibProcessPipe.c b/microstack/ILibProcessPipe.c index 7c99a24..47ba3a3 100644 --- a/microstack/ILibProcessPipe.c +++ b/microstack/ILibProcessPipe.c @@ -828,20 +828,22 @@ ILibProcessPipe_Process ILibProcessPipe_Manager_SpawnProcessEx3(ILibProcessPipe_ #endif if (spawnType == ILibProcessPipe_SpawnTypes_TERM) { +#ifndef __APPLE__ int pipe; struct winsize w; w.ws_row = CONSOLE_SCREEN_HEIGHT; w.ws_col = CONSOLE_SCREEN_WIDTH; w.ws_xpixel = 0; w.ws_ypixel = 0; -#ifndef __APPLE__ pid = forkpty(&pipe, NULL, NULL, &w); -#endif retVal->stdIn = ILibProcessPipe_Pipe_CreateFromExistingWithExtraMemory(pipeManager, pipe, extraMemorySize); retVal->stdIn->mProcess = retVal; retVal->stdOut = ILibProcessPipe_Pipe_CreateFromExistingWithExtraMemory(pipeManager, pipe, extraMemorySize); ILibProcessPipe_Pipe_SetBrokenPipeHandler(retVal->stdOut, ILibProcessPipe_Process_BrokenPipeSink); retVal->stdOut->mProcess = retVal; +#else + pid = 0; // Apple LLVM is being dumb, and throws a warning if I don't do this, even tho it'll never run +#endif } else { diff --git a/microstack/ILibWebClient.c b/microstack/ILibWebClient.c index a73649e..9587c8d 100644 --- a/microstack/ILibWebClient.c +++ b/microstack/ILibWebClient.c @@ -1451,7 +1451,7 @@ int ILibWebClient_ProcessWebSocketData(char* buffer, int offset, int length, ILi case WEBSOCKET_OPCODE_PING: if (state->pingHandler == NULL || state->pingHandler(wcdo, state->pingPongUser) == ILibWebClient_WebSocket_PingResponse_Respond) { - ILibWebClient_WebSocket_Send(wcdo, (ILibWebClient_WebSocket_DataTypes)WEBSOCKET_OPCODE_PONG, NULL, 0, ILibAsyncSocket_MemoryOwnership_STATIC, ILibWebServer_WebSocket_FragmentFlag_Complete); + ILibWebClient_WebSocket_Send(wcdo, (ILibWebClient_WebSocket_DataTypes)WEBSOCKET_OPCODE_PONG, NULL, 0, ILibAsyncSocket_MemoryOwnership_STATIC, ILibWebClient_WebSocket_FragmentFlag_Complete); } break; case WEBSOCKET_OPCODE_PONG: @@ -3288,13 +3288,13 @@ ILibTransport_DoneState ILibWebClient_StreamRequestBody( if (body != NULL && bodyLength > 0) { hexLen = sprintf_s(hex, 16, "%X\r\n", bodyLength); - result = ILibAsyncSocket_Send(t->wcdo->SOCK, hex, hexLen, ILibAsyncSocket_MemoryOwnership_USER); + result = (ILibTransport_DoneState)ILibAsyncSocket_Send(t->wcdo->SOCK, hex, hexLen, ILibAsyncSocket_MemoryOwnership_USER); if (result != ILibTransport_DoneState_ERROR) { - result = ILibAsyncSocket_Send(t->wcdo->SOCK, body ,bodyLength, MemoryOwnership); + result = (ILibTransport_DoneState)ILibAsyncSocket_Send(t->wcdo->SOCK, body ,bodyLength, MemoryOwnership); if (result != ILibTransport_DoneState_ERROR) { - result = ILibAsyncSocket_Send(t->wcdo->SOCK, "\r\n", 2, ILibAsyncSocket_MemoryOwnership_STATIC); + result = (ILibTransport_DoneState)ILibAsyncSocket_Send(t->wcdo->SOCK, "\r\n", 2, ILibAsyncSocket_MemoryOwnership_STATIC); } } else if (MemoryOwnership == ILibAsyncSocket_MemoryOwnership_CHAIN) @@ -3304,7 +3304,7 @@ ILibTransport_DoneState ILibWebClient_StreamRequestBody( } if (result != ILibTransport_DoneState_ERROR && done != 0) { - result = ILibAsyncSocket_Send(t->wcdo->SOCK, "0\r\n\r\n", 5, ILibAsyncSocket_MemoryOwnership_STATIC); + result = (ILibTransport_DoneState)ILibAsyncSocket_Send(t->wcdo->SOCK, "0\r\n\r\n", 5, ILibAsyncSocket_MemoryOwnership_STATIC); } if (result == ILibTransport_DoneState_COMPLETE && wr != NULL && wr->streamedState != NULL && wr->streamedState->OnSendOK != NULL && done == 0) { diff --git a/microstack/ILibWebClient.h b/microstack/ILibWebClient.h index 2126cb8..8b4aa41 100644 --- a/microstack/ILibWebClient.h +++ b/microstack/ILibWebClient.h @@ -291,8 +291,8 @@ typedef void(*ILibWebClient_WebSocket_PongHandler)(ILibWebClient_StateObject sta void ILibWebClient_AddWebSocketRequestHeaders(ILibHTTPPacket *packet, int FragmentReassemblyMaxBufferSize, ILibWebClient_OnSendOK OnSendOK); ILibAsyncSocket_SendStatus ILibWebClient_WebSocket_Send(ILibWebClient_StateObject state, ILibWebClient_WebSocket_DataTypes bufferType, char* buffer, int bufferLen, ILibAsyncSocket_MemoryOwnership userFree, ILibWebClient_WebSocket_FragmentFlags bufferFragment); void ILibWebClient_WebSocket_SetPingPongHandler(ILibWebClient_StateObject state, ILibWebClient_WebSocket_PingHandler pingHandler, ILibWebClient_WebSocket_PongHandler pongHandler, void *user); -#define ILibWebClient_WebSocket_Ping(stateObject) ILibWebClient_WebSocket_Send((stateObject), (ILibWebClient_WebSocket_DataTypes)WEBSOCKET_OPCODE_PING, NULL, 0, ILibAsyncSocket_MemoryOwnership_STATIC, ILibWebServer_WebSocket_FragmentFlag_Complete) -#define ILibWebClient_WebSocket_Pong(stateObject) ILibWebClient_WebSocket_Send((stateObject), (ILibWebClient_WebSocket_DataTypes)WEBSOCKET_OPCODE_PONG, NULL, 0, ILibAsyncSocket_MemoryOwnership_STATIC, ILibWebServer_WebSocket_FragmentFlag_Complete) +#define ILibWebClient_WebSocket_Ping(stateObject) ILibWebClient_WebSocket_Send((stateObject), (ILibWebClient_WebSocket_DataTypes)WEBSOCKET_OPCODE_PING, NULL, 0, ILibAsyncSocket_MemoryOwnership_STATIC, ILibWebClient_WebSocket_FragmentFlag_Complete) +#define ILibWebClient_WebSocket_Pong(stateObject) ILibWebClient_WebSocket_Send((stateObject), (ILibWebClient_WebSocket_DataTypes)WEBSOCKET_OPCODE_PONG, NULL, 0, ILibAsyncSocket_MemoryOwnership_STATIC, ILibWebClient_WebSocket_FragmentFlag_Complete) typedef void(*ILibWebClient_TimeoutHandler)(ILibWebClient_StateObject state, void *user); void ILibWebClient_SetTimeout(ILibWebClient_StateObject state, int timeoutSeconds, ILibWebClient_TimeoutHandler handler, void *user);