From 97a499fc50235f4e7fd6ff4afb5506ebd54bc477 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 30 Jun 2015 20:53:23 -0700 Subject: [PATCH] Fix build errors and warnings on Windows --- limelight-common/Platform.c | 2 +- limelight-common/Platform.h | 10 +++------- limelight-common/PlatformSockets.c | 5 +++-- limelight-common/RtspParser.c | 4 ++-- limelight-common/SdpGenerator.c | 4 ++-- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/limelight-common/Platform.c b/limelight-common/Platform.c index 8fa9a65..86ccc17 100644 --- a/limelight-common/Platform.c +++ b/limelight-common/Platform.c @@ -210,7 +210,7 @@ int PltCreateThread(ThreadEntry entry, void* context, PLT_THREAD *thread) { PltUnlockMutex(&thread_list_lock); // Make a callback to managed code to ask for a thread to grab this - platformCallbacks.threadStart(); + PlatformCallbacks.threadStart(); err = 0; } diff --git a/limelight-common/Platform.h b/limelight-common/Platform.h index 7e8e88c..fc9f623 100644 --- a/limelight-common/Platform.h +++ b/limelight-common/Platform.h @@ -17,11 +17,7 @@ #endif #ifdef _WIN32 -# if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP -# define LC_WINDOWS_PHONE -# elif WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP -# define LC_WINDOWS -# endif +# define LC_WINDOWS #else # define LC_POSIX # if defined(__APPLE__) @@ -33,10 +29,10 @@ #include "Limelight.h" #if defined(LC_WINDOWS_PHONE) || defined(LC_WINDOWS) extern char DbgBuf[512]; -extern PLATFORM_CALLBACKS platformCallbacks; +extern PLATFORM_CALLBACKS PlatformCallbacks; #define Limelog(s, ...) \ sprintf(DbgBuf, s, ##__VA_ARGS__); \ - platformCallbacks.debugPrint(DbgBuf) + PlatformCallbacks.debugPrint(DbgBuf) #else #define Limelog(s, ...) \ fprintf(stderr, s, ##__VA_ARGS__) diff --git a/limelight-common/PlatformSockets.c b/limelight-common/PlatformSockets.c index 6f975ba..387406d 100644 --- a/limelight-common/PlatformSockets.c +++ b/limelight-common/PlatformSockets.c @@ -3,8 +3,9 @@ void addrToUrlSafeString(struct sockaddr_storage *addr, char* string) { + char addrstr[INET6_ADDRSTRLEN]; + if (addr->ss_family == AF_INET6) { - char addrstr[INET6_ADDRSTRLEN]; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr; inet_ntop(addr->ss_family, &sin6->sin6_addr, addrstr, sizeof(addrstr)); @@ -13,7 +14,7 @@ void addrToUrlSafeString(struct sockaddr_storage *addr, char* string) } else { struct sockaddr_in *sin = (struct sockaddr_in *)addr; - char *addrstr = inet_ntoa(sin->sin_addr); + inet_ntop(addr->ss_family, &sin->sin_addr, addrstr, sizeof(addrstr)); // IPv4 addresses are returned without changes sprintf(string, "%s", addrstr); diff --git a/limelight-common/RtspParser.c b/limelight-common/RtspParser.c index 8a6f54f..20b9039 100644 --- a/limelight-common/RtspParser.c +++ b/limelight-common/RtspParser.c @@ -15,7 +15,7 @@ static int getMessageLength(PRTSP_MESSAGE msg){ POPTION_ITEM current; /* Initialize to 1 for null terminator */ - int count = 1; + size_t count = 1; /* Add the length of the protocol */ count += strlen(msg->protocol); @@ -50,7 +50,7 @@ static int getMessageLength(PRTSP_MESSAGE msg){ /* Add the length of the payload, if any */ count += msg->payloadLength; - return count; + return (int)count; } /* Given an RTSP message string rtspMessage, parse it into an RTSP_MESSAGE struct msg */ diff --git a/limelight-common/SdpGenerator.c b/limelight-common/SdpGenerator.c index 17f99f1..4a6ae08 100644 --- a/limelight-common/SdpGenerator.c +++ b/limelight-common/SdpGenerator.c @@ -25,7 +25,7 @@ static void freeAttributeList(PSDP_OPTION head) { /* Get the size of the attribute list */ static int getSerializedAttributeListSize(PSDP_OPTION head) { PSDP_OPTION currentEntry = head; - int size = 0; + size_t size = 0; while (currentEntry != NULL) { size += strlen("a="); size += strlen(currentEntry->name); @@ -35,7 +35,7 @@ static int getSerializedAttributeListSize(PSDP_OPTION head) { currentEntry = currentEntry->next; } - return size; + return (int)size; } /* Populate the serialized attribute list into a string */