From 0758de960a981d6d82b254cacc810a026111b686 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 18 Oct 2014 11:32:29 -0400 Subject: [PATCH] Clean up a bunch of warnings when building with Xcode 6.1 --- limelight-common/AudioStream.c | 11 +++++++---- limelight-common/ControlStream.c | 4 ++-- limelight-common/InputStream.c | 2 +- limelight-common/Limelight.h | 4 ++-- limelight-common/PlatformSockets.h | 6 +++++- limelight-common/PlatformThreads.c | 2 +- limelight-common/RtspConnection.c | 3 ++- limelight-common/SdpGenerator.c | 2 +- limelight-common/VideoStream.c | 8 ++++---- 9 files changed, 25 insertions(+), 17 deletions(-) diff --git a/limelight-common/AudioStream.c b/limelight-common/AudioStream.c index 11e0e1c..1123ae4 100644 --- a/limelight-common/AudioStream.c +++ b/limelight-common/AudioStream.c @@ -52,7 +52,7 @@ static void UdpPingThreadProc(void *context) { /* Ping in ASCII */ char pingData[] = { 0x50, 0x49, 0x4E, 0x47 }; struct sockaddr_in saddr; - int err; + SOCK_RET err; memset(&saddr, 0, sizeof(saddr)); saddr.sin_family = AF_INET; @@ -73,8 +73,9 @@ static void UdpPingThreadProc(void *context) { } static void ReceiveThreadProc(void* context) { - int err; + SOCK_RET err; PRTP_PACKET rtp; + int packetSize; char* buffer = NULL; while (!PltIsThreadInterrupted(&receiveThread)) { @@ -94,8 +95,10 @@ static void ReceiveThreadProc(void* context) { listenerCallbacks->connectionTerminated(LastSocketError()); return; } + + packetSize = (int)err; - if (err < sizeof(RTP_PACKET)) { + if (packetSize < sizeof(RTP_PACKET)) { // Runt packet continue; } @@ -106,7 +109,7 @@ static void ReceiveThreadProc(void* context) { continue; } - memcpy(buffer, &err, sizeof(err)); + memcpy(buffer, &packetSize, sizeof(int)); err = LbqOfferQueueItem(&packetQueue, buffer); if (err == LBQ_SUCCESS) { diff --git a/limelight-common/ControlStream.c b/limelight-common/ControlStream.c index 9a3e651..5cccead 100644 --- a/limelight-common/ControlStream.c +++ b/limelight-common/ControlStream.c @@ -74,7 +74,7 @@ void connectionLostPackets(int lastReceivedPacket, int nextReceivedPacket) { static PNVCTL_PACKET_HEADER readNvctlPacket(void) { NVCTL_PACKET_HEADER staticHeader; PNVCTL_PACKET_HEADER fullPacket; - int err; + SOCK_RET err; err = recv(ctlSock, (char*) &staticHeader, sizeof(staticHeader), 0); if (err != sizeof(staticHeader)) { @@ -100,7 +100,7 @@ static PNVCTL_PACKET_HEADER readNvctlPacket(void) { static int sendMessageAndForget(short ptype, short paylen, const void* payload) { NVCTL_PACKET_HEADER header; - int err; + SOCK_RET err; header.type = ptype; header.payloadLength = paylen; diff --git a/limelight-common/InputStream.c b/limelight-common/InputStream.c index ace45fc..ee42a25 100644 --- a/limelight-common/InputStream.c +++ b/limelight-common/InputStream.c @@ -87,7 +87,7 @@ void destroyInputStream(void) { } static void inputSendThreadProc(void* context) { - int err; + SOCK_RET err; PPACKET_HOLDER holder; char encryptedBuffer[MAX_INPUT_PACKET_SIZE]; size_t encryptedSize; diff --git a/limelight-common/Limelight.h b/limelight-common/Limelight.h index 19dc49d..4710bdf 100644 --- a/limelight-common/Limelight.h +++ b/limelight-common/Limelight.h @@ -72,10 +72,10 @@ typedef struct _AUDIO_RENDERER_CALLBACKS { typedef void(*ConnListenerStageStarting)(int stage); typedef void(*ConnListenerStageComplete)(int stage); -typedef void(*ConnListenerStageFailed)(int stage, int errorCode); +typedef void(*ConnListenerStageFailed)(int stage, long errorCode); typedef void(*ConnListenerConnectionStarted)(void); -typedef void(*ConnListenerConnectionTerminated)(int errorCode); +typedef void(*ConnListenerConnectionTerminated)(long errorCode); typedef void(*ConnListenerDisplayMessage)(char* message); typedef void(*ConnListenerDisplayTransientMessage)(char* message); diff --git a/limelight-common/PlatformSockets.h b/limelight-common/PlatformSockets.h index 53608f9..40dbd5c 100644 --- a/limelight-common/PlatformSockets.h +++ b/limelight-common/PlatformSockets.h @@ -9,6 +9,8 @@ #define SetLastSocketError(x) WSASetLastError(x) #define LastSocketError() WSAGetLastError() +typedef int SOCK_RET; + #else #include #include @@ -16,12 +18,14 @@ #include #include #include -#define SOCKET int #define LastSocketError() errno #define SetLastSocketError(x) errno = x #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #define closesocket(x) close(x) + +typedef int SOCKET; +typedef ssize_t SOCK_RET; #endif SOCKET connectTcpSocket(IP_ADDRESS dstaddr, unsigned short port); diff --git a/limelight-common/PlatformThreads.c b/limelight-common/PlatformThreads.c index 5444a71..ec4704d 100644 --- a/limelight-common/PlatformThreads.c +++ b/limelight-common/PlatformThreads.c @@ -39,7 +39,7 @@ void PltSleepMs(int ms) { #if defined(LC_WINDOWS) || defined (LC_WINDOWS_PHONE) WaitForSingleObjectEx(GetCurrentThread(), ms, FALSE); #else - long usecs = (long)ms * 1000; + useconds_t usecs = ms * 1000; usleep(usecs); #endif } diff --git a/limelight-common/RtspConnection.c b/limelight-common/RtspConnection.c index 3f33959..5ba3b82 100644 --- a/limelight-common/RtspConnection.c +++ b/limelight-common/RtspConnection.c @@ -81,7 +81,8 @@ static int initializeRtspRequest(PRTSP_MESSAGE msg, char* command, char* target) /* Returns 1 on success, 0 otherwise */ static int transactRtspMessage(PRTSP_MESSAGE request, PRTSP_MESSAGE response) { - int err, ret = 0; + SOCK_RET err; + int ret = 0; int offset; char* serializedMessage = NULL; int messageLen; diff --git a/limelight-common/SdpGenerator.c b/limelight-common/SdpGenerator.c index 3d6479f..9ec8539 100644 --- a/limelight-common/SdpGenerator.c +++ b/limelight-common/SdpGenerator.c @@ -82,7 +82,7 @@ static int addAttributeBinary(PSDP_OPTION *head, char* name, const void* payload static int addAttributeString(PSDP_OPTION *head, char* name, const char* payload) { // We purposefully omit the null terminating character - return addAttributeBinary(head, name, payload, strlen(payload)); + return addAttributeBinary(head, name, payload, (int)strlen(payload)); } static PSDP_OPTION getAttributesList(PSTREAM_CONFIGURATION streamConfig, struct in_addr targetAddress) { diff --git a/limelight-common/VideoStream.c b/limelight-common/VideoStream.c index 5edff55..5e03ad5 100644 --- a/limelight-common/VideoStream.c +++ b/limelight-common/VideoStream.c @@ -39,7 +39,7 @@ void destroyVideoStream(void) { static void UdpPingThreadProc(void *context) { char pingData [] = { 0x50, 0x49, 0x4E, 0x47 }; struct sockaddr_in saddr; - int err; + SOCK_RET err; memset(&saddr, 0, sizeof(saddr)); saddr.sin_family = AF_INET; @@ -59,7 +59,7 @@ static void UdpPingThreadProc(void *context) { } static void ReceiveThreadProc(void* context) { - int err; + SOCK_RET err; int bufferSize; char* buffer; @@ -80,7 +80,7 @@ static void ReceiveThreadProc(void* context) { } // queueRtpPacket() copies the data it needs to we can reuse the buffer - queueRtpPacket((PRTP_PACKET) buffer, err); + queueRtpPacket((PRTP_PACKET) buffer, (int)err); } free(buffer); @@ -102,7 +102,7 @@ static void DecoderThreadProc(void* context) { int readFirstFrame(void) { char* firstFrame; - int err; + SOCK_RET err; int offset = 0; firstFrameSocket = connectTcpSocket(remoteHost, FIRST_FRAME_PORT);