Bug 1039917 - Fix clang and gcc warnings in webrtc/signaling. r=jesup
authorChris Peterson <cpeterson@mozilla.com>
Tue, 15 Jul 2014 20:28:57 -0700
changeset 216760 f3cee88147f25039b33c24afec73d3ddb527239d
parent 216759 9926ef67edb3f3432a58204c054d3696013d9c81
child 216761 6f197c331bb14e76294a0669517c3e9528a527d9
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1039917
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1039917 - Fix clang and gcc warnings in webrtc/signaling. r=jesup
media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
media/webrtc/signaling/src/sipcc/core/sdp/ccsdp.c
media/webrtc/signaling/src/sipcc/core/sdp/sdp_utils.c
media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_core.c
media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_pmh.c
media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_subsmanager.c
media/webrtc/signaling/src/sipcc/cpr/common/cpr_ipc.c
media/webrtc/signaling/src/softphonewrapper/CC_SIPCCService.cpp
--- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
+++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
@@ -12,17 +12,20 @@
 #ifdef MOZILLA_INTERNAL_API
 #include "nsString.h"
 #include "mozilla/Preferences.h"
 #else
 #include "nsStringAPI.h"
 #endif
 
 static int gWebRtcTraceLoggingOn = 0;
+
+#ifndef ANDROID
 static const char *default_log = "WebRTC.log";
+#endif
 
 static PRLogModuleInfo* GetWebRtcTraceLog()
 {
   static PRLogModuleInfo *sLog;
   if (!sLog) {
     sLog = PR_NewLogModule("webrtc_trace");
   }
   return sLog;
--- a/media/webrtc/signaling/src/sipcc/core/sdp/ccsdp.c
+++ b/media/webrtc/signaling/src/sipcc/core/sdp/ccsdp.c
@@ -4,17 +4,17 @@
 
 #include "sdp.h"
 #include "ccapi.h"
 
 int ccsdpAttrGetFmtpInst(void *sdp_ptr, u16 level, u16 payload_num)
 {
   cc_sdp_t *sdpp = sdp_ptr;
   if ( sdpp->dest_sdp == NULL ) {
-    return NULL;
+    return 0;
   }
   return sdp_find_fmtp_inst(sdpp->dest_sdp, level, payload_num);
 }
 
 const char* ccsdpAttrGetFmtpParamSets(void *sdp_ptr, u16 level,
                                             u8 cap_num, u16 inst_num)
 {
   cc_sdp_t *sdpp = sdp_ptr;
--- a/media/webrtc/signaling/src/sipcc/core/sdp/sdp_utils.c
+++ b/media/webrtc/signaling/src/sipcc/core/sdp/sdp_utils.c
@@ -55,17 +55,17 @@ sdp_mca_t *sdp_alloc_mca () {
  * delimiters at the beginning will be skipped.
  * The pointer *string_of_tokens is moved forward to the next token on sucess.
  *
  */
 static sdp_result_e next_token(const char **string_of_tokens, char *token, unsigned token_max_len, const char *delim)
 {
   int flag2moveon = 0;
   const char *str = *string_of_tokens;
-  char *token_start = token;
+  const char *token_end = token + token_max_len - 1;
   const char *next_delim;
 
   if (!string_of_tokens || !*string_of_tokens || !token || !delim) {
     return SDP_FAILURE;
   }
 
   /* Locate front of token, skipping any delimiters */
   for ( ; ((*str != '\0') && (*str != '\n') && (*str != '\r')); str++) {
@@ -84,17 +84,17 @@ static sdp_result_e next_token(const cha
   /* Make sure there's really a token present. */
   if ((*str == '\0') || (*str == '\n') || (*str == '\r')) {
     return SDP_FAILURE;
   }
 
   /* Now locate end of token */
   flag2moveon = 0;
 
-  while (((token-token_start) < token_max_len - 1) &&
+  while ((token < token_end) &&
          (*str != '\0') && (*str != '\n') && (*str != '\r')) {
       for (next_delim=delim; *next_delim; next_delim++) {
           if (*str == *next_delim) {
               flag2moveon = 1;
               break;
           }
       }
       if( flag2moveon ) {
--- a/media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_core.c
+++ b/media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_core.c
@@ -9151,17 +9151,17 @@ sip_sm_request_check_and_store (ccsipCCB
 
         content_length = sippmh_get_content_length(request);
 
         if (request->raw_body) {
 
             if ((size_t) content_length != strlen(request->raw_body)) {
                 CCSIP_DEBUG_ERROR(SIP_F_PREFIX"\n Mismatched Content length and "
                                   "Actual message body length:content length=%d\n"
-                                  "and message as %s\n and strlen of messagebody = %lu\n",
+                                  "and message as %s\n and strlen of messagebody = %zu\n",
                                   fname, content_length, request->raw_body,
                                   strlen(request->raw_body));
                 *request_check_reason_code = SIP_WARN_MISC;
                 sstrncpy(request_check_reason_phrase,
                         SIP_CLI_ERR_BAD_REQ_CONTENT_LENGTH_ERROR,
                         SIP_WARNING_LENGTH);
                 return (-1);
             }
--- a/media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_pmh.c
+++ b/media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_pmh.c
@@ -4707,17 +4707,17 @@ sippmh_parse_supported_require (const ch
     if (punsupported_tokens != NULL) {
         *punsupported_tokens = NULL; //assume everything  will go right
     }
 
     //need to keep own buffer since PL_strtok_r is destructive
     size = strlen(header) + 1;
     temp_header = (char *) cpr_malloc(size);
     if (temp_header == NULL) {
-        CCSIP_DEBUG_ERROR("%s: malloc failed for strlen(header)=%lu", fname,
+        CCSIP_DEBUG_ERROR("%s: malloc failed for strlen(header)=%zu", fname,
                           strlen(header));
         return tags;
     }
     sstrncpy(temp_header, header, size);
 
     token = PL_strtok_r(temp_header, delim, &lasts);
     while (token != NULL) {
         bad_token = NULL;
--- a/media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_subsmanager.c
+++ b/media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_subsmanager.c
@@ -2671,17 +2671,17 @@ subsmanager_handle_ev_sip_subscribe (sip
     // Check content
     content_length = sippmh_get_content_length(pSipMessage);
 
     if (pSipMessage->raw_body) {
         if (content_length != strlen(pSipMessage->raw_body)) {
             CCSIP_DEBUG_ERROR(SIP_F_PREFIX"\n Mismatched Content length and \
                              Actual message body length:content length=%u \
                              \n and message as %s \
-                             \n and strlenof messagebody = %lu", fname,
+                             \n and strlenof messagebody = %zu", fname,
                              content_length, pSipMessage->raw_body,
                              strlen(pSipMessage->raw_body));
             if (sipSPISendErrorResponse(pSipMessage, SIP_CLI_ERR_BAD_REQ,
                                         SIP_CLI_ERR_BAD_REQ_PHRASE,
                                         SIP_WARN_MISC,
                                         SIP_CLI_ERR_BAD_REQ_CONTENT_LENGTH_ERROR,
                                         NULL) != TRUE) {
                 CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_SIP_SPI_SEND_ERROR),
--- a/media/webrtc/signaling/src/sipcc/cpr/common/cpr_ipc.c
+++ b/media/webrtc/signaling/src/sipcc/cpr/common/cpr_ipc.c
@@ -266,31 +266,33 @@ cprPostMessage (cpr_msg_queue_t *msgq, v
  *       If 'depth' is outside of the bounds, the value will be
  *       reset automatically.
  */
 cprMsgQueue_t
 cprCreateMessageQueue (const char *name, uint16_t depth)
 {
     cpr_msg_queue_t *msgq;
 
+#ifndef SIP_OS_WINDOWS
+    static int key_id = 100; /* arbitrary starting number */
+    pthread_cond_t _cond = PTHREAD_COND_INITIALIZER;
+    pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
     msgq = cpr_calloc(1, sizeof(cpr_msg_queue_t));
     if (msgq == NULL) {
         printf("%s: Malloc failed: %s\n", __FUNCTION__,
                name ? name : "unnamed");
         errno = ENOMEM;
         return NULL;
     }
 
     msgq->name = name ? name : "unnamed";
 
 #ifndef SIP_OS_WINDOWS
-    static int key_id = 100; /* arbitrary starting number */
-    pthread_cond_t _cond = PTHREAD_COND_INITIALIZER;
-    pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER;
-
     msgq->queueId = key_id++;
     msgq->cond = _cond;
     msgq->mutex = _lock;
 
     /*
      * Add message queue to list for statistics reporting
      */
     pthread_mutex_lock(&msgQueueListMutex);
@@ -360,16 +362,22 @@ cprGetMessage (cprMsgQueue_t msgQueue, b
 {
     void *buffer = NULL;
 
 #ifdef SIP_OS_WINDOWS
     struct msgbuffer *rcvMsg = (struct msgbuffer *)rcvBuffer;
     cpr_msg_queue_t *pCprMsgQueue;
     MSG msg;
     cpr_thread_t *pThreadPtr;
+#else
+    cpr_msg_queue_t *msgq = (cpr_msg_queue_t *) msgQueue;
+    cpr_msgq_node_t *node;
+    struct timespec timeout;
+    struct timeval tv;
+    struct timezone tz;
 #endif
 
     if (!msgQueue) {
         CPR_ERROR("%s - invalid msgQueue\n", __FUNCTION__);
         return NULL;
     }
 
     /* Initialize ppUserData */
@@ -439,24 +447,16 @@ cprGetMessage (cprMsgQueue_t msgQueue, b
         case WM_TIMER:
             DispatchMessage(&msg);
             return NULL;
             break;
         default:
             break;
     }
 #else
-    cpr_msg_queue_t *msgq;
-    cpr_msgq_node_t *node;
-    struct timespec timeout;
-    struct timeval tv;
-    struct timezone tz;
-
-    msgq = (cpr_msg_queue_t *) msgQueue;
-
     /*
      * If waitForever is set, block on the message queue
      * until a message is received, else return after
      * 25msec of waiting
      */
     pthread_mutex_lock(&msgq->mutex);
 
     if (!waitForever)
@@ -539,16 +539,22 @@ cprGetMessage (cprMsgQueue_t msgQueue, b
  */
 cprRC_t
 cprSendMessage (cprMsgQueue_t msgQueue, void *msg, void **ppUserData)
 {
 #ifdef SIP_OS_WINDOWS
     struct msgbuffer *sendMsg;
     cpr_thread_t *pCprThread;
     HANDLE *hThread;
+#else
+    static const char error_str[] = "%s: Msg not sent to %s queue: %s\n";
+    cpr_msgq_post_result_e rc;
+    cpr_msg_queue_t *msgq = (cpr_msg_queue_t *) msgQueue;
+    int16_t attemptsToSend = CPR_ATTEMPTS_TO_SEND;
+    uint16_t numAttempts   = 0;
 #endif
 
     if (!msgQueue) {
         CPR_ERROR("%s - msgQueue is NULL\n", __FUNCTION__);
         return CPR_FAILURE;
     }
 
 #ifdef SIP_OS_WINDOWS
@@ -587,24 +593,16 @@ cprSendMessage (cprMsgQueue_t msgQueue, 
         (WPARAM)sendMsg, 0) == 0 ) {
         CPR_ERROR("%s - Msg not sent: %d\n", __FUNCTION__, GetLastError());
         cpr_free(sendMsg);
         return CPR_FAILURE;
     }
     return CPR_SUCCESS;
 
 #else
-    static const char error_str[] = "%s: Msg not sent to %s queue: %s\n";
-    cpr_msgq_post_result_e rc;
-    cpr_msg_queue_t *msgq;
-    int16_t attemptsToSend = CPR_ATTEMPTS_TO_SEND;
-    uint16_t numAttempts   = 0;
-
-    msgq = (cpr_msg_queue_t *) msgQueue;
-
     /*
      * Attempt to send message
      */
     do {
 
         /*
          * Post the message to the Queue
          */
--- a/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCService.cpp
+++ b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCService.cpp
@@ -555,17 +555,17 @@ void CC_SIPCCService::applyLoggingMask (
 // method are not safe except from ccapp_thread.
 void CC_SIPCCService::endAllActiveCalls()
 {
 	CC_DevicePtr device = getActiveDevice();
 	if(device != nullptr)
 	{
 		CC_DeviceInfoPtr deviceInfo = device->getDeviceInfo();
 		vector<CC_CallPtr> calls = deviceInfo->getCalls();
-		CSFLogInfo( logTag, "endAllActiveCalls(): %lu calls to be ended.", calls.size());
+		CSFLogInfo( logTag, "endAllActiveCalls(): %zu calls to be ended.", calls.size());
 		for(vector<CC_CallPtr>::iterator it = calls.begin(); it != calls.end(); it++)
 		{
 			// For each active call, if it can be ended, do so.
 			CC_CallPtr call = *it;
 			CC_CallInfoPtr callInfo = call->getCallInfo();
 			if(callInfo->hasCapability(CC_CallCapabilityEnum::canEndCall))
 			{
 				CSFLogDebug( logTag, "endAllActiveCalls(): ending call %s -> %s [%s]",