Bug 874008 - Check format strings for r_log r=ekr
authorAdam Roach [:abr] <adam@nostrum.com>
Tue, 21 May 2013 09:16:07 +0800
changeset 132476 7571fcebd2a095922062206c5410a3e49a49e785
parent 132475 69a8f7b3a2e22666f53bd40a595d9ab767f2aec3
child 132477 399dc3feb02022fe2c8886335c310757c92b7c41
push id24705
push userryanvm@gmail.com
push dateTue, 21 May 2013 17:24:33 +0000
treeherdermozilla-central@97f49d0b228c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersekr
bugs874008
milestone24.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 874008 - Check format strings for r_log r=ekr
media/mtransport/nr_socket_prsock.cpp
media/mtransport/third_party/nICEr/src/stun/turn_client_ctx.c
media/mtransport/third_party/nrappkit/src/log/r_log.h
--- a/media/mtransport/nr_socket_prsock.cpp
+++ b/media/mtransport/nr_socket_prsock.cpp
@@ -325,17 +325,17 @@ int NrSocket::create(nr_transport_addr *
 
   status = PR_Bind(fd_, &naddr);
   if (status != PR_SUCCESS) {
     r_log(LOG_GENERIC,LOG_CRIT,"Couldn't bind socket to address %s",
           addr->as_string);
     ABORT(R_INTERNAL);
   }
 
-  r_log(LOG_GENERIC,LOG_DEBUG,"Creating socket %d with addr %s",
+  r_log(LOG_GENERIC,LOG_DEBUG,"Creating socket %p with addr %s",
         fd_, addr->as_string);
   nr_transport_addr_copy(&my_addr_,addr);
 
   /* If we have a wildcard port, patch up the addr */
   if(nr_transport_addr_is_wildcard(addr)){
     status = PR_GetSockName(fd_, &naddr);
     if (status != PR_SUCCESS){
       r_log(LOG_GENERIC, LOG_CRIT, "Couldn't get sock name for socket");
--- a/media/mtransport/third_party/nICEr/src/stun/turn_client_ctx.c
+++ b/media/mtransport/third_party/nICEr/src/stun/turn_client_ctx.c
@@ -656,17 +656,17 @@ abort:
 static void nr_turn_client_refresh_cb(NR_SOCKET s, int how, void *arg)
 {
   int r, _status;
   nr_turn_stun_ctx *ctx = (nr_turn_stun_ctx *)arg;
   /* Save lifetime from the reset */
   UINT4 lifetime = ctx->stun->results.refresh_response.lifetime_secs;
 
   r_log(NR_LOG_TURN, LOG_DEBUG, "TURN(%s): Refresh succeeded. lifetime=%u",
-        lifetime);
+        ctx->tctx->label, lifetime);
 
   if ((r=nr_turn_client_start_refresh_timer(
           ctx->tctx, ctx, lifetime)))
     ABORT(r);
 
   _status=0;
 
 abort:
@@ -704,17 +704,18 @@ int nr_turn_client_send_indication(nr_tu
     ABORT(r);
 
   if ((r=nr_stun_encode_message(ind)))
     ABORT(r);
 
   if ((r=nr_socket_sendto(ctx->sock,
                           ind->buffer, ind->length, flags,
                           &ctx->turn_server_addr))) {
-    r_log(NR_LOG_TURN, LOG_ERR, "TURN(%s): Failed sending send indication");
+    r_log(NR_LOG_TURN, LOG_ERR, "TURN(%s): Failed sending send indication",
+          ctx->label);
     ABORT(r);
   }
 
   _status=0;
 abort:
   RFREE(ind);
   return(_status);
 }
@@ -897,19 +898,21 @@ static int nr_turn_permission_find(nr_tu
   }
   *permp = perm;
 
   _status=0;
 abort:
   return(_status);
 }
 
-static void nr_turn_client_permissions_cb(NR_SOCKET s, int how, void *cb)
+static void nr_turn_client_permissions_cb(NR_SOCKET s, int how, void *arg)
 {
-  r_log(NR_LOG_TURN, LOG_DEBUG, "TURN(%s): Successfully refreshed permission");
+  nr_turn_stun_ctx *ctx = (nr_turn_stun_ctx *)arg;
+  r_log(NR_LOG_TURN, LOG_DEBUG, "TURN(%s): Successfully refreshed permission",
+        ctx->tctx->label);
 }
 
 /* Note that we don't destroy the nr_turn_stun_ctx. That is owned by the
    nr_turn_client_ctx. */
 static int nr_turn_permission_destroy(nr_turn_permission **permp)
 {
   nr_turn_permission *perm;
 
--- a/media/mtransport/third_party/nrappkit/src/log/r_log.h
+++ b/media/mtransport/third_party/nrappkit/src/log/r_log.h
@@ -41,23 +41,42 @@
 #define _r_log_h
 
 #ifndef WIN32
 #include <syslog.h>
 #endif
 #include <stdarg.h>
 #include <r_common.h>
 
-int r_log(int facility,int level,const char *fmt,...);
+int r_log(int facility,int level,const char *fmt,...)
+#ifdef __GNUC__
+  __attribute__ ((format (printf, 3, 4)))
+#endif
+;
+
 int r_vlog(int facility,int level,const char *fmt,va_list ap);
 int r_dump(int facility,int level,char *name,char *data,int len);
 
-int r_log_e(int facility,int level,const char *fmt,...);
+int r_log_e(int facility,int level,const char *fmt,...)
+#ifdef __GNUC__
+  __attribute__ ((format (printf, 3, 4)))
+#endif
+;
+
 int r_vlog_e(int facility,int level,const char *fmt,va_list ap);
-int r_log_nr(int facility,int level,int r,const char *fmt,...);
+int r_log_nr(int facility,int level,int r,const char *fmt,...)
+#ifdef __GNUC__
+  __attribute__ ((format (printf, 4, 5)))
+#endif
+;
+
+#ifdef __GNUC__
+#pragma GCC diagnostic error "-Wformat"
+#endif
+
 int r_vlog_nr(int facility,int level,int r,const char *fmt,va_list ap);
 
 int r_log_register(char *tipename,int *facility);
 int r_log_facility(int facility,char **tipename);
 int r_logging(int facility, int level);
 int r_log_init(void);
 
 #define LOG_GENERIC 0