Index: pjproject/trunk/pjlib-util/src/pjlib-util/cli_console.c
===================================================================
--- pjproject/trunk/pjlib-util/src/pjlib-util/cli_console.c	(revision 4727)
+++ pjproject/trunk/pjlib-util/src/pjlib-util/cli_console.c	(revision 4728)
@@ -46,11 +46,11 @@
     pj_thread_t        *input_thread;
     pj_bool_t           thread_quit;
-    pj_sem_t           *thread_sem;   
-    pj_cli_console_cfg  cfg;    
+    pj_sem_t           *thread_sem;
+    pj_cli_console_cfg  cfg;
 
     struct async_input_t
-    {        
+    {
         char       *buf;
-        unsigned    maxlen;	
+        unsigned    maxlen;
         pj_sem_t   *sem;
     } input;
@@ -127,5 +127,5 @@
     if (!pool)
         return PJ_ENOMEM;
-	
+
     sess = PJ_POOL_ZALLOC_T(pool, pj_cli_sess);
     fe = PJ_POOL_ZALLOC_T(pool, struct cli_console_fe);
@@ -136,5 +136,5 @@
     }
     sess->fe = &fe->base;
-    sess->log_level = param->log_level;    
+    sess->log_level = param->log_level;
     sess->op = PJ_POOL_ZALLOC_T(pool, struct pj_cli_sess_op);
     fe->base.op = PJ_POOL_ZALLOC_T(pool, struct pj_cli_front_end_op);
@@ -155,14 +155,14 @@
 
     pj_cli_register_front_end(cli, &fe->base);
-    if (param->prompt_str.slen == 0) {	
+    if (param->prompt_str.slen == 0) {
 	pj_str_t prompt_sign = pj_str(">>> ");
 	fe->cfg.prompt_str.ptr = pj_pool_alloc(fe->pool, prompt_sign.slen+1);
-	pj_strcpy(&fe->cfg.prompt_str, &prompt_sign);	
+	pj_strcpy(&fe->cfg.prompt_str, &prompt_sign);
     } else {
-	fe->cfg.prompt_str.ptr = pj_pool_alloc(fe->pool, 
+	fe->cfg.prompt_str.ptr = pj_pool_alloc(fe->pool,
 					       param->prompt_str.slen+1);
 	pj_strcpy(&fe->cfg.prompt_str, &param->prompt_str);
-    }    
-    fe->cfg.prompt_str.ptr[fe->cfg.prompt_str.slen] = 0; 
+    }
+    fe->cfg.prompt_str.ptr[fe->cfg.prompt_str.slen] = 0;
 
     if (param->quit_command.slen)
@@ -184,5 +184,5 @@
     send_data.ptr = data_str;
     send_data.slen = 0;
-    
+
     pj_strcat(&send_data, &fe->cfg.prompt_str);
     send_data.ptr[send_data.slen] = 0;
@@ -191,6 +191,6 @@
 }
 
-static void send_err_arg(pj_cli_sess *sess, 
-			 const pj_cli_exec_info *info, 
+static void send_err_arg(pj_cli_sess *sess,
+			 const pj_cli_exec_info *info,
 			 const pj_str_t *msg,
 			 pj_bool_t with_return)
@@ -219,8 +219,8 @@
 
     send_data.ptr[send_data.slen] = 0;
-    printf("%s", send_data.ptr);    
-}
-
-static void send_inv_arg(pj_cli_sess *sess, 
+    printf("%s", send_data.ptr);
+}
+
+static void send_inv_arg(pj_cli_sess *sess,
 			 const pj_cli_exec_info *info,
 			 pj_bool_t with_return)
@@ -230,5 +230,5 @@
 }
 
-static void send_too_many_arg(pj_cli_sess *sess, 
+static void send_too_many_arg(pj_cli_sess *sess,
 			      const pj_cli_exec_info *info,
 			      pj_bool_t with_return)
@@ -238,5 +238,5 @@
 }
 
-static void send_hint_arg(pj_str_t *send_data, 
+static void send_hint_arg(pj_str_t *send_data,
 			  const pj_str_t *desc,
 			  pj_ssize_t cmd_len,
@@ -257,5 +257,5 @@
 }
 
-static void send_ambi_arg(pj_cli_sess *sess, 
+static void send_ambi_arg(pj_cli_sess *sess,
 			  const pj_cli_exec_info *info,
 			  pj_bool_t with_return)
@@ -270,10 +270,9 @@
     pj_ssize_t max_length = 0;
     pj_ssize_t cmd_length = 0;
-    const pj_str_t *cmd_desc = 0;
     static const pj_str_t sc_type = {"sc", 2};
     static const pj_str_t choice_type = {"choice", 6};
     send_data.ptr = data;
     send_data.slen = 0;
-    
+
     if (with_return)
 	pj_strcat2(&send_data, "\r\n");
@@ -284,18 +283,18 @@
 	pj_strcat2(&send_data, " ");
     }
-    pj_strcat2(&send_data, "^");        
+    pj_strcat2(&send_data, "^");
     /* Get the max length of the command name */
     for (i=0;i<info->hint_cnt;++i) {
-	if ((&hint[i].type) && (hint[i].type.slen > 0)) {	    
-	    if (pj_stricmp(&hint[i].type, &sc_type) == 0) {		
+	if ((&hint[i].type) && (hint[i].type.slen > 0)) {
+	    if (pj_stricmp(&hint[i].type, &sc_type) == 0) {
 		if ((i > 0) && (!pj_stricmp(&hint[i-1].desc, &hint[i].desc))) {
 		    cmd_length += (hint[i].name.slen + 3);
 		} else {
 		    cmd_length = hint[i].name.slen;
-		}		
+		}
 	    } else {
 		cmd_length = hint[i].name.slen;
 	    }
-	} else {	    	    
+	} else {
 	    cmd_length = hint[i].name.slen;
 	}
@@ -308,5 +307,5 @@
     cmd_length = 0;
     for (i=0;i<info->hint_cnt;++i) {
-	if ((&hint[i].type) && (hint[i].type.slen > 0)) {	    
+	if ((&hint[i].type) && (hint[i].type.slen > 0)) {
 	    if (pj_stricmp(&hint[i].type, &sc_type) == 0) {
 		parse_state = OP_SHORTCUT;
@@ -316,5 +315,5 @@
 		parse_state = OP_TYPE;
 	    }
-	} else {	    	    
+	} else {
 	    parse_state = OP_NORMAL;
 	}
@@ -324,38 +323,37 @@
 	    cmd_length = hint[i].name.slen;
 	}
-    
+
 	switch (parse_state) {
 	case OP_CHOICE:
 	    pj_strcat2(&send_data, "[");
 	    pj_strcat(&send_data, &hint[i].name);
-	    pj_strcat2(&send_data, "]");	
+	    pj_strcat2(&send_data, "]");
 	    break;
 	case OP_TYPE:
 	    pj_strcat2(&send_data, "<");
 	    pj_strcat(&send_data, &hint[i].type);
-	    pj_strcat2(&send_data, ">");	
+	    pj_strcat2(&send_data, ">");
 	    break;
 	case OP_SHORTCUT:
 	    /* Format : "Command | sc |  description" */
-	    {		
+	    {
 		cmd_length += hint[i].name.slen;
 		if ((i > 0) && (!pj_stricmp(&hint[i-1].desc, &hint[i].desc))) {
 		    pj_strcat2(&send_data, " | ");
-		    cmd_length += 3;		    
+		    cmd_length += 3;
 		} else {
 		    pj_strcat2(&send_data, "\r\n  ");
 		}
-		pj_strcat(&send_data, &hint[i].name);	
+		pj_strcat(&send_data, &hint[i].name);
 	    }
 	    break;
 	default:
 	    pj_strcat(&send_data, &hint[i].name);
-	    cmd_desc = &hint[i].desc;
 	    break;
 	}
-    	
-	if ((parse_state == OP_TYPE) || (parse_state == OP_CHOICE) || 
+
+	if ((parse_state == OP_TYPE) || (parse_state == OP_CHOICE) ||
 	    ((i+1) >= info->hint_cnt) ||
-	    (pj_strncmp(&hint[i].desc, &hint[i+1].desc, hint[i].desc.slen))) 
+	    (pj_strncmp(&hint[i].desc, &hint[i+1].desc, hint[i].desc.slen)))
 	{
 	    /* Add description info */
@@ -364,9 +362,9 @@
 	    cmd_length = 0;
 	}
-    }  
+    }
     pj_strcat2(&send_data, "\r\n");
     pj_strcat(&send_data, &fe->cfg.prompt_str);
     send_data.ptr[send_data.slen] = 0;
-    printf("%s", send_data.ptr);    
+    printf("%s", send_data.ptr);
 }
 
@@ -375,5 +373,5 @@
     pj_status_t status;
     pj_bool_t retval = PJ_TRUE;
-    
+
     pj_pool_t *pool;
     pj_cli_cmd_val *cmd_val;
@@ -388,11 +386,11 @@
 
     cmd_val = PJ_POOL_ZALLOC_T(pool, pj_cli_cmd_val);
-    
-    status = pj_cli_sess_parse(sess, recv_buf, cmd_val, 
+
+    status = pj_cli_sess_parse(sess, recv_buf, cmd_val,
 			       pool, &info);
 
     switch (status) {
     case PJ_CLI_EINVARG:
-	send_inv_arg(sess, &info, PJ_TRUE);		
+	send_inv_arg(sess, &info, PJ_TRUE);
 	break;
     case PJ_CLI_ETOOMANYARGS:
@@ -403,16 +401,16 @@
 	send_ambi_arg(sess, &info, PJ_TRUE);
 	break;
-    case PJ_SUCCESS:	
-	if (info.hint_cnt > 0) {	
-	    /* Compelete command */	    
-	    send_ambi_arg(sess, &info, PJ_TRUE);	    		
+    case PJ_SUCCESS:
+	if (info.hint_cnt > 0) {
+	    /* Compelete command */
+	    send_ambi_arg(sess, &info, PJ_TRUE);
 	} else {
 	    retval = PJ_FALSE;
-	}	
-	break;
-    }
-
-    pj_pool_release(pool);	
-    return retval; 
+	}
+	break;
+    }
+
+    pj_pool_release(pool);
+    return retval;
 }
 
@@ -421,23 +419,23 @@
     pj_status_t status;
     pj_bool_t retval = PJ_TRUE;
-    
-    pj_pool_t *pool;    
+
+    pj_pool_t *pool;
     pj_cli_exec_info info;
     pj_cli_t *cli = sess->fe->cli;
     struct cli_console_fe *fe = (struct cli_console_fe *)sess->fe;
     char *recv_buf = fe->input.buf;
-        
+
     printf("\r\n");
 
     pool = pj_pool_create(pj_cli_get_param(cli)->pf, "handle_exec",
 			  PJ_CLI_CONSOLE_POOL_SIZE, PJ_CLI_CONSOLE_POOL_INC,
-			  NULL);    
-    
-    status = pj_cli_sess_exec(sess, recv_buf, 
+			  NULL);
+
+    status = pj_cli_sess_exec(sess, recv_buf,
 			      pool, &info);
 
     switch (status) {
     case PJ_CLI_EINVARG:
-	send_inv_arg(sess, &info, PJ_FALSE);	
+	send_inv_arg(sess, &info, PJ_FALSE);
 	break;
     case PJ_CLI_ETOOMANYARGS:
@@ -452,14 +450,14 @@
 	break;
     case PJ_SUCCESS:
-	send_prompt_str(sess);	
-	break;
-    }    
-
-    pj_pool_release(pool);	
-    return retval; 
+	send_prompt_str(sess);
+	break;
+    }
+
+    pj_pool_release(pool);
+    return retval;
 }
 
 static int readline_thread(void * p)
-{    
+{
     struct cli_console_fe * fe = (struct cli_console_fe *)p;
 
@@ -473,5 +471,5 @@
 
 	if (fgets(recv_buf, fe->input.maxlen, stdin) == NULL) {
-	    /* 
+	    /*
 	     * Be friendly to users who redirect commands into
 	     * program, when file ends, resume with kbd.
@@ -488,8 +486,8 @@
 		puts("Cannot switch back to console from file redirection");
 		if (fe->cfg.quit_command.slen) {
-		    pj_memcpy(recv_buf, fe->cfg.quit_command.ptr, 
+		    pj_memcpy(recv_buf, fe->cfg.quit_command.ptr,
 			      fe->input.maxlen);
 		}
-		recv_buf[fe->cfg.quit_command.slen] = '\0';		
+		recv_buf[fe->cfg.quit_command.slen] = '\0';
 	    } else {
 		puts("Switched back to console from file redirection");
@@ -506,5 +504,5 @@
 	    break;
 	}
-	input_len = pj_ansi_strlen(fe->input.buf);	
+	input_len = pj_ansi_strlen(fe->input.buf);
 	if ((input_len > 1) && (fe->input.buf[input_len-2] == '?')) {
 	    fe->input.buf[input_len-1] = 0;
@@ -516,12 +514,12 @@
 	}
 
-        pj_sem_post(fe->input.sem);        
+        pj_sem_post(fe->input.sem);
         pj_sem_wait(fe->thread_sem);
-    }    
+    }
 
     return 0;
 }
 
-PJ_DEF(pj_status_t) pj_cli_console_process(pj_cli_sess *sess, 
+PJ_DEF(pj_status_t) pj_cli_console_process(pj_cli_sess *sess,
 					   char *buf,
 					   unsigned maxlen)
Index: pjproject/trunk/pjlib-util/src/pjlib-util/cli_telnet.c
===================================================================
--- pjproject/trunk/pjlib-util/src/pjlib-util/cli_telnet.c	(revision 4727)
+++ pjproject/trunk/pjlib-util/src/pjlib-util/cli_telnet.c	(revision 4728)
@@ -37,5 +37,5 @@
     (defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0)
 
-#define EADDRINUSE WSAEADDRINUSE 
+#define EADDRINUSE WSAEADDRINUSE
 
 #endif
@@ -67,11 +67,11 @@
  * This specify the state for the telnet option negotiation.
  */
-enum cli_telnet_option_states 
-{    
+enum cli_telnet_option_states
+{
     OPT_DISABLE,		/* Option disable */
     OPT_ENABLE,			/* Option enable */
     OPT_EXPECT_DISABLE,		/* Already send disable req, expecting resp */
     OPT_EXPECT_ENABLE,		/* Already send enable req, expecting resp */
-    OPT_EXPECT_DISABLE_REV,	/* Already send disable req, expecting resp, 
+    OPT_EXPECT_DISABLE_REV,	/* Already send disable req, expecting resp,
 				 * need to send enable req */
     OPT_EXPECT_ENABLE_REV	/* Already send enable req, expecting resp,
@@ -199,5 +199,5 @@
 };
 
-enum terminal_cmd 
+enum terminal_cmd
 {
     TC_ESC		= 27,
@@ -207,5 +207,5 @@
     TC_LEFT		= 68,
     TC_END		= 70,
-    TC_HOME		= 72,    
+    TC_HOME		= 72,
     TC_CTRL_C		= 3,
     TC_CR		= 13,
@@ -229,6 +229,6 @@
 
 /**
- * This structure contains the command line shown to the user. 
- * The telnet also needs to maintain and manage command cursor position. 
+ * This structure contains the command line shown to the user.
+ * The telnet also needs to maintain and manage command cursor position.
  * Due to that reason, the insert/delete character process from buffer will
  * consider its current cursor position.
@@ -252,5 +252,5 @@
 
 /**
- * This structure contains the command history executed by user. 
+ * This structure contains the command history executed by user.
  * Besides storing the command history, it is necessary to be able
  * to browse it.
@@ -291,5 +291,5 @@
     pj_thread_t            *worker_thread;
     pj_bool_t               is_quitting;
-    pj_mutex_t             *mutex;    
+    pj_mutex_t             *mutex;
 } cli_telnet_fe;
 
@@ -305,5 +305,5 @@
 
 /**
- * Return the number of characters between the current cursor position 
+ * Return the number of characters between the current cursor position
  * to the end of line.
  */
@@ -314,12 +314,12 @@
 
 /**
- * Insert character to the receive buffer. 
- */
-static pj_bool_t recv_buf_insert(telnet_recv_buf *recv_buf, 
-				 unsigned char *data) 
-{    
+ * Insert character to the receive buffer.
+ */
+static pj_bool_t recv_buf_insert(telnet_recv_buf *recv_buf,
+				 unsigned char *data)
+{
     if (recv_buf->len+1 >= PJ_CLI_MAX_CMDBUF) {
 	return PJ_FALSE;
-    } else {	
+    } else {
 	if (*data == '\t' || *data == '?' || *data == '\r') {
 	    /* Always insert to the end of line */
@@ -328,11 +328,11 @@
 	    /* Insert based on the current cursor pos */
 	    unsigned cur_pos = recv_buf->cur_pos;
-	    unsigned rlen = recv_buf_right_len(recv_buf);	    
-	    if (rlen > 0) {		    
+	    unsigned rlen = recv_buf_right_len(recv_buf);
+	    if (rlen > 0) {
 		/* Shift right characters */
-		pj_memmove(&recv_buf->rbuf[cur_pos+1], 
-			   &recv_buf->rbuf[cur_pos], 
+		pj_memmove(&recv_buf->rbuf[cur_pos+1],
+			   &recv_buf->rbuf[cur_pos],
 			   rlen+1);
-	    } 
+	    }
 	    recv_buf->rbuf[cur_pos] = *data;
 	}
@@ -356,5 +356,5 @@
 	    unsigned cur_pos = recv_buf->cur_pos;
 	    /* Shift left characters */
-	    pj_memmove(&recv_buf->rbuf[cur_pos-1], &recv_buf->rbuf[cur_pos], 
+	    pj_memmove(&recv_buf->rbuf[cur_pos-1], &recv_buf->rbuf[cur_pos],
 		       rlen);
 	}
@@ -362,5 +362,5 @@
 	--recv_buf->len;
 	recv_buf->rbuf[recv_buf->len] = 0;
-    }    
+    }
     return PJ_TRUE;
 }
@@ -373,9 +373,9 @@
 
 /**
- * Insert the command to history. If the entered command is not on the list, 
- * a new entry will be created. All entered command will be moved to 
- * the first entry of the history. 
- */
-static pj_status_t insert_history(cli_telnet_sess *sess, 				 
+ * Insert the command to history. If the entered command is not on the list,
+ * a new entry will be created. All entered command will be moved to
+ * the first entry of the history.
+ */
+static pj_status_t insert_history(cli_telnet_sess *sess,
 				  char *cmd_val)
 {
@@ -393,9 +393,9 @@
     in_history = pj_list_search(sess->history, (void*)&cmd, compare_str);
     if (!in_history) {
-	if (pj_list_size(sess->history) < PJ_CLI_MAX_CMD_HISTORY) {	    
+	if (pj_list_size(sess->history) < PJ_CLI_MAX_CMD_HISTORY) {
 	    char *data_history;
 	    in_history = PJ_POOL_ZALLOC_T(sess->pool, cmd_history);
 	    pj_list_init(in_history);
-	    data_history = (char *)pj_pool_calloc(sess->pool, 
+	    data_history = (char *)pj_pool_calloc(sess->pool,
 			   sizeof(char), PJ_CLI_MAX_CMDBUF);
 	    in_history->command.ptr = data_history;
@@ -404,5 +404,5 @@
 	    /* Get the oldest history */
 	    in_history = sess->history->prev;
-	}	    
+	}
     } else {
 	pj_list_insert_nodes_after(in_history->prev, in_history->next);
@@ -416,5 +416,5 @@
 
 /**
- * Get the next or previous history of the shown/active history. 
+ * Get the next or previous history of the shown/active history.
  */
 static pj_str_t* get_prev_history(cli_telnet_sess *sess, pj_bool_t is_forward)
@@ -434,8 +434,8 @@
 	return NULL;
     } else {
-	if (is_forward) {	    
-	    node = (node->next==root)?node->next->next:node->next;	    
+	if (is_forward) {
+	    node = (node->next==root)?node->next->next:node->next;
 	} else {
-	    node = (node->prev==root)?node->prev->prev:node->prev;	    
+	    node = (node->prev==root)?node->prev->prev:node->prev;
 	}
 	retval = &node->command;
@@ -451,8 +451,8 @@
  * referenced - (RFC-854).
  */
-static pj_bool_t send_telnet_cmd(cli_telnet_sess *sess, 
-				 cli_telnet_command cmd, 
+static pj_bool_t send_telnet_cmd(cli_telnet_sess *sess,
+				 cli_telnet_command cmd,
 				 unsigned char option)
-{       
+{
     unsigned char buf[3];
     PJ_ASSERT_RETURN(sess, PJ_FALSE);
@@ -470,9 +470,9 @@
  * For local option: send WILL.
  * For remote option: send DO.
- * This method also handle the state transition of the ENABLE 
+ * This method also handle the state transition of the ENABLE
  * negotiation process.
  */
-static pj_bool_t send_enable_option(cli_telnet_sess *sess, 
-				    pj_bool_t is_local, 
+static pj_bool_t send_enable_option(cli_telnet_sess *sess,
+				    pj_bool_t is_local,
 				    unsigned char option)
 {
@@ -500,5 +500,5 @@
 	    *state = OPT_EXPECT_ENABLE;
 	    break;
-	case OPT_EXPECT_DISABLE_REV:	    
+	case OPT_EXPECT_DISABLE_REV:
 	    *state = OPT_DISABLE;
 	    break;
@@ -509,5 +509,5 @@
 }
 
-static pj_bool_t send_cmd_do(cli_telnet_sess *sess, 
+static pj_bool_t send_cmd_do(cli_telnet_sess *sess,
 			     unsigned char option)
 {
@@ -515,5 +515,5 @@
 }
 
-static pj_bool_t send_cmd_will(cli_telnet_sess *sess, 
+static pj_bool_t send_cmd_will(cli_telnet_sess *sess,
 			       unsigned char option)
 {
@@ -523,9 +523,9 @@
 /**
  * This method will handle receiving telnet's ENABLE option negotiation.
- * This method also handle the state transition of the ENABLE 
- * negotiation process. 
- */
-static pj_bool_t receive_enable_option(cli_telnet_sess *sess, 
-				       pj_bool_t is_local, 
+ * This method also handle the state transition of the ENABLE
+ * negotiation process.
+ */
+static pj_bool_t receive_enable_option(cli_telnet_sess *sess,
+				       pj_bool_t is_local,
 				       unsigned char option)
 {
@@ -550,13 +550,13 @@
 	    }
 	    break;
-	case OPT_EXPECT_ENABLE:	    
+	case OPT_EXPECT_ENABLE:
 	    *state = OPT_ENABLE;
 	    break;
-	case OPT_EXPECT_DISABLE:	    
+	case OPT_EXPECT_DISABLE:
 	    *state = OPT_DISABLE;
 	    break;
 	case OPT_EXPECT_ENABLE_REV:
 	    *state = OPT_EXPECT_DISABLE;
-	    send_telnet_cmd(sess, is_local?WONT:DONT, option);	    
+	    send_telnet_cmd(sess, is_local?WONT:DONT, option);
 	    break;
 	case OPT_EXPECT_DISABLE_REV:
@@ -566,14 +566,14 @@
 	    return PJ_FALSE;
     }
-    return PJ_TRUE;        
+    return PJ_TRUE;
 }
 
 /**
  * This method will handle receiving telnet's DISABLE option negotiation.
- * This method also handle the state transition of the DISABLE 
- * negotiation process. 
- */
-static pj_bool_t receive_disable_option(cli_telnet_sess *sess, 
-					pj_bool_t is_local, 
+ * This method also handle the state transition of the DISABLE
+ * negotiation process.
+ */
+static pj_bool_t receive_disable_option(cli_telnet_sess *sess,
+					pj_bool_t is_local,
 					unsigned char option)
 {
@@ -585,5 +585,5 @@
     sess_opt = &sess->telnet_option[option];
     state = is_local?(&sess_opt->local_state):(&sess_opt->peer_state);
-    
+
     switch (*state) {
 	case OPT_ENABLE:
@@ -595,5 +595,5 @@
 	    /* Ignore if already enabled */
 	    break;
-	case OPT_EXPECT_ENABLE:	    
+	case OPT_EXPECT_ENABLE:
 	case OPT_EXPECT_DISABLE:
 	    *state = OPT_DISABLE;
@@ -601,5 +601,5 @@
 	case OPT_EXPECT_ENABLE_REV:
 	    *state = OPT_DISABLE;
-	    send_telnet_cmd(sess, is_local?WONT:DONT, option);	    
+	    send_telnet_cmd(sess, is_local?WONT:DONT, option);
 	    break;
 	case OPT_EXPECT_DISABLE_REV:
@@ -610,5 +610,5 @@
 	    return PJ_FALSE;
     }
-    return PJ_TRUE;       
+    return PJ_TRUE;
 }
 
@@ -633,26 +633,26 @@
 }
 
-static void set_local_option(cli_telnet_sess *sess, 
-			     unsigned char option, 
-			     pj_bool_t enable) 
+static void set_local_option(cli_telnet_sess *sess,
+			     unsigned char option,
+			     pj_bool_t enable)
 {
     sess->telnet_option[option].local_is_enable = enable;
 }
 
-static void set_peer_option(cli_telnet_sess *sess, 
-			    unsigned char option, 
-			    pj_bool_t enable) 
+static void set_peer_option(cli_telnet_sess *sess,
+			    unsigned char option,
+			    pj_bool_t enable)
 {
     sess->telnet_option[option].peer_is_enable = enable;
 }
 
-static pj_bool_t is_local_option_state_ena(cli_telnet_sess *sess, 
+static pj_bool_t is_local_option_state_ena(cli_telnet_sess *sess,
 					   unsigned char option)
-{    
+{
     return (sess->telnet_option[option].local_state == OPT_ENABLE);
 }
 
-static void send_return_key(cli_telnet_sess *sess) 
-{    
+static void send_return_key(cli_telnet_sess *sess)
+{
     telnet_sess_send2(sess, (unsigned char*)"\r\n", 2);
 }
@@ -671,5 +671,5 @@
     send_data.ptr = data_str;
     send_data.slen = 0;
-    
+
     pj_strcat(&send_data, &fe->cfg.prompt_str);
 
@@ -681,6 +681,6 @@
  * the error position of the source command.
  */
-static void send_err_arg(cli_telnet_sess *sess, 
-			 const pj_cli_exec_info *info, 
+static void send_err_arg(cli_telnet_sess *sess,
+			 const pj_cli_exec_info *info,
 			 const pj_str_t *msg,
 			 pj_bool_t with_return,
@@ -715,5 +715,5 @@
 }
 
-static void send_inv_arg(cli_telnet_sess *sess, 
+static void send_inv_arg(cli_telnet_sess *sess,
 			 const pj_cli_exec_info *info,
 			 pj_bool_t with_return,
@@ -724,5 +724,5 @@
 }
 
-static void send_too_many_arg(cli_telnet_sess *sess, 
+static void send_too_many_arg(cli_telnet_sess *sess,
 			      const pj_cli_exec_info *info,
 			      pj_bool_t with_return,
@@ -733,6 +733,6 @@
 }
 
-static void send_hint_arg(cli_telnet_sess *sess, 
-			  pj_str_t *send_data, 
+static void send_hint_arg(cli_telnet_sess *sess,
+			  pj_str_t *send_data,
 			  const pj_str_t *desc,
 			  pj_ssize_t cmd_len,
@@ -756,5 +756,5 @@
  * is ambiguous. It will show the matching command as the hint information.
  */
-static void send_ambi_arg(cli_telnet_sess *sess, 
+static void send_ambi_arg(cli_telnet_sess *sess,
 			  const pj_cli_exec_info *info,
 			  pj_bool_t with_return,
@@ -770,10 +770,9 @@
     pj_ssize_t max_length = 0;
     pj_ssize_t cmd_length = 0;
-    const pj_str_t *cmd_desc = 0;
     static const pj_str_t sc_type = {"sc", 2};
     static const pj_str_t choice_type = {"choice", 6};
     send_data.ptr = data;
     send_data.slen = 0;
-    
+
     if (with_return)
 	pj_strcat2(&send_data, "\r\n");
@@ -787,15 +786,15 @@
     /* Get the max length of the command name */
     for (i=0;i<info->hint_cnt;++i) {
-	if ((&hint[i].type) && (hint[i].type.slen > 0)) {	    
-	    if (pj_stricmp(&hint[i].type, &sc_type) == 0) {		
+	if ((&hint[i].type) && (hint[i].type.slen > 0)) {
+	    if (pj_stricmp(&hint[i].type, &sc_type) == 0) {
 		if ((i > 0) && (!pj_stricmp(&hint[i-1].desc, &hint[i].desc))) {
 		    cmd_length += (hint[i].name.slen + 3);
 		} else {
 		    cmd_length = hint[i].name.slen;
-		}		
+		}
 	    } else {
 		cmd_length = hint[i].name.slen;
 	    }
-	} else {	    	    
+	} else {
 	    cmd_length = hint[i].name.slen;
 	}
@@ -805,9 +804,9 @@
 	}
     }
-    
+
     cmd_length = 0;
     /* Build hint information */
-    for (i=0;i<info->hint_cnt;++i) {			
-	if ((&hint[i].type) && (hint[i].type.slen > 0)) {	    
+    for (i=0;i<info->hint_cnt;++i) {
+	if ((&hint[i].type) && (hint[i].type.slen > 0)) {
 	    if (pj_stricmp(&hint[i].type, &sc_type) == 0) {
 		parse_state = OP_SHORTCUT;
@@ -817,19 +816,19 @@
 		parse_state = OP_TYPE;
 	    }
-	} else {	    	    
+	} else {
 	    parse_state = OP_NORMAL;
 	}
-	
+
 	if (parse_state != OP_SHORTCUT) {
 	    pj_strcat2(&send_data, "\r\n  ");
 	    cmd_length = hint[i].name.slen;
-	}	    
-	
+	}
+
 	switch (parse_state) {
 	case OP_CHOICE:
-	    /* Format : "[Choice Value]  description" */	    
+	    /* Format : "[Choice Value]  description" */
 	    pj_strcat2(&send_data, "[");
 	    pj_strcat(&send_data, &hint[i].name);
-	    pj_strcat2(&send_data, "]");	
+	    pj_strcat2(&send_data, "]");
 	    break;
 	case OP_TYPE:
@@ -837,17 +836,17 @@
 	    pj_strcat2(&send_data, "<");
 	    pj_strcat(&send_data, &hint[i].name);
-	    pj_strcat2(&send_data, ">");	
+	    pj_strcat2(&send_data, ">");
 	    break;
 	case OP_SHORTCUT:
 	    /* Format : "Command | sc |  description" */
-	    {		
+	    {
 		cmd_length += hint[i].name.slen;
 		if ((i > 0) && (!pj_stricmp(&hint[i-1].desc, &hint[i].desc))) {
 		    pj_strcat2(&send_data, " | ");
-		    cmd_length += 3;		    
+		    cmd_length += 3;
 		} else {
 		    pj_strcat2(&send_data, "\r\n  ");
 		}
-		pj_strcat(&send_data, &hint[i].name);	
+		pj_strcat(&send_data, &hint[i].name);
 	    }
 	    break;
@@ -855,26 +854,25 @@
 	    /* Command */
 	    pj_strcat(&send_data, &hint[i].name);
-	    cmd_desc = &hint[i].desc;	    
-	    break;
-	}
-    	
-	if ((parse_state == OP_TYPE) || (parse_state == OP_CHOICE) || 
+	    break;
+	}
+
+	if ((parse_state == OP_TYPE) || (parse_state == OP_CHOICE) ||
 	    ((i+1) >= info->hint_cnt) ||
-	    (pj_strncmp(&hint[i].desc, &hint[i+1].desc, hint[i].desc.slen))) 
+	    (pj_strncmp(&hint[i].desc, &hint[i+1].desc, hint[i].desc.slen)))
 	{
 	    /* Add description info */
-	    send_hint_arg(sess, &send_data, 
-			  &hint[i].desc, cmd_length, 
+	    send_hint_arg(sess, &send_data,
+			  &hint[i].desc, cmd_length,
 			  max_length);
 
 	    cmd_length = 0;
-	}	
-    }  
-    pj_strcat2(&send_data, "\r\n");       
+	}
+    }
+    pj_strcat2(&send_data, "\r\n");
     pj_strcat(&send_data, &fe->cfg.prompt_str);
     if (with_last_cmd)
 	pj_strcat2(&send_data, (char *)sess->rcmd->rbuf);
 
-    telnet_sess_send(sess, &send_data);    
+    telnet_sess_send(sess, &send_data);
 }
 
@@ -882,5 +880,5 @@
  * This method is to send command completion of the entered command.
  */
-static void send_comp_arg(cli_telnet_sess *sess, 
+static void send_comp_arg(cli_telnet_sess *sess,
 			  pj_cli_exec_info *info)
 {
@@ -893,5 +891,5 @@
     send_data.slen = 0;
 
-    pj_strcat(&send_data, &info->hint[0].name);        
+    pj_strcat(&send_data, &info->hint[0].name);
 
     telnet_sess_send(sess, &send_data);
@@ -902,8 +900,8 @@
  */
 static pj_bool_t handle_alfa_num(cli_telnet_sess *sess, unsigned char *data)
-{        
+{
     if (is_local_option_state_ena(sess, TERM_ECHO)) {
 	if (recv_buf_right_len(sess->rcmd) > 0) {
-	    /* Cursor is not at EOL, insert character */	    
+	    /* Cursor is not at EOL, insert character */
 	    unsigned char echo[5] = {0x1b, 0x5b, 0x31, 0x40, 0x00};
 	    echo[4] = *data;
@@ -914,5 +912,5 @@
 	}
 	return PJ_TRUE;
-    } 
+    }
     return PJ_FALSE;
 }
@@ -926,6 +924,6 @@
     if (recv_buf_backspace(sess->rcmd)) {
 	if (rlen) {
-	    /* 
-	     * Cursor is not at the end of line, move the characters 
+	    /*
+	     * Cursor is not at the end of line, move the characters
 	     * after the cursor to left
 	     */
@@ -934,5 +932,5 @@
 	    telnet_sess_send2(sess, echo, 5);
 	} else {
-	    const static unsigned char echo[3] = {0x08, 0x20, 0x08};	    
+	    const static unsigned char echo[3] = {0x08, 0x20, 0x08};
 	    telnet_sess_send2(sess, echo, 3);
 	}
@@ -942,6 +940,6 @@
 }
 
-/* 
- * Syntax error handler for parser. 
+/*
+ * Syntax error handler for parser.
  */
 static void on_syntax_error(pj_scanner *scanner)
@@ -958,5 +956,5 @@
     pj_scanner scanner;
     PJ_USE_EXCEPTION;
-    pj_scan_init(&scanner, cmd->ptr, cmd->slen, PJ_SCAN_AUTOSKIP_WS, 
+    pj_scan_init(&scanner, cmd->ptr, cmd->slen, PJ_SCAN_AUTOSKIP_WS,
 		 &on_syntax_error);
     PJ_TRY {
@@ -966,5 +964,5 @@
     }
     PJ_CATCH_ANY {
-	pj_scan_fini(&scanner);	
+	pj_scan_fini(&scanner);
 	return PJ_GET_EXCEPTION();
     }
@@ -981,5 +979,5 @@
     pj_bool_t retval = PJ_TRUE;
     unsigned len;
-    
+
     pj_pool_t *pool;
     pj_cli_cmd_val *cmd_val;
@@ -990,7 +988,7 @@
 
     cmd_val = PJ_POOL_ZALLOC_T(pool, pj_cli_cmd_val);
-    
-    status = pj_cli_sess_parse(&sess->base, (char *)&sess->rcmd->rbuf, cmd_val, 
-			       pool, &info);    
+
+    status = pj_cli_sess_parse(&sess->base, (char *)&sess->rcmd->rbuf, cmd_val,
+			       pool, &info);
 
     len = (unsigned)pj_ansi_strlen((char *)sess->rcmd->rbuf);
@@ -998,5 +996,5 @@
     switch (status) {
     case PJ_CLI_EINVARG:
-	send_inv_arg(sess, &info, PJ_TRUE, PJ_TRUE);		
+	send_inv_arg(sess, &info, PJ_TRUE, PJ_TRUE);
 	break;
     case PJ_CLI_ETOOMANYARGS:
@@ -1015,5 +1013,5 @@
 	    telnet_sess_send2(sess, data_sent, rlen);
 	}
-	if (info.hint_cnt > 0) {	
+	if (info.hint_cnt > 0) {
 	    /* Complete command */
 	    pj_str_t cmd = pj_str((char *)sess->rcmd->rbuf);
@@ -1026,15 +1024,15 @@
 		if (hint_info->slen >= last_token.slen) {
 		    hint_info->slen -= last_token.slen;
-		    pj_memmove(hint_info->ptr, 
-			       &hint_info->ptr[last_token.slen], 
-			       hint_info->slen);		    
-		} 
+		    pj_memmove(hint_info->ptr,
+			       &hint_info->ptr[last_token.slen],
+			       hint_info->slen);
+		}
 		send_comp_arg(sess, &info);
 
-		pj_memcpy(&sess->rcmd->rbuf[len], info.hint[0].name.ptr, 
+		pj_memcpy(&sess->rcmd->rbuf[len], info.hint[0].name.ptr,
 			  info.hint[0].name.slen);
 
 		len += (unsigned)info.hint[0].name.slen;
-		sess->rcmd->rbuf[len] = 0;		    
+		sess->rcmd->rbuf[len] = 0;
 	    }
 	} else {
@@ -1046,6 +1044,6 @@
     sess->rcmd->cur_pos = sess->rcmd->len;
 
-    pj_pool_release(pool);	
-    return retval; 
+    pj_pool_release(pool);
+    return retval;
 }
 
@@ -1057,8 +1055,8 @@
     pj_status_t status;
     pj_bool_t retval = PJ_TRUE;
-    
-    pj_pool_t *pool;    
-    pj_cli_exec_info info;    
-    
+
+    pj_pool_t *pool;
+    pj_cli_exec_info info;
+
     send_return_key(sess);
     insert_history(sess, (char *)&sess->rcmd->rbuf);
@@ -1066,12 +1064,12 @@
     pool = pj_pool_create(sess->pool->factory, "handle_return",
 			  PJ_CLI_TELNET_POOL_SIZE, PJ_CLI_TELNET_POOL_INC,
-			  NULL);    
-    
-    status = pj_cli_sess_exec(&sess->base, (char *)&sess->rcmd->rbuf, 
+			  NULL);
+
+    status = pj_cli_sess_exec(&sess->base, (char *)&sess->rcmd->rbuf,
 			      pool, &info);
 
     switch (status) {
     case PJ_CLI_EINVARG:
-	send_inv_arg(sess, &info, PJ_FALSE, PJ_FALSE);	
+	send_inv_arg(sess, &info, PJ_FALSE, PJ_FALSE);
 	break;
     case PJ_CLI_ETOOMANYARGS:
@@ -1088,5 +1086,5 @@
 	send_prompt_str(sess);
 	break;
-    }    
+    }
     if (retval) {
 	sess->rcmd->rbuf[0] = 0;
@@ -1095,6 +1093,6 @@
     }
 
-    pj_pool_release(pool);	
-    return retval; 
+    pj_pool_release(pool);
+    return retval;
 }
 
@@ -1106,5 +1104,5 @@
     if (recv_buf_right_len(sess->rcmd)) {
 	unsigned char *data = &sess->rcmd->rbuf[sess->rcmd->cur_pos++];
-	telnet_sess_send2(sess, data, 1);		
+	telnet_sess_send2(sess, data, 1);
 	return PJ_TRUE;
     }
@@ -1116,5 +1114,5 @@
  */
 static pj_bool_t handle_left_key(cli_telnet_sess *sess)
-{    
+{
     static const unsigned char move_cursor_left = 0x08;
     if (sess->rcmd->cur_pos) {
@@ -1151,5 +1149,5 @@
 	    send_data.slen = sess->rcmd->cur_pos;
 	}
-	
+
 	if (sess->rcmd->len > (unsigned)history->slen) {
 	    /* Clear the command currently shown*/
@@ -1159,8 +1157,8 @@
 
 	    /* Move cursor position to the beginning of line */
-	    pj_memset(&send_data.ptr[send_data.slen], MOVE_CURSOR_LEFT, 
+	    pj_memset(&send_data.ptr[send_data.slen], MOVE_CURSOR_LEFT,
 		      buf_len);
 	    send_data.slen += buf_len;
-	} 
+	}
 	/* Send data */
 	pj_strcat(&send_data, history);
@@ -1175,7 +1173,7 @@
 }
 
-static pj_status_t process_vt100_cmd(cli_telnet_sess *sess, 
+static pj_status_t process_vt100_cmd(cli_telnet_sess *sess,
 				     unsigned char *cmd)
-{    
+{
     pj_status_t status = PJ_TRUE;
     switch (*cmd) {
@@ -1225,6 +1223,6 @@
 }
 
-/* 
- * Send a message to a telnet session 
+/*
+ * Send a message to a telnet session
  */
 static pj_status_t telnet_sess_send(cli_telnet_sess *sess,
@@ -1241,10 +1239,10 @@
 
     if (sess->buf_len == 0)
-        status = pj_activesock_send(sess->asock, &sess->op_key, 
+        status = pj_activesock_send(sess->asock, &sess->op_key,
                                     str->ptr, &sz, 0);
-    /* If we cannot send now, append it at the end of the buffer 
+    /* If we cannot send now, append it at the end of the buffer
      * to be sent later.
      */
-    if (sess->buf_len > 0 || 
+    if (sess->buf_len > 0 ||
         (status != PJ_SUCCESS && status != PJ_EPENDING))
     {
@@ -1273,6 +1271,6 @@
 }
 
-/* 
- * Send a message to a telnet session with formatted text 
+/*
+ * Send a message to a telnet session with formatted text
  * (add single linefeed character with carriage return)
  */
@@ -1288,18 +1286,18 @@
     PJ_USE_EXCEPTION;
 
-    pj_scan_init(&scanner, str->ptr, str->slen, 
+    pj_scan_init(&scanner, str->ptr, str->slen,
 	         PJ_SCAN_AUTOSKIP_WS, &on_syntax_error);
-    
+
     str_begin = scanner.begin;
 
     PJ_TRY {
-	while (!pj_scan_is_eof(&scanner)) {	    	    
-	    pj_scan_get_until_ch(&scanner, '\n', &out_str);	    
+	while (!pj_scan_is_eof(&scanner)) {
+	    pj_scan_get_until_ch(&scanner, '\n', &out_str);
 	    str_len = (int)(scanner.curptr - str_begin);
-	    if (*scanner.curptr == '\n') {		
-		if ((str_len > 1) && (out_str.ptr[str_len-2] == '\r')) 
-		{	    		    
+	    if (*scanner.curptr == '\n') {
+		if ((str_len > 1) && (out_str.ptr[str_len-2] == '\r'))
+		{
 		    continue;
-		} else {		    
+		} else {
 		    int str_pos = (int)(str_begin - scanner.begin);
 
@@ -1314,5 +1312,5 @@
 			pj_scan_advance_n(&scanner, 1, PJ_TRUE);
 			str_begin = scanner.curptr;
-		    }		    
+		    }
 		}
 	    } else {
@@ -1355,5 +1353,5 @@
     pj_mutex_unlock(tsess->smutex);
     pj_activesock_close(tsess->asock);
-    pj_mutex_destroy(tsess->smutex);    
+    pj_mutex_destroy(tsess->smutex);
     pj_pool_release(tsess->pool);
 }
@@ -1363,5 +1361,5 @@
 {
     cli_telnet_fe *tfe = (cli_telnet_fe *)fe;
-    pj_cli_sess *sess;    
+    pj_cli_sess *sess;
 
     pj_mutex_lock(tfe->mutex);
@@ -1371,5 +1369,5 @@
         cli_telnet_sess *tsess = (cli_telnet_sess *)sess;
 
-        sess = sess->next;        
+        sess = sess->next;
 	if (tsess->base.log_level > level) {
 	    pj_str_t s;
@@ -1379,5 +1377,5 @@
 	}
     }
-    
+
     pj_mutex_unlock(tfe->mutex);
 }
@@ -1436,5 +1434,5 @@
 			    pj_activesock_get_user_data(asock);
 
-    PJ_UNUSED_ARG(op_key);    
+    PJ_UNUSED_ARG(op_key);
 
     if (sent <= 0) {
@@ -1471,5 +1469,5 @@
                             pj_activesock_get_user_data(asock);
     cli_telnet_fe *tfe = (cli_telnet_fe *)sess->base.fe;
-    unsigned char *cdata = (unsigned char*)data;    
+    unsigned char *cdata = (unsigned char*)data;
     pj_status_t is_valid = PJ_TRUE;
 
@@ -1483,5 +1481,5 @@
 	TRACE_((THIS_FILE, "Error on data read %d", status));
         return PJ_FALSE;
-    }    
+    }
 
     pj_mutex_lock(sess->smutex);
@@ -1490,10 +1488,10 @@
 	case ST_CR:
 	    sess->parse_state = ST_NORMAL;
-	    if (*cdata == 0 || *cdata == '\n')				
+	    if (*cdata == 0 || *cdata == '\n')
 		pj_mutex_unlock(sess->smutex);
 		is_valid = handle_return(sess);
-		if (!is_valid)		    
+		if (!is_valid)
 		    return PJ_FALSE;
-		pj_mutex_lock(sess->smutex);	
+		pj_mutex_lock(sess->smutex);
 		break;
 	case ST_NORMAL:
@@ -1502,7 +1500,7 @@
 	    } else if (*cdata == 127) {
 		is_valid = handle_backspace(sess, cdata);
-	    } else if (*cdata == 27) {		    
+	    } else if (*cdata == 27) {
 		sess->parse_state = ST_ESC;
-	    } else { 
+	    } else {
 		if (recv_buf_insert(sess->rcmd, cdata)) {
 		    if (*cdata == '\r') {
@@ -1519,5 +1517,5 @@
 	    break;
 	case ST_ESC:
-	    if (*cdata == 91) {		
+	    if (*cdata == 91) {
 		sess->parse_state = ST_VT100;
 	    } else {
@@ -1598,9 +1596,9 @@
     if (status != PJ_SUCCESS && status != PJ_EPENDING) {
 	TRACE_((THIS_FILE, "Error on data accept %d", status));
-	if (status == PJ_ESOCKETSTOP) 
-	    telnet_restart(fe);	    
-	
+	if (status == PJ_ESOCKETSTOP)
+	    telnet_restart(fe);
+
         return PJ_FALSE;
-    }    
+    }
 
     /* An incoming connection is accepted, create a new session */
@@ -1609,5 +1607,5 @@
                           NULL);
     if (!pool) {
-        TRACE_((THIS_FILE, 
+        TRACE_((THIS_FILE,
                 "Not enough memory to create a new telnet session"));
         return PJ_TRUE;
@@ -1632,5 +1630,5 @@
     if (sstatus != PJ_SUCCESS)
         goto on_exit;
-    
+
     sstatus = pj_activesock_create(pool, newsock, pj_SOCK_STREAM(),
                                    NULL, fe->cfg.ioqueue,
@@ -1657,5 +1655,5 @@
     send_cmd_do(sess, SUPPRESS_GA);
     send_cmd_will(sess, TERM_ECHO);
-    send_cmd_will(sess, STATUS);   
+    send_cmd_will(sess, STATUS);
     send_cmd_will(sess, SUPPRESS_GA);
 
@@ -1682,5 +1680,5 @@
     else
         pj_sock_close(newsock);
-    
+
     if (sess->smutex)
         pj_mutex_destroy(sess->smutex);
@@ -1697,5 +1695,5 @@
     cli_telnet_fe *fe;
     pj_pool_t *pool;
-    pj_status_t status;   
+    pj_status_t status;
 
     PJ_ASSERT_RETURN(cli, PJ_EINVAL);
@@ -1707,5 +1705,5 @@
     if (!fe)
         return PJ_ENOMEM;
-	
+
     fe->base.op = PJ_POOL_ZALLOC_T(pool, struct pj_cli_front_end_op);
 
@@ -1714,5 +1712,5 @@
     else
         pj_memcpy(&fe->cfg, param, sizeof(*param));
-	
+
     pj_list_init(&fe->sess_head);
     fe->base.cli = cli;
@@ -1722,5 +1720,5 @@
     fe->pool = pool;
 
-    if (!fe->cfg.ioqueue) {	
+    if (!fe->cfg.ioqueue) {
         /* Create own ioqueue if application doesn't supply one */
         status = pj_ioqueue_create(pool, 8, &fe->cfg.ioqueue);
@@ -1762,5 +1760,5 @@
     pj_activesock_cb asock_cb;
     pj_sockaddr_in addr;
-    pj_status_t status;   
+    pj_status_t status;
     int val;
     int restart_retry;
@@ -1794,18 +1792,18 @@
 	PJ_LOG(4,(THIS_FILE, "Address is still in use, retrying.."));
 	pj_thread_sleep(msec);
-    }    
-    
-    if (status == PJ_SUCCESS) {	
-	int addr_len = sizeof(addr);	
+    }
+
+    if (status == PJ_SUCCESS) {
+	int addr_len = sizeof(addr);
 
 	status = pj_sock_getsockname(sock, &addr, &addr_len);
 	if (status != PJ_SUCCESS)
 	    goto on_exit;
-	    
-        fe->cfg.port = pj_sockaddr_in_get_port(&addr);	
+
+        fe->cfg.port = pj_sockaddr_in_get_port(&addr);
 
 	if (fe->cfg.prompt_str.slen == 0) {
 	    pj_str_t prompt_sign = {"> ", 2};
-	    char *prompt_data = pj_pool_alloc(fe->pool, 
+	    char *prompt_data = pj_pool_alloc(fe->pool,
 					      pj_gethostname()->slen+2);
 	    fe->cfg.prompt_str.ptr = prompt_data;
@@ -1813,5 +1811,5 @@
 	    pj_strcpy(&fe->cfg.prompt_str, pj_gethostname());
 	    pj_strcat(&fe->cfg.prompt_str, &prompt_sign);
-	}	
+	}
     } else {
         PJ_LOG(3, (THIS_FILE, "Failed binding the socket"));
@@ -1869,8 +1867,8 @@
 {
     pj_status_t status;
-    pj_cli_sess *sess;      
+    pj_cli_sess *sess;
 
     fe->is_quitting = PJ_TRUE;
-    if (fe->worker_thread) {	
+    if (fe->worker_thread) {
 	pj_thread_join(fe->worker_thread);
     }
@@ -1911,12 +1909,12 @@
 }
 
-PJ_DEF(pj_status_t) pj_cli_telnet_get_info(pj_cli_front_end *fe, 
+PJ_DEF(pj_status_t) pj_cli_telnet_get_info(pj_cli_front_end *fe,
 					   pj_cli_telnet_info *info)
 {
     pj_sockaddr hostip;
     pj_status_t status;
-    cli_telnet_fe *tfe = (cli_telnet_fe*) fe; 
-
-    PJ_ASSERT_RETURN(fe && (fe->type == PJ_CLI_TELNET_FRONT_END) && info, 
+    cli_telnet_fe *tfe = (cli_telnet_fe*) fe;
+
+    PJ_ASSERT_RETURN(fe && (fe->type == PJ_CLI_TELNET_FRONT_END) && info,
 		     PJ_EINVAL);
 
Index: pjproject/trunk/pjlib/src/pj/os_core_unix.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/os_core_unix.c	(revision 4727)
+++ pjproject/trunk/pjlib/src/pj/os_core_unix.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 /*
@@ -165,5 +165,5 @@
     pj_log_init();
 
-    /* Initialize exception ID for the pool. 
+    /* Initialize exception ID for the pool.
      * Must do so after critical section is configured.
      */
@@ -171,5 +171,5 @@
     if (rc != PJ_SUCCESS)
         return rc;
-    
+
     /* Init random seed. */
     /* Or probably not. Let application in charge of this */
@@ -188,5 +188,5 @@
 	}
     }
-#endif   
+#endif
 
     /* Flag PJLIB as initialized */
@@ -383,5 +383,5 @@
  * Get native thread handle
  */
-PJ_DEF(void*) pj_thread_get_os_handle(pj_thread_t *thread) 
+PJ_DEF(void*) pj_thread_get_os_handle(pj_thread_t *thread)
 {
     PJ_ASSERT_RETURN(thread, NULL);
@@ -441,10 +441,10 @@
 
     if(cstr_thread_name && pj_strlen(&thread_name) < sizeof(thread->obj_name)-1)
-	pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name), 
+	pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name),
 			 cstr_thread_name, thread->thread);
     else
-	pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name), 
+	pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name),
 			 "thr%p", (void*)thread->thread);
-    
+
     rc = pj_thread_local_set(thread_tls_id, thread);
     if (rc != PJ_SUCCESS) {
@@ -458,5 +458,5 @@
     thread->stk_max_usage = 0;
 #else
-    stack_ptr = '\0';
+    PJ_UNUSED_ARG(stack_ptr);
 #endif
 
@@ -533,9 +533,9 @@
  * pj_thread_create(...)
  */
-PJ_DEF(pj_status_t) pj_thread_create( pj_pool_t *pool, 
+PJ_DEF(pj_status_t) pj_thread_create( pj_pool_t *pool,
 				      const char *thread_name,
-				      pj_thread_proc *proc, 
+				      pj_thread_proc *proc,
 				      void *arg,
-				      pj_size_t stack_size, 
+				      pj_size_t stack_size,
 				      unsigned flags,
 				      pj_thread_t **ptr_thread)
@@ -555,9 +555,9 @@
     rec = (struct pj_thread_t*) pj_pool_zalloc(pool, sizeof(pj_thread_t));
     PJ_ASSERT_RETURN(rec, PJ_ENOMEM);
-    
+
     /* Set name. */
-    if (!thread_name) 
+    if (!thread_name)
 	thread_name = "thr%p";
-    
+
     if (strchr(thread_name, '%')) {
 	pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec);
@@ -587,5 +587,5 @@
 	pj_assert(rec->suspended_mutex == NULL);
     }
-    
+
 
     /* Init thread attributes */
@@ -668,5 +668,5 @@
 #if PJ_HAS_THREADS
     pj_thread_t *rec = (pj_thread_t*)pj_thread_local_get(thread_tls_id);
-    
+
     if (rec == NULL) {
 	pj_assert(!"Calling pjlib from unknown/external thread. You must "
@@ -706,6 +706,6 @@
 	return PJ_SUCCESS;
     else {
-	/* Calling pthread_join() on a thread that no longer exists and 
-	 * getting back ESRCH isn't an error (in this context). 
+	/* Calling pthread_join() on a thread that no longer exists and
+	 * getting back ESRCH isn't an error (in this context).
 	 * Thanks Phil Torre <ptorre@zetron.com>.
 	 */
@@ -762,7 +762,7 @@
     /* MacOS X (reported on 10.5) seems to always set errno to ETIMEDOUT.
      * It does so because usleep() is declared to return int, and we're
-     * supposed to check for errno only when usleep() returns non-zero. 
+     * supposed to check for errno only when usleep() returns non-zero.
      * Unfortunately, usleep() is declared to return void in other platforms
-     * so it's not possible to always check for the return value (unless 
+     * so it's not possible to always check for the return value (unless
      * we add a detection routine in autoconf).
      *
@@ -832,5 +832,5 @@
  * pj_atomic_create()
  */
-PJ_DEF(pj_status_t) pj_atomic_create( pj_pool_t *pool, 
+PJ_DEF(pj_status_t) pj_atomic_create( pj_pool_t *pool,
 				      pj_atomic_value_t initial,
 				      pj_atomic_t **ptr_atomic)
@@ -842,5 +842,5 @@
 
     PJ_ASSERT_RETURN(atomic_var, PJ_ENOMEM);
-    
+
 #if PJ_HAS_THREADS
     rc = pj_mutex_create(pool, "atm%p", PJ_MUTEX_SIMPLE, &atomic_var->mutex);
@@ -880,5 +880,5 @@
 #if PJ_HAS_THREADS
     pj_mutex_unlock( atomic_var->mutex);
-#endif 
+#endif
 }
 
@@ -889,5 +889,5 @@
 {
     pj_atomic_value_t oldval;
-    
+
     PJ_CHECK_STACK();
 
@@ -959,6 +959,6 @@
 /*
  * pj_atomic_add_and_get()
- */ 
-PJ_DEF(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var, 
+ */
+PJ_DEF(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var,
                                                  pj_atomic_value_t value )
 {
@@ -968,5 +968,5 @@
     pj_mutex_lock(atomic_var->mutex);
 #endif
-    
+
     atomic_var->value += value;
     new_value = atomic_var->value;
@@ -981,6 +981,6 @@
 /*
  * pj_atomic_add()
- */ 
-PJ_DEF(void) pj_atomic_add( pj_atomic_t *atomic_var, 
+ */
+PJ_DEF(void) pj_atomic_add( pj_atomic_t *atomic_var,
                             pj_atomic_value_t value )
 {
@@ -1012,7 +1012,7 @@
 	    break;
     }
-    if (i == MAX_THREADS) 
+    if (i == MAX_THREADS)
 	return PJ_ETOOMANY;
-    
+
     tls_flag[i] = 1;
     tls[i] = NULL;
@@ -1119,5 +1119,5 @@
        defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
 	// Phil Torre <ptorre@zetron.com>:
-	// The RTEMS implementation of POSIX mutexes doesn't include 
+	// The RTEMS implementation of POSIX mutexes doesn't include
 	// pthread_mutexattr_settype(), so what follows is a hack
 	// until I get RTEMS patched to support the set/get functions.
@@ -1132,5 +1132,5 @@
 #endif
     }
-    
+
     if (rc != 0) {
 	return PJ_RETURN_OS_ERROR(rc);
@@ -1141,5 +1141,5 @@
 	return PJ_RETURN_OS_ERROR(rc);
     }
-    
+
     rc = pthread_mutexattr_destroy(&attr);
     if (rc != 0) {
@@ -1176,6 +1176,6 @@
  * pj_mutex_create()
  */
-PJ_DEF(pj_status_t) pj_mutex_create(pj_pool_t *pool, 
-				    const char *name, 
+PJ_DEF(pj_status_t) pj_mutex_create(pj_pool_t *pool,
+				    const char *name,
 				    int type,
 				    pj_mutex_t **ptr_mutex)
@@ -1192,5 +1192,5 @@
     if ((rc=init_mutex(mutex, name, type)) != PJ_SUCCESS)
 	return rc;
-    
+
     *ptr_mutex = mutex;
     return PJ_SUCCESS;
@@ -1204,5 +1204,5 @@
  * pj_mutex_create_simple()
  */
-PJ_DEF(pj_status_t) pj_mutex_create_simple( pj_pool_t *pool, 
+PJ_DEF(pj_status_t) pj_mutex_create_simple( pj_pool_t *pool,
                                             const char *name,
 					    pj_mutex_t **mutex )
@@ -1233,9 +1233,9 @@
 
 #if PJ_DEBUG
-    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting (mutex owner=%s)", 
+    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting (mutex owner=%s)",
 				pj_thread_this()->obj_name,
 				mutex->owner_name));
 #else
-    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting", 
+    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting",
 				pj_thread_this()->obj_name));
 #endif
@@ -1251,12 +1251,12 @@
     }
 
-    PJ_LOG(6,(mutex->obj_name, 
-	      (status==0 ? 
-		"Mutex acquired by thread %s (level=%d)" : 
+    PJ_LOG(6,(mutex->obj_name,
+	      (status==0 ?
+		"Mutex acquired by thread %s (level=%d)" :
 		"Mutex acquisition FAILED by %s (level=%d)"),
 	      pj_thread_this()->obj_name,
 	      mutex->nesting_level));
 #else
-    PJ_LOG(6,(mutex->obj_name, 
+    PJ_LOG(6,(mutex->obj_name,
 	      (status==0 ? "Mutex acquired by thread %s" : "FAILED by %s"),
 	      pj_thread_this()->obj_name));
@@ -1291,9 +1291,9 @@
     }
 
-    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s (level=%d)", 
-				pj_thread_this()->obj_name, 
+    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s (level=%d)",
+				pj_thread_this()->obj_name,
 				mutex->nesting_level));
 #else
-    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s", 
+    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s",
 				pj_thread_this()->obj_name));
 #endif
@@ -1322,5 +1322,5 @@
     PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
 
-    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is trying", 
+    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is trying",
 				pj_thread_this()->obj_name));
 
@@ -1333,16 +1333,16 @@
 	++mutex->nesting_level;
 
-	PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s (level=%d)", 
+	PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s (level=%d)",
 				   pj_thread_this()->obj_name,
 				   mutex->nesting_level));
 #else
-	PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s", 
+	PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s",
 				  pj_thread_this()->obj_name));
 #endif
     } else {
-	PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s's trylock() failed", 
+	PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s's trylock() failed",
 				    pj_thread_this()->obj_name));
     }
-    
+
     if (status==0)
 	return PJ_SUCCESS;
@@ -1426,5 +1426,5 @@
 
     PJ_UNUSED_ARG(name);
-    
+
     rwm = PJ_POOL_ALLOC_T(pool, pj_rwmutex_t);
     PJ_ASSERT_RETURN(rwm, PJ_ENOMEM);
@@ -1516,7 +1516,7 @@
  * pj_sem_create()
  */
-PJ_DEF(pj_status_t) pj_sem_create( pj_pool_t *pool, 
+PJ_DEF(pj_status_t) pj_sem_create( pj_pool_t *pool,
 				   const char *name,
-				   unsigned initial, 
+				   unsigned initial,
 				   unsigned max,
 				   pj_sem_t **ptr_sem)
@@ -1537,5 +1537,5 @@
 	pj_str_t nam;
 
-	/* We should use SEM_NAME_LEN, but this doesn't seem to be 
+	/* We should use SEM_NAME_LEN, but this doesn't seem to be
 	 * declared anywhere? The value here is just from trial and error
 	 * to get the longest name supported.
@@ -1554,5 +1554,5 @@
 
 	/* Create semaphore */
-	sem->sem = sem_open(sem_name, O_CREAT|O_EXCL, S_IRUSR|S_IWUSR, 
+	sem->sem = sem_open(sem_name, O_CREAT|O_EXCL, S_IRUSR|S_IWUSR,
 			    initial);
 	if (sem->sem == SEM_FAILED)
@@ -1564,8 +1564,8 @@
 #else
     sem->sem = PJ_POOL_ALLOC_T(pool, sem_t);
-    if (sem_init( sem->sem, 0, initial) != 0) 
+    if (sem_init( sem->sem, 0, initial) != 0)
 	return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
 #endif
-    
+
     /* Set name. */
     if (!name) {
@@ -1600,14 +1600,14 @@
     PJ_ASSERT_RETURN(sem, PJ_EINVAL);
 
-    PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s is waiting", 
+    PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s is waiting",
 			      pj_thread_this()->obj_name));
 
     result = sem_wait( sem->sem );
-    
+
     if (result == 0) {
-	PJ_LOG(6, (sem->obj_name, "Semaphore acquired by thread %s", 
+	PJ_LOG(6, (sem->obj_name, "Semaphore acquired by thread %s",
 				  pj_thread_this()->obj_name));
     } else {
-	PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s FAILED to acquire", 
+	PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s FAILED to acquire",
 				  pj_thread_this()->obj_name));
     }
@@ -1635,9 +1635,9 @@
 
     result = sem_trywait( sem->sem );
-    
+
     if (result == 0) {
-	PJ_LOG(6, (sem->obj_name, "Semaphore acquired by thread %s", 
+	PJ_LOG(6, (sem->obj_name, "Semaphore acquired by thread %s",
 				  pj_thread_this()->obj_name));
-    } 
+    }
     if (result == 0)
 	return PJ_SUCCESS;
Index: pjproject/trunk/pjlib/src/pjlib-test/test.c
===================================================================
--- pjproject/trunk/pjlib/src/pjlib-test/test.c	(revision 4727)
+++ pjproject/trunk/pjlib/src/pjlib-test/test.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "test.h"
@@ -39,5 +39,5 @@
 const char *param_echo_server = ECHO_SERVER_ADDRESS;
 int param_echo_port = ECHO_SERVER_START_PORT;
-int param_log_decor = PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME | 
+int param_log_decor = PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME |
 		      PJ_LOG_HAS_MICRO_SEC;
 
@@ -64,5 +64,5 @@
 	return rc;
     }
-    
+
     //pj_dump_config();
     pj_caching_pool_init( &caching_pool, NULL, 0 );
@@ -99,5 +99,5 @@
     DO_TEST( string_test() );
 #endif
-    
+
 #if INCLUDE_FIFOBUF_TEST
     DO_TEST( fifobuf_test() );
@@ -185,6 +185,6 @@
         param_echo_sock_type = pj_SOCK_DGRAM();
 
-    echo_client( param_echo_sock_type, 
-                 param_echo_server, 
+    echo_client( param_echo_sock_type,
+                 param_echo_server,
                  param_echo_port);
 #endif
@@ -197,7 +197,7 @@
 
     PJ_LOG(3,("test", ""));
- 
+
     pj_thread_get_stack_info(pj_thread_this(), &filename, &line);
-    PJ_LOG(3,("test", "Stack max usage: %u, deepest: %s:%u", 
+    PJ_LOG(3,("test", "Stack max usage: %u, deepest: %s:%u",
 	              pj_thread_get_stack_max_usage(pj_thread_this()),
 		      filename, line));
@@ -206,7 +206,7 @@
     else
 	PJ_LOG(3,("test", "Test completed with error(s)"));
-    
+
     pj_shutdown();
-    
+
     return 0;
 }
@@ -217,6 +217,4 @@
 {
     PJ_USE_EXCEPTION;
-
-    pj_AF_INET();
 
     PJ_TRY {
@@ -225,5 +223,5 @@
     PJ_CATCH_ANY {
         int id = PJ_GET_EXCEPTION();
-        PJ_LOG(3,("test", "FATAL: unhandled exception id %d (%s)", 
+        PJ_LOG(3,("test", "FATAL: unhandled exception id %d (%s)",
                   id, pj_exception_id_name(id)));
     }
Index: pjproject/trunk/pjlib/src/pjlib-test/thread.c
===================================================================
--- pjproject/trunk/pjlib/src/pjlib-test/thread.c	(revision 4727)
+++ pjproject/trunk/pjlib/src/pjlib-test/thread.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "test.h"
@@ -31,5 +31,5 @@
  *  - whether thread timeslicing works, and threads have equal
  *    time-slice proportion.
- * 
+ *
  * APIs tested:
  *  - pj_thread_create()
@@ -78,4 +78,5 @@
 
     id = *pcounter;
+    PJ_UNUSED_ARG(id); /* Warning about unused var if TRACE__ is disabled */
     TRACE__((THIS_FILE, "     thread %d running..", id));
 
@@ -121,7 +122,7 @@
     pj_status_t rc;
     pj_uint32_t counter = 0;
- 
+
     PJ_LOG(3,(THIS_FILE, "..%s", title));
-    
+
     pool = pj_pool_create(mem, NULL, 4000, 4000, NULL);
     if (!pool)
@@ -153,5 +154,5 @@
 	    return -1015;
 	}
-	
+
 	rc = pj_thread_resume(thread);
 	if (rc != PJ_SUCCESS) {
@@ -160,5 +161,5 @@
 	}
     }
-    
+
     PJ_LOG(3,(THIS_FILE, "..waiting for thread to quit.."));
 
@@ -174,5 +175,5 @@
 	return -1025;
     }
-    
+
     PJ_LOG(3,(THIS_FILE, "...%s success", title));
     return PJ_SUCCESS;
@@ -203,8 +204,8 @@
     for (i=0; i<NUM_THREADS; ++i) {
         counter[i] = i;
-        rc = pj_thread_create(pool, "thread", (pj_thread_proc*)&thread_proc, 
-			      &counter[i], 
-                              PJ_THREAD_DEFAULT_STACK_SIZE, 
-                              PJ_THREAD_SUSPENDED, 
+        rc = pj_thread_create(pool, "thread", (pj_thread_proc*)&thread_proc,
+			      &counter[i],
+                              PJ_THREAD_DEFAULT_STACK_SIZE,
+                              PJ_THREAD_SUSPENDED,
                               &thread[i]);
         if (rc!=PJ_SUCCESS) {
@@ -224,5 +225,5 @@
     for (i=0; i<NUM_THREADS; ++i) {
         if (counter[i] > i) {
-            PJ_LOG(3,(THIS_FILE, "....ERROR! Thread %d-th is not suspended!", 
+            PJ_LOG(3,(THIS_FILE, "....ERROR! Thread %d-th is not suspended!",
 		      i));
             return -30;
@@ -240,5 +241,5 @@
     }
 
-    /* Main thread sleeps for some time to allow threads to run. 
+    /* Main thread sleeps for some time to allow threads to run.
      * The longer we sleep, the more accurate the calculation will be,
      * but it'll make user waits for longer for the test to finish.
@@ -253,5 +254,5 @@
     /* Wait until all threads quit, then destroy. */
     for (i=0; i<NUM_THREADS; ++i) {
-	TRACE__((THIS_FILE, "    Main thread joining thread %d [%p]..", 
+	TRACE__((THIS_FILE, "    Main thread joining thread %d [%p]..",
 			    i, thread[i]));
         rc = pj_thread_join(thread[i]);
@@ -292,12 +293,12 @@
     diff = (highest-lowest)*100 / ((highest+lowest)/2);
     if ( diff >= 50) {
-        PJ_LOG(3,(THIS_FILE, 
+        PJ_LOG(3,(THIS_FILE,
 		  "...ERROR: thread didn't have equal timeslice!"));
-        PJ_LOG(3,(THIS_FILE, 
+        PJ_LOG(3,(THIS_FILE,
 		  ".....lowest counter=%u, highest counter=%u, diff=%u%%",
                   lowest, highest, diff));
         return -80;
     } else {
-        PJ_LOG(3,(THIS_FILE, 
+        PJ_LOG(3,(THIS_FILE,
                   "...info: timeslice diff between lowest & highest=%u%%",
                   diff));
@@ -315,9 +316,9 @@
     if (rc != PJ_SUCCESS)
 	return rc;
-    
+
     rc = simple_thread("suspended thread test", PJ_THREAD_SUSPENDED);
     if (rc != PJ_SUCCESS)
 	return rc;
-    
+
     rc = timeslice_test();
     if (rc != PJ_SUCCESS)
@@ -329,5 +330,5 @@
 #else
 /* To prevent warning about "translation unit is empty"
- * when this test is disabled. 
+ * when this test is disabled.
  */
 int dummy_thread_test;
Index: pjproject/trunk/pjmedia/src/pjmedia-audiodev/bb10_dev.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia-audiodev/bb10_dev.c	(revision 4727)
+++ pjproject/trunk/pjmedia/src/pjmedia-audiodev/bb10_dev.c	(revision 4728)
@@ -501,5 +501,5 @@
 		if (status.status == SND_PCM_STATUS_READY ||
 		    status.status == SND_PCM_STATUS_UNDERRUN ||
-		    status.status == SND_PCM_STATUS_ERROR ) 
+		    status.status == SND_PCM_STATUS_ERROR )
 		{
 		    if (snd_pcm_plugin_prepare (stream->pb_pcm,
@@ -778,5 +778,5 @@
     TRACE_((THIS_FILE, "bb10_open_playback: pb_frames = %d clock = %d",
                        stream->pb_frames, param->clock_rate));
-    
+
     return PJ_SUCCESS;
 }
@@ -864,4 +864,5 @@
 
     frame_size = setup.buf.block.frag_size;
+    PJ_UNUSED_ARG(frame_size); /* Warning about unused var */
 
     /* Set clock rate */
@@ -962,5 +963,5 @@
 
 
-/* 
+/*
  * API: get running parameter
  * based on ALSA template
@@ -981,5 +982,5 @@
 /*
  * API: get capability
- * based on ALSA template 
+ * based on ALSA template
 */
 static pj_status_t bb10_stream_get_cap(pjmedia_aud_stream *s,
@@ -1043,5 +1044,5 @@
             ret = bb10_initialize_playback_ctrl(stream,true);
         } else {
-            ret = bb10_initialize_playback_ctrl(stream,false);        	
+            ret = bb10_initialize_playback_ctrl(stream,false);
         }
     	return ret;
Index: pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c	(revision 4727)
+++ pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <pjmedia/types.h>
@@ -78,4 +78,14 @@
 #if 0
 #   define TRACE_(expr)	PJ_LOG(5,expr)
+
+static const char *state_names[] =
+{
+    "Null",
+    "local talking",
+    "remote silent",
+    "doubletalk",
+    "remote talking"
+};
+
 #else
 #   define TRACE_(expr)
@@ -126,21 +136,12 @@
 } talk_state_t;
 
-static const char *state_names[] = 
-{
-    "Null",
-    "local talking",
-    "remote silent",
-    "doubletalk",
-    "remote talking"
-};
-
 
 /* Description:
 
    The echo suppressor tries to find the position of echoed signal by looking
-   at the correlation between signal played to the speaker (played signal) 
+   at the correlation between signal played to the speaker (played signal)
    and the signal captured from the microphone (recorded signal).
 
-   To do this, it first divides the frames (from mic and speaker) into 
+   To do this, it first divides the frames (from mic and speaker) into
    segments, calculate the audio level of the segment, and save the level
    information in the playback and record history (play_hist and rec_hist
@@ -151,5 +152,5 @@
 
    The record history size is as large as the template size (tmpl_cnt), since
-   we will use the record history as the template to find the best matching 
+   we will use the record history as the template to find the best matching
    position in the playback history.
 
@@ -188,5 +189,5 @@
       similar) the signal is. The correlation value is done over the template
       duration.
-    - the gain scaling factor, that is the ratio between mic signal and 
+    - the gain scaling factor, that is the ratio between mic signal and
       speaker signal. The ES calculates both the minimum and average ratios.
 
@@ -210,5 +211,5 @@
    Processing:
 
-   Once learning is done, the ES will change the level of the mic signal 
+   Once learning is done, the ES will change the level of the mic signal
    depending on the state of the conversation and according to the ratio that
    has been found in the learning phase above.
@@ -264,5 +265,5 @@
 
 /*
- * Create. 
+ * Create.
  */
 PJ_DEF(pj_status_t) echo_supp_create( pj_pool_t *pool,
@@ -293,30 +294,30 @@
     ec->play_hist_cnt = (pj_uint16_t)(ec->tail_cnt+ec->templ_cnt);
 
-    ec->max_calc = (pj_uint16_t)(MAX_CALC_DURATION_SEC * clock_rate / 
+    ec->max_calc = (pj_uint16_t)(MAX_CALC_DURATION_SEC * clock_rate /
 				 ec->samples_per_segment);
 
-    ec->rec_hist = (pj_uint16_t*) 
+    ec->rec_hist = (pj_uint16_t*)
 		    pj_pool_alloc(pool, ec->templ_cnt *
 					sizeof(ec->rec_hist[0]));
 
     /* Note: play history has twice number of elements */
-    ec->play_hist = (pj_uint16_t*) 
+    ec->play_hist = (pj_uint16_t*)
 		     pj_pool_alloc(pool, ec->play_hist_cnt *
 					 sizeof(ec->play_hist[0]));
 
     ec->corr_sum = (float*)
-		   pj_pool_alloc(pool, ec->tail_cnt * 
+		   pj_pool_alloc(pool, ec->tail_cnt *
 				       sizeof(ec->corr_sum[0]));
     ec->tmp_corr = (float*)
-		   pj_pool_alloc(pool, ec->tail_cnt * 
+		   pj_pool_alloc(pool, ec->tail_cnt *
 				       sizeof(ec->tmp_corr[0]));
     ec->min_factor = (float*)
-		     pj_pool_alloc(pool, ec->tail_cnt * 
+		     pj_pool_alloc(pool, ec->tail_cnt *
 				         sizeof(ec->min_factor[0]));
     ec->avg_factor = (float*)
-		     pj_pool_alloc(pool, ec->tail_cnt * 
+		     pj_pool_alloc(pool, ec->tail_cnt *
 				         sizeof(ec->avg_factor[0]));
     ec->tmp_factor = (float*)
-		     pj_pool_alloc(pool, ec->tail_cnt * 
+		     pj_pool_alloc(pool, ec->tail_cnt *
 				         sizeof(ec->tmp_factor[0]));
     echo_supp_reset(ec);
@@ -328,5 +329,5 @@
 
 /*
- * Destroy. 
+ * Destroy.
  */
 PJ_DEF(pj_status_t) echo_supp_destroy(void *state)
@@ -394,5 +395,5 @@
 
 /* Set state */
-static void echo_supp_set_state(echo_supp *ec, talk_state_t state, 
+static void echo_supp_set_state(echo_supp *ec, talk_state_t state,
 				unsigned level)
 {
@@ -400,6 +401,6 @@
 
     if (state != ec->talk_state) {
-	TRACE_((THIS_FILE, "[%03d.%03d] %s --> %s, level=%u", 
-			   (ec->update_cnt * SEGMENT_PTIME / 1000), 
+	TRACE_((THIS_FILE, "[%03d.%03d] %s --> %s, level=%u",
+			   (ec->update_cnt * SEGMENT_PTIME / 1000),
 			   ((ec->update_cnt * SEGMENT_PTIME) % 1000),
 			   state_names[ec->talk_state],
@@ -470,7 +471,7 @@
     } else {
 	/* Update from previous calculation */
-	ec->sum_rec_level = ec->sum_rec_level - old_rec_frm_level + 
+	ec->sum_rec_level = ec->sum_rec_level - old_rec_frm_level +
 			    ec->rec_hist[ec->templ_cnt-1];
-	ec->rec_corr = ec->rec_corr - ((float)ec->rec_hist[0] / 
+	ec->rec_corr = ec->rec_corr - ((float)ec->rec_hist[0] /
 					      old_rec_frm_level) +
 		       ((float)ec->rec_hist[ec->templ_cnt-1] /
@@ -483,6 +484,6 @@
      * to detect echo.
      */
-    /* 
-     * First phase: do full calculation for the first position 
+    /*
+     * First phase: do full calculation for the first position
      */
     if (ec->sum_play_level0 == 0) {
@@ -501,7 +502,7 @@
     } else {
 	/* Update from previous calculation */
-	ec->sum_play_level0 = ec->sum_play_level0 - old_play_frm_level + 
+	ec->sum_play_level0 = ec->sum_play_level0 - old_play_frm_level +
 			      ec->play_hist[ec->templ_cnt-1];
-	ec->play_corr0 = ec->play_corr0 - ((float)ec->play_hist[0] / 
+	ec->play_corr0 = ec->play_corr0 - ((float)ec->play_hist[0] /
 					          old_play_frm_level) +
 		         ((float)ec->play_hist[ec->templ_cnt-1] /
@@ -585,5 +586,5 @@
 	if (ec->tmp_factor[i] < ec->min_factor[i])
 	    ec->min_factor[i] = ec->tmp_factor[i];
-	ec->avg_factor[i] = ((ec->avg_factor[i] * ec->tail_cnt) + 
+	ec->avg_factor[i] = ((ec->avg_factor[i] * ec->tail_cnt) +
 				    ec->tmp_factor[i]) /
 			    (ec->tail_cnt + 1);
@@ -610,5 +611,5 @@
 	iavg = (int)(ec->avg_factor[ec->tail_index] * 1000);
 
-	PJ_LOG(4,(THIS_FILE, 
+	PJ_LOG(4,(THIS_FILE,
 		  "Echo suppressor updated at t=%03d.%03ds, echo tail=%d msec"
 		  ", factor min/avg=%d.%03d/%d.%03d",
@@ -634,5 +635,5 @@
 	iavg = (int)(ec->avg_factor[ec->tail_index] * 1000);
 
-	PJ_LOG(4,(THIS_FILE, 
+	PJ_LOG(4,(THIS_FILE,
 	          "Echo suppressor learning done at t=%03d.%03ds, tail=%d ms"
 		  ", factor min/avg=%d.%03d/%d.%03d",
@@ -647,5 +648,5 @@
 
 /* Amplify frame */
-static void amplify_frame(pj_int16_t *frm, unsigned length, 
+static void amplify_frame(pj_int16_t *frm, unsigned length,
 			  pj_ufloat_t factor)
 {
@@ -657,5 +658,5 @@
 }
 
-/* 
+/*
  * Perform echo cancellation.
  */
@@ -710,6 +711,6 @@
 	 * if remote user is currently talking
 	 */
-	for (i=ec->play_hist_cnt -lookup_cnt -tail_cnt; 
-	     i<ec->play_hist_cnt-tail_cnt; ++i) 
+	for (i=ec->play_hist_cnt -lookup_cnt -tail_cnt;
+	     i<ec->play_hist_cnt-tail_cnt; ++i)
 	{
 	    if (ec->play_hist[i] > play_level)
@@ -733,5 +734,5 @@
 	    } else {
 		/* Speaker is active, but we've picked up large signal in
-		 * the microphone. Assume that this is an echo, so bring 
+		 * the microphone. Assume that this is an echo, so bring
 		 * the level down to minimum too.
 		 */
@@ -763,5 +764,5 @@
 
 	/* Amplify frame */
-	amplify_frame(rec_frm, ec->samples_per_frame, 
+	amplify_frame(rec_frm, ec->samples_per_frame,
 		      pj_ufloat_from_float(factor));
 	ec->last_factor = factor;
@@ -775,5 +776,5 @@
 
 	    /* Accumulate average echo residue to see the ES effectiveness */
-	    ec->residue = ((ec->residue * ec->running_cnt) + level) / 
+	    ec->residue = ((ec->residue * ec->running_cnt) + level) /
 			  (ec->running_cnt + 1);
 
Index: pjproject/trunk/pjmedia/src/pjmedia/jbuf.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/jbuf.c	(revision 4727)
+++ pjproject/trunk/pjmedia/src/pjmedia/jbuf.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 /*
@@ -36,5 +36,5 @@
 #define INVALID_OFFSET		-9999
 
-/* Maximum burst length, whenever an operation is bursting longer than 
+/* Maximum burst length, whenever an operation is bursting longer than
  * this value, JB will assume that the opposite operation was idle.
  */
@@ -47,6 +47,6 @@
 
 
-/* Minimal difference between JB size and 2*burst-level to perform 
- * JB shrinking in static discard algorithm. 
+/* Minimal difference between JB size and 2*burst-level to perform
+ * JB shrinking in static discard algorithm.
  */
 #define STA_DISC_SAFE_SHRINKING_DIFF	1
@@ -68,11 +68,11 @@
     pj_uint32_t	    *bit_info;		/**< frame bit info array	    */
     pj_uint32_t	    *ts;		/**< timestamp array		    */
-    
+
     /* States */
     unsigned	     head;		/**< index of head, pointed frame
 					     will be returned by next GET   */
-    unsigned	     size;		/**< current size of framelist, 
+    unsigned	     size;		/**< current size of framelist,
 					     including discarded frames.    */
-    unsigned	     discarded_num;	/**< current number of discarded 
+    unsigned	     discarded_num;	/**< current number of discarded
 					     frames.			    */
     int		     origin;		/**< original index of flist_head   */
@@ -92,5 +92,5 @@
     pj_size_t	    jb_frame_size;	/**< frame size			    */
     unsigned	    jb_frame_ptime;	/**< frame duration.		    */
-    pj_size_t	    jb_max_count;	/**< capacity of jitter buffer, 
+    pj_size_t	    jb_max_count;	/**< capacity of jitter buffer,
 					     in frames			    */
     int		    jb_init_prefetch;	/**< Initial prefetch		    */
@@ -98,6 +98,6 @@
     int		    jb_max_prefetch;	/**< Maximum allowable prefetch	    */
     int		    jb_max_burst;	/**< maximum possible burst, whenever
-					     burst exceeds this value, it 
-					     won't be included in level 
+					     burst exceeds this value, it
+					     won't be included in level
 					     calculation		    */
     int		    jb_min_shrink_gap;	/**< How often can we shrink	    */
@@ -108,25 +108,25 @@
 
     /* States */
-    int		    jb_level;		/**< delay between source & 
-					     destination (calculated according 
-					     of the number of burst get/put 
+    int		    jb_level;		/**< delay between source &
+					     destination (calculated according
+					     of the number of burst get/put
 					     operations)		    */
-    int		    jb_max_hist_level;  /**< max level during the last level 
+    int		    jb_max_hist_level;  /**< max level during the last level
 					     calculations		    */
-    int		    jb_stable_hist;	/**< num of times the delay has	been 
+    int		    jb_stable_hist;	/**< num of times the delay has	been
 					     lower then the prefetch num    */
-    int		    jb_last_op;		/**< last operation executed 
+    int		    jb_last_op;		/**< last operation executed
 					     (put/get)			    */
     int		    jb_eff_level;	/**< effective burst level	    */
-    int		    jb_prefetch;	/**< no. of frame to insert before 
-					     removing some (at the beginning 
-					     of the framelist->content 
+    int		    jb_prefetch;	/**< no. of frame to insert before
+					     removing some (at the beginning
+					     of the framelist->content
 					     operation), the value may be
 					     continuously updated based on
 					     current frame burst level.	    */
     pj_bool_t	    jb_prefetching;	/**< flag if jbuf is prefetching.   */
-    int		    jb_status;		/**< status is 'init' until the	first 
+    int		    jb_status;		/**< status is 'init' until the	first
 					     'put' operation		    */
-    int		    jb_init_cycle_cnt;	/**< status is 'init' until the	first 
+    int		    jb_init_cycle_cnt;	/**< status is 'init' until the	first
 					     'put' operation		    */
 
@@ -137,5 +137,5 @@
 
     /* Statistics */
-    pj_math_stat    jb_delay;		/**< Delay statistics of jitter buffer 
+    pj_math_stat    jb_delay;		/**< Delay statistics of jitter buffer
 					     (in ms)			    */
     pj_math_stat    jb_burst;		/**< Burst statistics (in frames)   */
@@ -165,5 +165,5 @@
 
 
-/* Enabling this would log the jitter buffer state about once per 
+/* Enabling this would log the jitter buffer state about once per
  * second.
  */
@@ -181,5 +181,5 @@
 				      jb_framelist_t *framelist,
 				      unsigned frame_size,
-				      unsigned max_count) 
+				      unsigned max_count)
 {
     PJ_ASSERT_RETURN(pool && framelist, PJ_EINVAL);
@@ -189,22 +189,22 @@
     framelist->frame_size   = frame_size;
     framelist->max_count    = max_count;
-    framelist->content	    = (char*) 
+    framelist->content	    = (char*)
 			      pj_pool_alloc(pool,
-					    framelist->frame_size* 
+					    framelist->frame_size*
 					    framelist->max_count);
     framelist->frame_type   = (int*)
-			      pj_pool_alloc(pool, 
+			      pj_pool_alloc(pool,
 					    sizeof(framelist->frame_type[0])*
 					    framelist->max_count);
     framelist->content_len  = (pj_size_t*)
-			      pj_pool_alloc(pool, 
+			      pj_pool_alloc(pool,
 					    sizeof(framelist->content_len[0])*
 					    framelist->max_count);
     framelist->bit_info	    = (pj_uint32_t*)
-			      pj_pool_alloc(pool, 
+			      pj_pool_alloc(pool,
 					    sizeof(framelist->bit_info[0])*
 					    framelist->max_count);
     framelist->ts	    = (pj_uint32_t*)
-			      pj_pool_alloc(pool, 
+			      pj_pool_alloc(pool,
 					    sizeof(framelist->ts[0])*
 					    framelist->max_count);
@@ -214,5 +214,5 @@
 }
 
-static pj_status_t jb_framelist_destroy(jb_framelist_t *framelist) 
+static pj_status_t jb_framelist_destroy(jb_framelist_t *framelist)
 {
     PJ_UNUSED_ARG(framelist);
@@ -220,5 +220,5 @@
 }
 
-static pj_status_t jb_framelist_reset(jb_framelist_t *framelist) 
+static pj_status_t jb_framelist_reset(jb_framelist_t *framelist)
 {
     framelist->head = 0;
@@ -228,19 +228,19 @@
 
 
-    //pj_bzero(framelist->content, 
-    //	     framelist->frame_size * 
+    //pj_bzero(framelist->content,
+    //	     framelist->frame_size *
     //	     framelist->max_count);
 
     pj_memset(framelist->frame_type,
 	      PJMEDIA_JB_MISSING_FRAME,
-	      sizeof(framelist->frame_type[0]) * 
+	      sizeof(framelist->frame_type[0]) *
 	      framelist->max_count);
 
-    pj_bzero(framelist->content_len, 
-	     sizeof(framelist->content_len[0]) * 
+    pj_bzero(framelist->content_len,
+	     sizeof(framelist->content_len[0]) *
 	     framelist->max_count);
 
     //pj_bzero(framelist->bit_info,
-    //	     sizeof(framelist->bit_info[0]) * 
+    //	     sizeof(framelist->bit_info[0]) *
     //	     framelist->max_count);
 
@@ -249,5 +249,5 @@
 
 
-static unsigned jb_framelist_size(const jb_framelist_t *framelist) 
+static unsigned jb_framelist_size(const jb_framelist_t *framelist)
 {
     return framelist->size;
@@ -255,10 +255,10 @@
 
 
-static unsigned jb_framelist_eff_size(const jb_framelist_t *framelist) 
+static unsigned jb_framelist_eff_size(const jb_framelist_t *framelist)
 {
     return (framelist->size - framelist->discarded_num);
 }
 
-static int jb_framelist_origin(const jb_framelist_t *framelist) 
+static int jb_framelist_origin(const jb_framelist_t *framelist)
 {
     return framelist->origin;
@@ -271,5 +271,5 @@
 				  pj_uint32_t *bit_info,
 				  pj_uint32_t *ts,
-				  int *seq) 
+				  int *seq)
 {
     if (framelist->size) {
@@ -296,9 +296,9 @@
 		    *bit_info = 0;
 	    } else {
-		pj_memcpy(frame, 
-			  framelist->content + 
+		pj_memcpy(frame,
+			  framelist->content +
 			  framelist->head * framelist->frame_size,
 			  framelist->frame_size);
-		*p_type = (pjmedia_jb_frame_type) 
+		*p_type = (pjmedia_jb_frame_type)
 			  framelist->frame_type[framelist->head];
 		if (size)
@@ -312,5 +312,5 @@
 		*seq = framelist->origin;
 
-	    //pj_bzero(framelist->content + 
+	    //pj_bzero(framelist->content +
 	    //	 framelist->head * framelist->frame_size,
 	    //	 framelist->frame_size);
@@ -323,5 +323,5 @@
 	    framelist->head = (framelist->head + 1) % framelist->max_count;
 	    framelist->size--;
-    	
+
 	    return PJ_TRUE;
 	}
@@ -342,5 +342,5 @@
 				   pj_uint32_t *bit_info,
 				   pj_uint32_t *ts,
-				   int *seq) 
+				   int *seq)
 {
     unsigned pos, idx;
@@ -367,5 +367,5 @@
 	*frame = framelist->content + pos*framelist->frame_size;
     if (type)
-	*type = (pjmedia_jb_frame_type) 
+	*type = (pjmedia_jb_frame_type)
 		framelist->frame_type[pos];
     if (size)
@@ -384,7 +384,7 @@
 /* Remove oldest frames as many as param 'count' */
 static unsigned jb_framelist_remove_head(jb_framelist_t *framelist,
-					 unsigned count) 
-{
-    if (count > framelist->size) 
+					 unsigned count)
+{
+    if (count > framelist->size)
 	count = framelist->size;
 
@@ -410,5 +410,5 @@
 	}
 
-	//pj_bzero(framelist->content + 
+	//pj_bzero(framelist->content +
 	//	    framelist->head * framelist->frame_size,
 	//          step1*framelist->frame_size);
@@ -440,5 +440,5 @@
 	framelist->size -= count;
     }
-    
+
     return count;
 }
@@ -549,7 +549,7 @@
 
 
-PJ_DEF(pj_status_t) pjmedia_jbuf_create(pj_pool_t *pool, 
+PJ_DEF(pj_status_t) pjmedia_jbuf_create(pj_pool_t *pool,
 					const pj_str_t *name,
-					unsigned frame_size, 
+					unsigned frame_size,
 					unsigned ptime,
 					unsigned max_count,
@@ -597,5 +597,5 @@
     PJ_ASSERT_RETURN(prefetch <= jb->jb_max_count, PJ_EINVAL);
 
-    jb->jb_min_prefetch = jb->jb_max_prefetch = 
+    jb->jb_min_prefetch = jb->jb_max_prefetch =
 	jb->jb_prefetch = jb->jb_init_prefetch = prefetch;
 
@@ -676,10 +676,10 @@
 	       "  burst (min/max/avg/dev)=%d/%d/%d/%d frames\n"
 	       "  lost=%d discard=%d empty=%d",
-	       jb_framelist_size(&jb->jb_framelist), 
-	       jb_framelist_eff_size(&jb->jb_framelist), 
+	       jb_framelist_size(&jb->jb_framelist),
+	       jb_framelist_eff_size(&jb->jb_framelist),
 	       jb->jb_prefetch, jb->jb_eff_level,
-	       jb->jb_delay.min, jb->jb_delay.max, jb->jb_delay.mean, 
+	       jb->jb_delay.min, jb->jb_delay.max, jb->jb_delay.mean,
 	       pj_math_stat_get_stddev(&jb->jb_delay),
-	       jb->jb_burst.min, jb->jb_burst.max, jb->jb_burst.mean, 
+	       jb->jb_burst.min, jb->jb_burst.max, jb->jb_burst.mean,
 	       pj_math_stat_get_stddev(&jb->jb_burst),
 	       jb->jb_lost, jb->jb_discard, jb->jb_empty));
@@ -705,12 +705,12 @@
 
 	enum { STABLE_HISTORY_LIMIT = 20 };
-        
+
 	jb->jb_stable_hist++;
-        
-	/* Only update the effective level (and prefetch) if 'stable' 
+
+	/* Only update the effective level (and prefetch) if 'stable'
 	 * condition is reached (not just short time impulse)
 	 */
 	if (jb->jb_stable_hist > STABLE_HISTORY_LIMIT) {
-    	
+
 	    diff = (jb->jb_eff_level - jb->jb_max_hist_level) / 3;
 
@@ -724,5 +724,5 @@
 	    if (jb->jb_init_prefetch) {
 		jb->jb_prefetch = jb->jb_eff_level;
-		if (jb->jb_prefetch < jb->jb_min_prefetch) 
+		if (jb->jb_prefetch < jb->jb_min_prefetch)
 		    jb->jb_prefetch = jb->jb_min_prefetch;
 		if (jb->jb_prefetch > jb->jb_max_prefetch)
@@ -736,4 +736,5 @@
 	    TRACE__((jb->jb_name.ptr,"jb updated(1), lvl=%d pre=%d, size=%d",
 		     jb->jb_eff_level, jb->jb_prefetch, cur_size));
+	    PJ_UNUSED_ARG(cur_size); /* Warning about unused var */
 	}
     }
@@ -759,5 +760,5 @@
 	//jb->jb_max_hist_level = 0;
 
-	TRACE__((jb->jb_name.ptr,"jb updated(2), lvl=%d pre=%d, size=%d", 
+	TRACE__((jb->jb_name.ptr,"jb updated(2), lvl=%d pre=%d, size=%d",
 		 jb->jb_eff_level, jb->jb_prefetch, cur_size));
     }
@@ -778,9 +779,9 @@
      *
      * Moreover, normally drift level is quite low, so JB shouldn't need
-     * to shrink aggresively, it will shrink maximum one frame per 
-     * PJMEDIA_JBUF_DISC_MIN_GAP ms. Theoritically, JB may handle drift level 
+     * to shrink aggresively, it will shrink maximum one frame per
+     * PJMEDIA_JBUF_DISC_MIN_GAP ms. Theoritically, JB may handle drift level
      * as much as = FRAME_PTIME/PJMEDIA_JBUF_DISC_MIN_GAP * 100%
      *
-     * Whenever there is drift, where PUT > GET, this method will keep 
+     * Whenever there is drift, where PUT > GET, this method will keep
      * the latency (JB size) as much as twice of burst level.
      */
@@ -797,6 +798,6 @@
 	int seq_origin;
 
-	/* Check and adjust jb_discard_ref, in case there was 
-	 * seq restart 
+	/* Check and adjust jb_discard_ref, in case there was
+	 * seq restart
 	 */
 	seq_origin = jb_framelist_origin(&jb->jb_framelist);
@@ -814,5 +815,5 @@
 	    jb->jb_discard += diff;
 
-	    TRACE__((jb->jb_name.ptr, 
+	    TRACE__((jb->jb_name.ptr,
 		     "JB shrinking %d frame(s), cur size=%d", diff,
 		     jb_framelist_eff_size(&jb->jb_framelist)));
@@ -846,5 +847,5 @@
 	T = PJMEDIA_JBUF_PRO_DISC_T2;
     else
-	T = PJMEDIA_JBUF_PRO_DISC_T1 + 
+	T = PJMEDIA_JBUF_PRO_DISC_T1 +
 	    (PJMEDIA_JBUF_PRO_DISC_T2 - PJMEDIA_JBUF_PRO_DISC_T1) *
 	    (burst_level - PJMEDIA_JBUF_PRO_DISC_MIN_BURST) /
@@ -874,5 +875,5 @@
     if (last_seq >= (jb->jb_discard_ref + (int)jb->jb_discard_dist)) {
 	int discard_seq;
-	
+
 	discard_seq = jb->jb_discard_ref + jb->jb_discard_dist;
 	if (discard_seq < jb_framelist_origin(&jb->jb_framelist))
@@ -881,5 +882,5 @@
 	jb_framelist_discard(&jb->jb_framelist, discard_seq);
 
-	TRACE__((jb->jb_name.ptr, 
+	TRACE__((jb->jb_name.ptr,
 		"Discard #%d: ref=#%d dist=%d orig=%d size=%d/%d "
 		"burst=%d/%d",
@@ -897,5 +898,5 @@
     }
 }
-    
+
 
 PJ_INLINE(void) jbuf_update(pjmedia_jbuf *jb, int oper)
@@ -905,6 +906,6 @@
 
 	if (jb->jb_status == JB_STATUS_INITIALIZING) {
-	    /* Switch status 'initializing' -> 'processing' after some OP 
-	     * switch cycles and current OP is GET (burst level is calculated 
+	    /* Switch status 'initializing' -> 'processing' after some OP
+	     * switch cycles and current OP is GET (burst level is calculated
 	     * based on PUT burst), so burst calculation is guaranted to be
 	     * performed right after the status switching.
@@ -922,8 +923,8 @@
 	}
 
-	/* Perform jitter calculation based on PUT burst-level only, since 
+	/* Perform jitter calculation based on PUT burst-level only, since
 	 * GET burst-level may not be accurate, e.g: when VAD is active.
 	 * Note that when burst-level is too big, i.e: exceeds jb_max_burst,
-	 * the GET op may be idle, in this case, we better skip the jitter 
+	 * the GET op may be idle, in this case, we better skip the jitter
 	 * calculation.
 	 */
@@ -940,7 +941,7 @@
 }
 
-PJ_DEF(void) pjmedia_jbuf_put_frame( pjmedia_jbuf *jb, 
-				     const void *frame, 
-				     pj_size_t frame_size, 
+PJ_DEF(void) pjmedia_jbuf_put_frame( pjmedia_jbuf *jb,
+				     const void *frame,
+				     pj_size_t frame_size,
 				     int frame_seq)
 {
@@ -948,18 +949,18 @@
 }
 
-PJ_DEF(void) pjmedia_jbuf_put_frame2(pjmedia_jbuf *jb, 
-				     const void *frame, 
-				     pj_size_t frame_size, 
+PJ_DEF(void) pjmedia_jbuf_put_frame2(pjmedia_jbuf *jb,
+				     const void *frame,
+				     pj_size_t frame_size,
 				     pj_uint32_t bit_info,
 				     int frame_seq,
 				     pj_bool_t *discarded)
 {
-    pjmedia_jbuf_put_frame3(jb, frame, frame_size, bit_info, frame_seq, 0, 
+    pjmedia_jbuf_put_frame3(jb, frame, frame_size, bit_info, frame_seq, 0,
 			    discarded);
 }
 
-PJ_DEF(void) pjmedia_jbuf_put_frame3(pjmedia_jbuf *jb, 
-				     const void *frame, 
-				     pj_size_t frame_size, 
+PJ_DEF(void) pjmedia_jbuf_put_frame3(pjmedia_jbuf *jb,
+				     const void *frame,
+				     pj_size_t frame_size,
 				     pj_uint32_t bit_info,
 				     int frame_seq,
@@ -978,5 +979,5 @@
 				 (unsigned)min_frame_size, bit_info, ts,
 				 PJMEDIA_JB_NORMAL_FRAME);
-    
+
     /* Jitter buffer is full, remove some older frames */
     while (status == PJ_ETOOMANY) {
@@ -1010,5 +1011,5 @@
     if (status == PJ_SUCCESS) {
 	if (jb->jb_prefetching) {
-	    TRACE__((jb->jb_name.ptr, "PUT prefetch_cnt=%d/%d", 
+	    TRACE__((jb->jb_name.ptr, "PUT prefetch_cnt=%d/%d",
 		     new_size, jb->jb_prefetch));
 	    if (new_size >= jb->jb_prefetch)
@@ -1024,6 +1025,6 @@
  * Get frame from jitter buffer.
  */
-PJ_DEF(void) pjmedia_jbuf_get_frame( pjmedia_jbuf *jb, 
-				     void *frame, 
+PJ_DEF(void) pjmedia_jbuf_get_frame( pjmedia_jbuf *jb,
+				     void *frame,
 				     char *p_frame_type)
 {
@@ -1035,6 +1036,6 @@
  * Get frame from jitter buffer.
  */
-PJ_DEF(void) pjmedia_jbuf_get_frame2(pjmedia_jbuf *jb, 
-				     void *frame, 
+PJ_DEF(void) pjmedia_jbuf_get_frame2(pjmedia_jbuf *jb,
+				     void *frame,
 				     pj_size_t *size,
 				     char *p_frame_type,
@@ -1048,6 +1049,6 @@
  * Get frame from jitter buffer.
  */
-PJ_DEF(void) pjmedia_jbuf_get_frame3(pjmedia_jbuf *jb, 
-				     void *frame, 
+PJ_DEF(void) pjmedia_jbuf_get_frame3(pjmedia_jbuf *jb,
+				     void *frame,
 				     pj_size_t *size,
 				     char *p_frame_type,
@@ -1078,5 +1079,5 @@
 
 	/* Try to retrieve a frame from frame list */
-	res = jb_framelist_get(&jb->jb_framelist, frame, size, &ftype, 
+	res = jb_framelist_get(&jb->jb_framelist, frame, size, &ftype,
 			       bit_info, ts, seq);
 	if (res) {
@@ -1097,5 +1098,5 @@
 		/* We've just retrieved one frame, so add one to cur_size */
 		cur_size = jb_framelist_eff_size(&jb->jb_framelist) + 1;
-		pj_math_stat_update(&jb->jb_delay, 
+		pj_math_stat_update(&jb->jb_delay,
 				    cur_size*jb->jb_frame_ptime);
 	    }
@@ -1129,14 +1130,14 @@
     state->min_prefetch = jb->jb_min_prefetch;
     state->max_prefetch = jb->jb_max_prefetch;
-    
+
     state->burst = jb->jb_eff_level;
     state->prefetch = jb->jb_prefetch;
     state->size = jb_framelist_eff_size(&jb->jb_framelist);
-    
+
     state->avg_delay = jb->jb_delay.mean;
     state->min_delay = jb->jb_delay.min;
     state->max_delay = jb->jb_delay.max;
     state->dev_delay = pj_math_stat_get_stddev(&jb->jb_delay);
-    
+
     state->avg_burst = jb->jb_burst.mean;
     state->empty = jb->jb_empty;
@@ -1150,6 +1151,6 @@
 PJ_DEF(void) pjmedia_jbuf_peek_frame( pjmedia_jbuf *jb,
 				      unsigned offset,
-				      const void **frame, 
-				      pj_size_t *size, 
+				      const void **frame,
+				      pj_size_t *size,
 				      char *p_frm_type,
 				      pj_uint32_t *bit_info,
@@ -1171,5 +1172,5 @@
 
 
-PJ_DEF(unsigned) pjmedia_jbuf_remove_frame(pjmedia_jbuf *jb, 
+PJ_DEF(unsigned) pjmedia_jbuf_remove_frame(pjmedia_jbuf *jb,
 					   unsigned frame_cnt)
 {
Index: pjproject/trunk/pjmedia/src/pjmedia/stream.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/stream.c	(revision 4727)
+++ pjproject/trunk/pjmedia/src/pjmedia/stream.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <pjmedia/stream.h>
@@ -185,14 +185,14 @@
      */
     pj_bool_t		     has_g722_mpeg_bug;
-					    /**< Flag to specify whether 
-						 normalization process 
+					    /**< Flag to specify whether
+						 normalization process
 						 is needed		    */
     unsigned		     rtp_tx_ts_len_per_pkt;
 					    /**< Normalized ts length per packet
-						 transmitted according to 
+						 transmitted according to
 						 'erroneous' definition	    */
     unsigned		     rtp_rx_ts_len_per_frame;
 					    /**< Normalized ts length per frame
-						 received according to 
+						 received according to
 						 'erroneous' definition	    */
     unsigned		     rtp_rx_last_cnt;/**< Nb of frames in last pkt  */
@@ -203,9 +203,9 @@
 
 #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)
-    pj_uint32_t		     rtcp_xr_last_tx;  /**< RTCP XR tx time 
+    pj_uint32_t		     rtcp_xr_last_tx;  /**< RTCP XR tx time
 					            in timestamp.           */
     pj_uint32_t		     rtcp_xr_interval; /**< Interval, in timestamp. */
-    pj_sockaddr		     rtcp_xr_dest;     /**< Additional remote RTCP XR 
-						    dest. If sin_family is 
+    pj_sockaddr		     rtcp_xr_dest;     /**< Additional remote RTCP XR
+						    dest. If sin_family is
 						    zero, it will be ignored*/
     unsigned		     rtcp_xr_dest_len; /**< Length of RTCP XR dest
@@ -231,6 +231,6 @@
 
 /* RFC 2833 digit */
-static const char digitmap[16] = { '0', '1', '2', '3', 
-				   '4', '5', '6', '7', 
+static const char digitmap[16] = { '0', '1', '2', '3',
+				   '4', '5', '6', '7',
 				   '8', '9', '*', '#',
 				   'A', 'B', 'C', 'D'};
@@ -285,5 +285,5 @@
 }
 
-PJ_INLINE(int) trace_jb_print_state(pjmedia_stream *stream, 
+PJ_INLINE(int) trace_jb_print_state(pjmedia_stream *stream,
 				    char **buf, pj_ssize_t len)
 {
@@ -460,5 +460,5 @@
 
 #else
-    
+
     PJ_UNUSED_ARG(stream);
 
@@ -498,10 +498,10 @@
     samples_per_frame = stream->codec_param.info.frm_ptime *
 			stream->codec_param.info.clock_rate *
-			stream->codec_param.info.channel_cnt / 
+			stream->codec_param.info.channel_cnt /
 			1000;
     p_out_samp = (pj_int16_t*) frame->buf;
 
-    for (samples_count=0; samples_count < samples_required; 
-	 samples_count += samples_per_frame) 
+    for (samples_count=0; samples_count < samples_required;
+	 samples_count += samples_per_frame)
     {
 	char frame_type;
@@ -518,9 +518,9 @@
 
 	if (frame_type == PJMEDIA_JB_MISSING_FRAME) {
-	    
+
 	    /* Activate PLC */
-	    if (stream->codec->op->recover && 
+	    if (stream->codec->op->recover &&
 		stream->codec_param.setting.plc &&
-		stream->plc_cnt < stream->max_plc_cnt) 
+		stream->plc_cnt < stream->max_plc_cnt)
 	    {
 		pjmedia_frame frame_out;
@@ -561,5 +561,5 @@
 	    /* Jitter buffer is empty. If this is the first "empty" state,
 	     * activate PLC to smoothen the fade-out, otherwise zero
-	     * the frame. 
+	     * the frame.
 	     */
 	    //Using this "if" will only invoke PLC for the first packet
@@ -568,7 +568,7 @@
 	    if (1) {
 		/* Activate PLC to smoothen the missing frame */
-		if (stream->codec->op->recover && 
+		if (stream->codec->op->recover &&
 		    stream->codec_param.setting.plc &&
-		    stream->plc_cnt < stream->max_plc_cnt) 
+		    stream->plc_cnt < stream->max_plc_cnt)
 		{
 		    pjmedia_frame frame_out;
@@ -590,5 +590,5 @@
 
 		    with_plc = ", plc invoked";
-		} 
+		}
 	    }
 
@@ -604,6 +604,6 @@
 		/* Report changing frame type event */
 		pjmedia_jbuf_get_state(stream->jb, &jb_state);
-		PJ_LOG(5,(stream->port.info.name.ptr, 
-			  "Jitter buffer empty (prefetch=%d)%s", 
+		PJ_LOG(5,(stream->port.info.name.ptr,
+			  "Jitter buffer empty (prefetch=%d)%s",
 			  jb_state.prefetch, with_plc));
 
@@ -623,7 +623,7 @@
 
 	    /* Always activate PLC when it's available.. */
-	    if (stream->codec->op->recover && 
+	    if (stream->codec->op->recover &&
 		stream->codec_param.setting.plc &&
-		stream->plc_cnt < stream->max_plc_cnt) 
+		stream->plc_cnt < stream->max_plc_cnt)
 	    {
 		pjmedia_frame frame_out;
@@ -645,5 +645,5 @@
 
 		with_plc = ", plc invoked";
-	    } 
+	    }
 
 	    if (samples_count < samples_required) {
@@ -658,6 +658,6 @@
 		/* Report changing frame type event */
 		pjmedia_jbuf_get_state(stream->jb, &jb_state);
-		PJ_LOG(5,(stream->port.info.name.ptr, 
-			  "Jitter buffer is bufferring (prefetch=%d)%s", 
+		PJ_LOG(5,(stream->port.info.name.ptr,
+			  "Jitter buffer is bufferring (prefetch=%d)%s",
 			  jb_state.prefetch, with_plc));
 
@@ -684,11 +684,11 @@
 	    frame_out.size = frame->size - samples_count*BYTES_PER_SAMPLE;
 	    status = pjmedia_codec_decode( stream->codec, &frame_in,
-					   (unsigned)frame_out.size, 
+					   (unsigned)frame_out.size,
 					   &frame_out);
 	    if (status != 0) {
-		LOGERR_((port->info.name.ptr, "codec decode() error", 
+		LOGERR_((port->info.name.ptr, "codec decode() error",
 			 status));
 
-		pjmedia_zero_samples(p_out_samp + samples_count, 
+		pjmedia_zero_samples(p_out_samp + samples_count,
 				     samples_per_frame);
 	    }
@@ -696,5 +696,5 @@
 	    if (stream->jb_last_frm != frame_type) {
 		/* Report changing frame type event */
-		PJ_LOG(5,(stream->port.info.name.ptr, 
+		PJ_LOG(5,(stream->port.info.name.ptr,
 			  "Jitter buffer starts returning normal frames "
 			  "(after %d empty/lost)",
@@ -753,5 +753,5 @@
     samples_per_frame = stream->codec_param.info.frm_ptime *
 			stream->codec_param.info.clock_rate *
-			stream->codec_param.info.channel_cnt / 
+			stream->codec_param.info.channel_cnt /
 			1000;
 
@@ -774,5 +774,5 @@
 	trace_jb_get(stream, frame_type, frame_size);
 #endif
-	
+
 	/* Unlock jitter buffer mutex. */
 	pj_mutex_unlock( stream->jb_mutex );
@@ -791,5 +791,5 @@
 					   0, frame);
 	    if (status != PJ_SUCCESS) {
-		LOGERR_((port->info.name.ptr, "codec decode() error", 
+		LOGERR_((port->info.name.ptr, "codec decode() error",
 			 status));
 		pjmedia_frame_ext_append_subframe(f, NULL, 0,
@@ -799,5 +799,5 @@
 	    if (stream->jb_last_frm != frame_type) {
 		/* Report changing frame type event */
-		PJ_LOG(5,(stream->port.info.name.ptr, 
+		PJ_LOG(5,(stream->port.info.name.ptr,
 			  "Jitter buffer starts returning normal frames "
 			  "(after %d empty/lost)",
@@ -817,5 +817,5 @@
 		status = pjmedia_codec_recover(stream->codec, 0, frame);
 	    }
-	    
+
 	    /* No PLC or PLC failed */
 	    if (!stream->codec->op->recover || status != PJ_SUCCESS) {
@@ -840,6 +840,6 @@
 		    /* Report changing frame type event */
 		    pjmedia_jbuf_get_state(stream->jb, &jb_state);
-		    PJ_LOG(5,(stream->port.info.name.ptr, 
-			      "Jitter buffer empty (prefetch=%d)", 
+		    PJ_LOG(5,(stream->port.info.name.ptr,
+			      "Jitter buffer empty (prefetch=%d)",
 			      jb_state.prefetch));
 
@@ -859,5 +859,5 @@
 		    /* Report changing frame type event */
 		    pjmedia_jbuf_get_state(stream->jb, &jb_state);
-		    PJ_LOG(5,(stream->port.info.name.ptr, 
+		    PJ_LOG(5,(stream->port.info.name.ptr,
 			      "Jitter buffer is bufferring (prefetch=%d)",
 			      jb_state.prefetch));
@@ -879,5 +879,5 @@
  * Transmit DTMF
  */
-static void create_dtmf_payload(pjmedia_stream *stream, 
+static void create_dtmf_payload(pjmedia_stream *stream,
 			        struct pjmedia_frame *frame_out,
 			        int forced_last, int *first, int *last)
@@ -885,5 +885,4 @@
     pjmedia_rtp_dtmf_event *event;
     struct dtmf *digit = &stream->tx_dtmf_buf[0];
-    pj_uint32_t cur_ts;
 
     pj_assert(sizeof(pjmedia_rtp_dtmf_event) == 4);
@@ -892,8 +891,7 @@
 
     event = (pjmedia_rtp_dtmf_event*) frame_out->buf;
-    cur_ts = pj_ntohl(stream->enc->rtp.out_hdr.ts);
 
     if (digit->duration == 0) {
-	PJ_LOG(5,(stream->port.info.name.ptr, "Sending DTMF digit id %c", 
+	PJ_LOG(5,(stream->port.info.name.ptr, "Sending DTMF digit id %c",
 		  digitmap[digit->event]));
 	*first = 1;
@@ -988,12 +986,12 @@
 	/* Update RTCP XR with current JB states */
 	pjmedia_jbuf_get_state(stream->jb, &jb_state);
-    	    
+
 	i = jb_state.avg_delay;
-	status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
+	status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
 					     PJMEDIA_RTCP_XR_INFO_JB_NOM, i);
 	pj_assert(status == PJ_SUCCESS);
 
 	i = jb_state.max_delay;
-	status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
+	status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
 					     PJMEDIA_RTCP_XR_INFO_JB_MAX, i);
 	pj_assert(status == PJ_SUCCESS);
@@ -1008,7 +1006,7 @@
 	    /* Send the RTCP XR to third-party destination if specified */
 	    if (stream->rtcp_xr_dest_len) {
-		pjmedia_transport_send_rtcp2(stream->transport, 
+		pjmedia_transport_send_rtcp2(stream->transport,
 					     &stream->rtcp_xr_dest,
-					     stream->rtcp_xr_dest_len, 
+					     stream->rtcp_xr_dest_len,
 					     xr_pkt, xr_len);
 	    }
@@ -1050,5 +1048,5 @@
 static void check_tx_rtcp(pjmedia_stream *stream, pj_uint32_t timestamp)
 {
-    /* Note that timestamp may represent local or remote timestamp, 
+    /* Note that timestamp may represent local or remote timestamp,
      * depending on whether this function is called from put_frame()
      * or get_frame().
@@ -1056,5 +1054,5 @@
 
     if (stream->rtcp_last_tx == 0) {
-	
+
 	stream->rtcp_last_tx = timestamp;
 
@@ -1067,5 +1065,5 @@
 	    if (stream->rtcp_xr_last_tx == 0) {
 		stream->rtcp_xr_last_tx = timestamp;
-	    } else if (timestamp - stream->rtcp_xr_last_tx >= 
+	    } else if (timestamp - stream->rtcp_xr_last_tx >=
 		       stream->rtcp_xr_interval)
 	    {
@@ -1131,5 +1129,5 @@
 
     /* How many samples are needed */
-    count = stream->codec_param.info.enc_ptime * 
+    count = stream->codec_param.info.enc_ptime *
 	    PJMEDIA_PIA_SRATE(&stream->port.info) / 1000;
 
@@ -1154,5 +1152,5 @@
  * put_frame_imp()
  */
-static pj_status_t put_frame_imp( pjmedia_port *port, 
+static pj_status_t put_frame_imp( pjmedia_port *port,
 				  pjmedia_frame *frame )
 {
@@ -1175,5 +1173,5 @@
 	pj_uint32_t dtx_duration;
 
-	dtx_duration = pj_timestamp_diff32(&stream->last_frm_ts_sent, 
+	dtx_duration = pj_timestamp_diff32(&stream->last_frm_ts_sent,
 					   &frame->timestamp);
 	if (dtx_duration >
@@ -1194,5 +1192,5 @@
     /* Number of samples in the frame */
     if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO)
-	ts_len = ((unsigned)frame->size >> 1) / 
+	ts_len = ((unsigned)frame->size >> 1) /
 		 stream->codec_param.info.channel_cnt;
     else if (frame->type == PJMEDIA_FRAME_TYPE_EXTENDED)
@@ -1206,5 +1204,5 @@
 
 #if defined(PJMEDIA_HANDLE_G722_MPEG_BUG) && (PJMEDIA_HANDLE_G722_MPEG_BUG!=0)
-    /* Handle special case for audio codec with RTP timestamp inconsistence 
+    /* Handle special case for audio codec with RTP timestamp inconsistence
      * e.g: G722, MPEG audio.
      */
@@ -1225,5 +1223,5 @@
 
 
-    /* If we have DTMF digits in the queue, transmit the digits. 
+    /* If we have DTMF digits in the queue, transmit the digits.
      * Otherwise encode the PCM buffer.
      */
@@ -1235,15 +1233,15 @@
 	/* Encapsulate into RTP packet. Note that:
          *  - RTP marker should be set on the beginning of a new event
-	 *  - RTP timestamp is constant for the same packet. 
+	 *  - RTP timestamp is constant for the same packet.
          */
-	status = pjmedia_rtp_encode_rtp( &channel->rtp, 
-					 stream->tx_event_pt, first, 
+	status = pjmedia_rtp_encode_rtp( &channel->rtp,
+					 stream->tx_event_pt, first,
 					 (int)frame_out.size,
-					 (first ? rtp_ts_len : 0), 
-					 (const void**)&rtphdr, 
+					 (first ? rtp_ts_len : 0),
+					 (const void**)&rtphdr,
 					 &rtphdrlen);
 
 	if (last) {
-	    /* This is the last packet for the event. 
+	    /* This is the last packet for the event.
 	     * Increment the RTP timestamp of the RTP session, for next
 	     * RTP packets.
@@ -1272,5 +1270,5 @@
 	       stream->codec_param.info.channel_cnt *
 	       stream->codec_param.info.clock_rate/1000 <
-		  PJ_ARRAY_SIZE(zero_frame)) 
+		  PJ_ARRAY_SIZE(zero_frame))
     {
 	pjmedia_frame silence_frame;
@@ -1283,12 +1281,12 @@
 	silence_frame.type = PJMEDIA_FRAME_TYPE_AUDIO;
 	silence_frame.timestamp.u32.lo = pj_ntohl(stream->enc->rtp.out_hdr.ts);
-	
+
 	/* Encode! */
 	status = pjmedia_codec_encode( stream->codec, &silence_frame,
-				       channel->out_pkt_size - 
+				       channel->out_pkt_size -
 				       sizeof(pjmedia_rtp_hdr),
 				       &frame_out);
 	if (status != PJ_SUCCESS) {
-	    LOGERR_((stream->port.info.name.ptr, 
+	    LOGERR_((stream->port.info.name.ptr,
 		    "Codec encode() error", status));
 	    return status;
@@ -1296,8 +1294,8 @@
 
 	/* Encapsulate. */
-	status = pjmedia_rtp_encode_rtp( &channel->rtp, 
-					 channel->pt, 0, 
-					 (int)frame_out.size, rtp_ts_len, 
-					 (const void**)&rtphdr, 
+	status = pjmedia_rtp_encode_rtp( &channel->rtp,
+					 channel->pt, 0,
+					 (int)frame_out.size, rtp_ts_len,
+					 (const void**)&rtphdr,
 					 &rtphdrlen);
 
@@ -1309,10 +1307,10 @@
     {
 	/* Encode! */
-	status = pjmedia_codec_encode( stream->codec, frame, 
-				       channel->out_pkt_size - 
+	status = pjmedia_codec_encode( stream->codec, frame,
+				       channel->out_pkt_size -
 				       sizeof(pjmedia_rtp_hdr),
 				       &frame_out);
 	if (status != PJ_SUCCESS) {
-	    LOGERR_((stream->port.info.name.ptr, 
+	    LOGERR_((stream->port.info.name.ptr,
 		    "Codec encode() error", status));
 	    return status;
@@ -1320,8 +1318,8 @@
 
 	/* Encapsulate. */
-	status = pjmedia_rtp_encode_rtp( &channel->rtp, 
-					 channel->pt, 0, 
-					 (int)frame_out.size, rtp_ts_len, 
-					 (const void**)&rtphdr, 
+	status = pjmedia_rtp_encode_rtp( &channel->rtp,
+					 channel->pt, 0,
+					 (int)frame_out.size, rtp_ts_len,
+					 (const void**)&rtphdr,
 					 &rtphdrlen);
 
@@ -1329,8 +1327,8 @@
 
 	/* Just update RTP session's timestamp. */
-	status = pjmedia_rtp_encode_rtp( &channel->rtp, 
-					 0, 0, 
-					 0, rtp_ts_len, 
-					 (const void**)&rtphdr, 
+	status = pjmedia_rtp_encode_rtp( &channel->rtp,
+					 0, 0,
+					 0, rtp_ts_len,
+					 (const void**)&rtphdr,
 					 &rtphdrlen);
 
@@ -1338,10 +1336,10 @@
 
     if (status != PJ_SUCCESS) {
-	LOGERR_((stream->port.info.name.ptr, 
+	LOGERR_((stream->port.info.name.ptr,
 		"RTP encode_rtp() error", status));
 	return status;
     }
 
-    /* Check if now is the time to transmit RTCP SR/RR report. 
+    /* Check if now is the time to transmit RTCP SR/RR report.
      * We only do this when stream direction is not "decoding only", because
      * when it is, check_tx_rtcp() will be handled by get_frame().
@@ -1414,5 +1412,5 @@
  * RTP packet, and transmit to peer.
  */
-static pj_status_t put_frame( pjmedia_port *port, 
+static pj_status_t put_frame( pjmedia_port *port,
 			      pjmedia_frame *frame )
 {
@@ -1462,5 +1460,5 @@
      */
     if (stream->vad_enabled != stream->codec_param.setting.vad &&
-	(stream->tx_duration - stream->ts_vad_disabled) > 
+	(stream->tx_duration - stream->ts_vad_disabled) >
            PJMEDIA_PIA_SRATE(&stream->port.info) *
 	  PJMEDIA_STREAM_VAD_SUSPEND_MSEC / 1000)
@@ -1479,5 +1477,5 @@
 	pj_status_t status = PJ_SUCCESS;
 
-	/* Copy original frame to temporary frame since we need 
+	/* Copy original frame to temporary frame since we need
 	 * to modify it.
 	 */
@@ -1546,5 +1544,5 @@
  * Handle incoming DTMF digits.
  */
-static void handle_incoming_dtmf( pjmedia_stream *stream, 
+static void handle_incoming_dtmf( pjmedia_stream *stream,
 				  const void *payload, unsigned payloadlen)
 {
@@ -1572,5 +1570,5 @@
     /* Ignore unknown event. */
     if (event->event > 15) {
-	PJ_LOG(5,(stream->port.info.name.ptr, 
+	PJ_LOG(5,(stream->port.info.name.ptr,
 		  "Ignored RTP pkt with bad DTMF event %d",
     		  event->event));
@@ -1591,5 +1589,5 @@
     if (stream->dtmf_cb) {
 
-	stream->dtmf_cb(stream, stream->dtmf_cb_user_data, 
+	stream->dtmf_cb(stream, stream->dtmf_cb_user_data,
 			digitmap[event->event]);
 
@@ -1601,5 +1599,5 @@
 	if (stream->rx_dtmf_count >= PJ_ARRAY_SIZE(stream->rx_dtmf_buf)) {
 	    /* DTMF digits overflow.  Discard the oldest digit. */
-	    pj_array_erase(stream->rx_dtmf_buf, 
+	    pj_array_erase(stream->rx_dtmf_buf,
 			   sizeof(stream->rx_dtmf_buf[0]),
 			   stream->rx_dtmf_count, 0);
@@ -1614,7 +1612,7 @@
 /*
  * This callback is called by stream transport on receipt of packets
- * in the RTP socket. 
- */
-static void on_rx_rtp( void *data, 
+ * in the RTP socket.
+ */
+static void on_rx_rtp( void *data,
 		       void *pkt,
                        pj_ssize_t bytes_read)
@@ -1632,5 +1630,5 @@
     /* Check for errors */
     if (bytes_read < 0) {
-	LOGERR_((stream->port.info.name.ptr, "RTP recv() error", 
+	LOGERR_((stream->port.info.name.ptr, "RTP recv() error",
 		(pj_status_t)-bytes_read));
 	return;
@@ -1660,7 +1658,7 @@
 			        hdr->pt != stream->rx_event_pt);
     if (seq_st.status.value) {
-	TRC_  ((stream->port.info.name.ptr, 
+	TRC_  ((stream->port.info.name.ptr,
 		"RTP status: badpt=%d, badssrc=%d, dup=%d, "
-		"outorder=%d, probation=%d, restart=%d", 
+		"outorder=%d, probation=%d, restart=%d",
 		seq_st.status.flag.badpt,
 		seq_st.status.flag.badssrc,
@@ -1737,6 +1735,6 @@
 				     payloadlen, &ts, &count, frames);
 	if (status != PJ_SUCCESS) {
-	    LOGERR_((stream->port.info.name.ptr, 
-		     "Codec parse() error", 
+	    LOGERR_((stream->port.info.name.ptr,
+		     "Codec parse() error",
 		     status));
 	    count = 0;
@@ -1746,5 +1744,5 @@
 	/* This code is used to learn the samples per frame value that is put
 	 * by remote endpoint, for codecs with inconsistent clock rate such
-	 * as G.722 or MPEG audio. We need to learn the samples per frame 
+	 * as G.722 or MPEG audio. We need to learn the samples per frame
 	 * value as it is used as divider when inserting frames into the
 	 * jitter buffer.
@@ -1752,9 +1750,9 @@
 	if (stream->has_g722_mpeg_bug) {
 	    if (stream->rtp_rx_check_cnt) {
-		/* Make sure the detection performed only on two consecutive 
+		/* Make sure the detection performed only on two consecutive
 		 * packets with valid RTP sequence and no wrapped timestamp.
 		 */
-		if (seq_st.diff == 1 && stream->rtp_rx_last_ts && 
-		    ts.u64 > stream->rtp_rx_last_ts && 
+		if (seq_st.diff == 1 && stream->rtp_rx_last_ts &&
+		    ts.u64 > stream->rtp_rx_last_ts &&
 		    stream->rtp_rx_last_cnt > 0)
 		{
@@ -1768,6 +1766,6 @@
 
 		    /* Get remote frame timestamp span */
-		    peer_frm_ts_diff = 
-			((pj_uint32_t)ts.u64-stream->rtp_rx_last_ts) / 
+		    peer_frm_ts_diff =
+			((pj_uint32_t)ts.u64-stream->rtp_rx_last_ts) /
 			stream->rtp_rx_last_cnt;
 
@@ -1778,5 +1776,5 @@
 		     */
 		    if (stream->codec_param.info.pt == PJMEDIA_RTP_PT_G722 &&
-			(peer_frm_ts_diff == frm_ts_span || 
+			(peer_frm_ts_diff == frm_ts_span ||
 			 peer_frm_ts_diff == (frm_ts_span>>1)))
 		    {
@@ -1790,7 +1788,7 @@
 			if (--stream->rtp_rx_check_cnt == 0) {
     			    PJ_LOG(4, (THIS_FILE, "G722 codec used, remote"
-				       " samples per frame detected = %d", 
+				       " samples per frame detected = %d",
 				       stream->rtp_rx_ts_len_per_frame));
-			    
+
 			    /* Reset jitter buffer once detection done */
 			    pjmedia_jbuf_reset(stream->jb);
@@ -1811,10 +1809,10 @@
 
 	} else {
-	    ts_span = stream->codec_param.info.frm_ptime * 
+	    ts_span = stream->codec_param.info.frm_ptime *
 		      stream->codec_param.info.clock_rate /
 		      1000;
 	}
 #else
-	ts_span = stream->codec_param.info.frm_ptime * 
+	ts_span = stream->codec_param.info.frm_ptime *
 		  stream->codec_param.info.clock_rate /
 		  1000;
@@ -1842,5 +1840,5 @@
 
     /* Check if now is the time to transmit RTCP SR/RR report.
-     * We only do this when stream direction is "decoding only", 
+     * We only do this when stream direction is "decoding only",
      * because otherwise check_tx_rtcp() will be handled by put_frame()
      */
@@ -1850,5 +1848,5 @@
 
     if (status != 0) {
-	LOGERR_((stream->port.info.name.ptr, "Jitter buffer put() error", 
+	LOGERR_((stream->port.info.name.ptr, "Jitter buffer put() error",
 		status));
 	pkt_discarded = PJ_TRUE;
@@ -1880,8 +1878,8 @@
 /*
  * This callback is called by stream transport on receipt of packets
- * in the RTCP socket. 
+ * in the RTCP socket.
  */
 static void on_rx_rtcp( void *data,
-                        void *pkt, 
+                        void *pkt,
                         pj_ssize_t bytes_read)
 {
@@ -1890,5 +1888,5 @@
     /* Check for errors */
     if (bytes_read < 0) {
-	LOGERR_((stream->port.info.name.ptr, "RTCP recv() error", 
+	LOGERR_((stream->port.info.name.ptr, "RTCP recv() error",
 		(pj_status_t)-bytes_read));
 	return;
@@ -1911,5 +1909,5 @@
     pjmedia_channel *channel;
     pj_status_t status;
-    
+
     /* Allocate memory for channel descriptor */
 
@@ -1924,11 +1922,11 @@
     channel->pt = pt;
 
-    
+
     /* Allocate buffer for outgoing packet. */
 
     if (param->type == PJMEDIA_TYPE_AUDIO) {
-        channel->out_pkt_size = sizeof(pjmedia_rtp_hdr) + 
-			        stream->codec_param.info.max_bps * 
-			        PJMEDIA_MAX_FRAME_DURATION_MS / 
+        channel->out_pkt_size = sizeof(pjmedia_rtp_hdr) +
+			        stream->codec_param.info.max_bps *
+			        PJMEDIA_MAX_FRAME_DURATION_MS /
 			        8 / 1000;
         if (channel->out_pkt_size > PJMEDIA_MAX_MTU -
@@ -2078,6 +2076,6 @@
 	stream->codec_param = *info->param;
     else {
-	status = pjmedia_codec_mgr_get_default_param(stream->codec_mgr, 
-						     &info->fmt, 
+	status = pjmedia_codec_mgr_get_default_param(stream->codec_mgr,
+						     &info->fmt,
 						     &stream->codec_param);
 	if (status != PJ_SUCCESS)
@@ -2137,5 +2135,5 @@
     /* If encoder and decoder's ptime are asymmetric, then we need to
      * create buffer on the encoder side. This could happen for example
-     * with iLBC 
+     * with iLBC
      */
     if (stream->codec_param.info.enc_ptime!=0 &&
@@ -2185,5 +2183,5 @@
         stream->frame_size = stream->codec_param.info.max_rx_frame_size;
     } else {
-        stream->frame_size = stream->codec_param.info.max_bps * 
+        stream->frame_size = stream->codec_param.info.max_bps *
 			     stream->codec_param.info.frm_ptime / 8 / 1000;
         if ((stream->codec_param.info.max_bps *
@@ -2218,5 +2216,5 @@
     /* Init jitter buffer parameters: */
     if (info->jb_max >= stream->codec_param.info.frm_ptime)
-	jb_max = (info->jb_max + stream->codec_param.info.frm_ptime - 1) / 
+	jb_max = (info->jb_max + stream->codec_param.info.frm_ptime - 1) /
 		 stream->codec_param.info.frm_ptime;
     else
@@ -2243,5 +2241,5 @@
     /* Create jitter buffer */
     status = pjmedia_jbuf_create(pool, &stream->port.info.name,
-				 stream->frame_size, 
+				 stream->frame_size,
 				 stream->codec_param.info.frm_ptime,
 				 jb_max, &stream->jb);
@@ -2255,5 +2253,5 @@
     /* Create decoder channel: */
 
-    status = create_channel( pool, stream, PJMEDIA_DIR_DECODING, 
+    status = create_channel( pool, stream, PJMEDIA_DIR_DECODING,
 			     info->rx_pt, info, &stream->dec);
     if (status != PJ_SUCCESS)
@@ -2263,5 +2261,5 @@
     /* Create encoder channel: */
 
-    status = create_channel( pool, stream, PJMEDIA_DIR_ENCODING, 
+    status = create_channel( pool, stream, PJMEDIA_DIR_ENCODING,
 			     info->tx_pt, info, &stream->enc);
     if (status != PJ_SUCCESS)
@@ -2316,7 +2314,7 @@
 
     /* Only attach transport when stream is ready. */
-    status = pjmedia_transport_attach(tp, stream, &info->rem_addr, 
-				      &info->rem_rtcp, 
-				      pj_sockaddr_get_len(&info->rem_addr), 
+    status = pjmedia_transport_attach(tp, stream, &info->rem_addr,
+				      &info->rem_rtcp,
+				      pj_sockaddr_get_len(&info->rem_addr),
                                       &on_rx_rtp, &on_rx_rtcp);
     if (status != PJ_SUCCESS)
@@ -2336,6 +2334,6 @@
 	    stream->rtcp_xr_interval = info->rtcp_xr_interval;
 	else
-	    stream->rtcp_xr_interval = (PJMEDIA_RTCP_INTERVAL + 
-				       (pj_rand() % 8000)) * 
+	    stream->rtcp_xr_interval = (PJMEDIA_RTCP_INTERVAL +
+				       (pj_rand() % 8000)) *
 				       info->fmt.clock_rate / 1000;
 
@@ -2349,5 +2347,5 @@
 	/* jitter buffer adaptive info */
 	i = PJMEDIA_RTCP_XR_JB_ADAPTIVE;
-	pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
+	pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
 				    PJMEDIA_RTCP_XR_INFO_CONF_JBA,
 				    i);
@@ -2355,5 +2353,5 @@
 	/* Jitter buffer aggressiveness info (estimated) */
 	i = 7;
-	pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
+	pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
 				    PJMEDIA_RTCP_XR_INFO_CONF_JBR,
 				    i);
@@ -2361,5 +2359,5 @@
 	/* Jitter buffer absolute maximum delay */
 	i = jb_max * stream->codec_param.info.frm_ptime;
-	pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
+	pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
 				    PJMEDIA_RTCP_XR_INFO_JB_ABS_MAX,
 				    i);
@@ -2374,5 +2372,5 @@
 	    i = PJMEDIA_RTCP_XR_PLC_DIS;
 #endif
-	pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 
+	pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
 				    PJMEDIA_RTCP_XR_INFO_CONF_PLC,
 				    i);
@@ -2396,5 +2394,5 @@
 	pj_ssize_t len;
 
-	pj_ansi_snprintf(trace_name, sizeof(trace_name), 
+	pj_ansi_snprintf(trace_name, sizeof(trace_name),
 			 TRACE_JB_PATH_PREFIX "%s.csv",
 			 stream->port.info.name.ptr);
@@ -2402,5 +2400,5 @@
 	if (status != PJ_SUCCESS) {
 	    stream->trace_jb_fd = TRACE_JB_INVALID_FD;
-	    PJ_LOG(3,(THIS_FILE, "Failed creating RTP trace file '%s'", 
+	    PJ_LOG(3,(THIS_FILE, "Failed creating RTP trace file '%s'",
 		      trace_name));
 	} else {
@@ -2490,5 +2488,5 @@
     }
 
-    /* Detach from transport 
+    /* Detach from transport
      * MUST NOT hold stream mutex while detaching from transport, as
      * it may cause deadlock. See ticket #460 for the details.
@@ -2513,5 +2511,5 @@
 
     /* Free mutex */
-    
+
     if (stream->jb_mutex) {
 	pj_mutex_destroy(stream->jb_mutex);
@@ -2724,7 +2722,7 @@
 	return PJMEDIA_RTP_EREMNORFC2833;
     }
-    
+
     pj_mutex_lock(stream->jb_mutex);
-    
+
     if (stream->tx_dtmf_count+digit_char->slen >=
 	(long)PJ_ARRAY_SIZE(stream->tx_dtmf_buf))
@@ -2735,5 +2733,5 @@
 
 	/* convert ASCII digits into payload type first, to make sure
-	 * that all digits are valid. 
+	 * that all digits are valid.
 	 */
 	for (i=0; i<digit_char->slen; ++i) {
@@ -2744,5 +2742,5 @@
 	    {
 		pt = dig - '0';
-	    } 
+	    }
 	    else if (dig >= 'a' && dig <= 'd')
 	    {
@@ -2830,7 +2828,7 @@
  */
 PJ_DEF(pj_status_t) pjmedia_stream_set_dtmf_callback(pjmedia_stream *stream,
-				 void (*cb)(pjmedia_stream*, 
-					    void *user_data, 
-					    int digit), 
+				 void (*cb)(pjmedia_stream*,
+					    void *user_data,
+					    int digit),
 				 void *user_data)
 {
Index: pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c	(revision 4727)
+++ pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
@@ -46,5 +46,5 @@
 #define MAX_KEY_LEN		    128
 
-/* Initial value of probation counter. When probation counter > 0, 
+/* Initial value of probation counter. When probation counter > 0,
  * it means SRTP is in probation state, and it may restart when
  * srtp_unprotect() returns err_status_replay_*
@@ -77,5 +77,5 @@
 
     /* cipher AES_CM, auth HMAC_SHA1, auth tag len = 10 octets */
-    {"AES_CM_128_HMAC_SHA1_80", AES_128_ICM, 30, HMAC_SHA1, 20, 10, 10, 
+    {"AES_CM_128_HMAC_SHA1_80", AES_128_ICM, 30, HMAC_SHA1, 20, 10, 10,
 	sec_serv_conf_and_auth},
 
@@ -84,5 +84,5 @@
 	sec_serv_conf_and_auth},
 
-    /* 
+    /*
      * F8_128_HMAC_SHA1_8 not supported by libsrtp?
      * {"F8_128_HMAC_SHA1_8", NULL_CIPHER, 0, NULL_AUTH, 0, 0, 0, sec_serv_none}
@@ -125,5 +125,5 @@
 				   void *pkt,
 				   pj_ssize_t size);
-        
+
     /* Transport information */
     pjmedia_transport	*member_tp; /**< Underlying transport.       */
@@ -131,10 +131,10 @@
     /* SRTP usage policy of peer. This field is updated when media is starting.
      * This is useful when SRTP is in optional mode and peer is using mandatory
-     * mode, so when local is about to reinvite/update, it should offer 
+     * mode, so when local is about to reinvite/update, it should offer
      * RTP/SAVP instead of offering RTP/AVP.
      */
     pjmedia_srtp_use	 peer_use;
 
-    /* When probation counter > 0, it means SRTP is in probation state, 
+    /* When probation counter > 0, it means SRTP is in probation state,
      * and it may restart when srtp_unprotect() returns err_status_replay_*
      */
@@ -206,5 +206,5 @@
 
 
-static pjmedia_transport_op transport_srtp_op = 
+static pjmedia_transport_op transport_srtp_op =
 {
     &transport_get_info,
@@ -239,15 +239,15 @@
 	"couldn't deallocate properly",	    /* err_status_dealloc_fail  = 4  */
 	"couldn't initialize",		    /* err_status_init_fail     = 5  */
-	"can't process as much data as requested", 
+	"can't process as much data as requested",
 					    /* err_status_terminus      = 6  */
 	"authentication failure",	    /* err_status_auth_fail     = 7  */
 	"cipher failure",		    /* err_status_cipher_fail   = 8  */
 	"replay check failed (bad index)",  /* err_status_replay_fail   = 9  */
-	"replay check failed (index too old)", 
+	"replay check failed (index too old)",
 					    /* err_status_replay_old    = 10 */
 	"algorithm failed test routine",    /* err_status_algo_fail     = 11 */
 	"unsupported operation",	    /* err_status_no_such_op    = 12 */
 	"no appropriate context found",	    /* err_status_no_ctx        = 13 */
-	"unable to perform desired validation", 
+	"unable to perform desired validation",
 					    /* err_status_cant_check    = 14 */
 	"can't use key any more",	    /* err_status_key_expired   = 15 */
@@ -286,6 +286,6 @@
 
 	err = srtp_init();
-	if (err != err_status_ok) { 
-	    PJ_LOG(4, (THIS_FILE, "Failed to initialize libsrtp: %s", 
+	if (err != err_status_ok) {
+	    PJ_LOG(4, (THIS_FILE, "Failed to initialize libsrtp: %s",
 		       get_libsrtp_errstr(err)));
 	    return PJMEDIA_ERRNO_FROM_LIBSRTP(err);
@@ -294,7 +294,7 @@
 	if (pjmedia_endpt_atexit(endpt, pjmedia_srtp_deinit_lib) != PJ_SUCCESS)
 	{
-	    /* There will be memory leak when it fails to schedule libsrtp 
+	    /* There will be memory leak when it fails to schedule libsrtp
 	     * deinitialization, however the memory leak could be harmless,
-	     * since in modern OS's memory used by an application is released 
+	     * since in modern OS's memory used by an application is released
 	     * when the application terminates.
 	     */
@@ -307,5 +307,5 @@
     PJ_UNUSED_ARG(endpt);
 #endif
-    
+
     return PJ_SUCCESS;
 }
@@ -338,5 +338,5 @@
 #endif
     if (err != err_status_ok) {
-	PJ_LOG(4, (THIS_FILE, "Failed to deinitialize libsrtp: %s", 
+	PJ_LOG(4, (THIS_FILE, "Failed to deinitialize libsrtp: %s",
 		   get_libsrtp_errstr(err)));
     }
@@ -350,5 +350,5 @@
     int i;
     int cs_cnt = sizeof(crypto_suites)/sizeof(crypto_suites[0]);
-    
+
     /* treat unspecified crypto_name as crypto 'NULL' */
     if (crypto_name->slen == 0)
@@ -421,5 +421,5 @@
 
     /* Check crypto availability */
-    if (opt && opt->crypto_count == 0 && 
+    if (opt && opt->crypto_count == 0 &&
 	opt->use == PJMEDIA_SRTP_MANDATORY)
 	return PJMEDIA_SRTP_ESDPREQCRYPTO;
@@ -435,6 +435,6 @@
 
 	    /* check key length */
-	    if (opt->crypto[i].key.slen && 
-		opt->crypto[i].key.slen < 
+	    if (opt->crypto[i].key.slen &&
+		opt->crypto[i].key.slen <
 		(pj_ssize_t)crypto_suites[cs_idx].cipher_key_len)
 		return PJMEDIA_SRTP_EINKEYLEN;
@@ -506,5 +506,5 @@
  */
 PJ_DEF(pj_status_t) pjmedia_transport_srtp_start(
-			   pjmedia_transport *tp, 
+			   pjmedia_transport *tp,
 			   const pjmedia_srtp_crypto *tx,
 			   const pjmedia_srtp_crypto *rx)
@@ -518,5 +518,4 @@
     int		     cr_rx_idx = 0;
     int		     au_rx_idx = 0;
-    int		     crypto_suites_cnt;
     pj_status_t	     status = PJ_SUCCESS;
 
@@ -528,6 +527,4 @@
 	pjmedia_transport_srtp_stop(tp);
     }
-
-    crypto_suites_cnt = sizeof(crypto_suites)/sizeof(crypto_suites[0]);
 
     /* Get encryption and authentication method */
@@ -545,5 +542,5 @@
 
     /* Check whether the crypto-suite requested is supported */
-    if (cr_tx_idx == -1 || cr_rx_idx == -1 || au_tx_idx == -1 || 
+    if (cr_tx_idx == -1 || cr_rx_idx == -1 || au_tx_idx == -1 ||
 	au_rx_idx == -1)
     {
@@ -648,5 +645,5 @@
 	else
 	    b64[b64_len] = '\0';
-        
+
 	PJ_LOG(5, (srtp->pool->obj_name, "TX: %s key=%s",
 		   srtp->tx_policy.name.ptr, b64));
@@ -700,5 +697,5 @@
     err = srtp_dealloc(p_srtp->srtp_rx_ctx);
     if (err != err_status_ok) {
-	PJ_LOG(4, (p_srtp->pool->obj_name, 
+	PJ_LOG(4, (p_srtp->pool->obj_name,
 		   "Failed to dealloc RX SRTP context: %s",
 		   get_libsrtp_errstr(err)));
@@ -706,5 +703,5 @@
     err = srtp_dealloc(p_srtp->srtp_tx_ctx);
     if (err != err_status_ok) {
-	PJ_LOG(4, (p_srtp->pool->obj_name, 
+	PJ_LOG(4, (p_srtp->pool->obj_name,
 		   "Failed to dealloc TX SRTP context: %s",
 		   get_libsrtp_errstr(err)));
@@ -753,5 +750,5 @@
     info->spc_info[spc_info_idx].type = PJMEDIA_TRANSPORT_TYPE_SRTP;
     info->spc_info[spc_info_idx].cbsize = sizeof(srtp_info);
-    pj_memcpy(&info->spc_info[spc_info_idx].buffer, &srtp_info, 
+    pj_memcpy(&info->spc_info[spc_info_idx].buffer, &srtp_info,
 	      sizeof(srtp_info));
 
@@ -782,5 +779,5 @@
 
     /* Attach itself to transport */
-    status = pjmedia_transport_attach(srtp->member_tp, srtp, rem_addr, 
+    status = pjmedia_transport_attach(srtp->member_tp, srtp, rem_addr,
 				      rem_rtcp, addr_len, &srtp_rtp_cb,
 				      &srtp_rtcp_cb);
@@ -842,10 +839,10 @@
 
     if (err == err_status_ok) {
-	status = pjmedia_transport_send_rtp(srtp->member_tp, 
+	status = pjmedia_transport_send_rtp(srtp->member_tp,
 					    srtp->rtp_tx_buffer, len);
     } else {
 	status = PJMEDIA_ERRNO_FROM_LIBSRTP(err);
     }
-    
+
     return status;
 }
@@ -870,5 +867,5 @@
 
     if (srtp->bypass_srtp) {
-	return pjmedia_transport_send_rtcp2(srtp->member_tp, addr, addr_len, 
+	return pjmedia_transport_send_rtcp2(srtp->member_tp, addr, addr_len,
 	                                    pkt, size);
     }
@@ -903,5 +900,5 @@
 {
     transport_srtp *srtp = (transport_srtp *) tp;
-    
+
     PJ_ASSERT_RETURN(tp, PJ_EINVAL);
 
@@ -965,11 +962,11 @@
     }
     err = srtp_unprotect(srtp->srtp_rx_ctx, (pj_uint8_t*)pkt, &len);
-    if (srtp->probation_cnt > 0 && 
-	(err == err_status_replay_old || err == err_status_replay_fail)) 
+    if (srtp->probation_cnt > 0 &&
+	(err == err_status_replay_old || err == err_status_replay_fail))
     {
 	/* Handle such condition that stream is updated (RTP seq is reinited
-	 * & SRTP is restarted), but some old packets are still coming 
+	 * & SRTP is restarted), but some old packets are still coming
 	 * so SRTP is learning wrong RTP seq. While the newly inited RTP seq
-	 * comes, SRTP thinks the RTP seq is replayed, so srtp_unprotect() 
+	 * comes, SRTP thinks the RTP seq is replayed, so srtp_unprotect()
 	 * will return err_status_replay_*. Restarting SRTP can resolve this.
 	 */
@@ -982,5 +979,5 @@
 					      &tx, &rx);
 	if (status != PJ_SUCCESS) {
-	    PJ_LOG(5,(srtp->pool->obj_name, "Failed to restart SRTP, err=%s", 
+	    PJ_LOG(5,(srtp->pool->obj_name, "Failed to restart SRTP, err=%s",
 		      get_libsrtp_errstr(err)));
 	} else if (!srtp->bypass_srtp) {
@@ -990,6 +987,6 @@
 
     if (err != err_status_ok) {
-	PJ_LOG(5,(srtp->pool->obj_name, 
-		  "Failed to unprotect SRTP, pkt size=%d, err=%s", 
+	PJ_LOG(5,(srtp->pool->obj_name,
+		  "Failed to unprotect SRTP, pkt size=%d, err=%s",
 		  size, get_libsrtp_errstr(err)));
     } else {
@@ -1036,5 +1033,5 @@
     err = srtp_unprotect_rtcp(srtp->srtp_rx_ctx, (pj_uint8_t*)pkt, &len);
     if (err != err_status_ok) {
-	PJ_LOG(5,(srtp->pool->obj_name, 
+	PJ_LOG(5,(srtp->pool->obj_name,
 		  "Failed to unprotect SRTCP, pkt size=%d, err=%s",
 		  size, get_libsrtp_errstr(err)));
@@ -1056,5 +1053,5 @@
  */
 static pj_status_t generate_crypto_attr_value(pj_pool_t *pool,
-					      char *buffer, int *buffer_len, 
+					      char *buffer, int *buffer_len,
 					      pjmedia_srtp_crypto *crypto,
 					      int tag)
@@ -1088,5 +1085,5 @@
 	    key_ok = PJ_TRUE;
 
-	    err = crypto_get_random((unsigned char*)key, 
+	    err = crypto_get_random((unsigned char*)key,
 				     crypto_suites[cs_idx].cipher_key_len);
 	    if (err != err_status_ok) {
@@ -1100,5 +1097,5 @@
 	} while (!key_ok);
 	crypto->key.ptr = (char*)
-			  pj_pool_zalloc(pool, 
+			  pj_pool_zalloc(pool,
 					 crypto_suites[cs_idx].cipher_key_len);
 	pj_memcpy(crypto->key.ptr, key, crypto_suites[cs_idx].cipher_key_len);
@@ -1118,5 +1115,5 @@
 
     b64_key[b64_key_len] = '\0';
-    
+
     PJ_ASSERT_RETURN(*buffer_len >= (crypto->name.slen + \
 		     b64_key_len + 16), PJ_ETOOSMALL);
@@ -1124,5 +1121,5 @@
     /* Print the crypto attribute value. */
     print_len = pj_ansi_snprintf(buffer, *buffer_len, "%d %s inline:%s",
-				   tag, 
+				   tag,
 				   crypto_suites[cs_idx].name,
 				   b64_key);
@@ -1206,5 +1203,5 @@
     crypto->key.ptr = (char*) pj_pool_zalloc(pool, MAX_KEY_LEN);
     itmp = MAX_KEY_LEN;
-    status = pj_base64_decode(&tmp, (pj_uint8_t*)crypto->key.ptr, 
+    status = pj_base64_decode(&tmp, (pj_uint8_t*)crypto->key.ptr,
 			      &itmp);
     if (status != PJ_SUCCESS) {
@@ -1227,5 +1224,5 @@
 
     PJ_ASSERT_RETURN(tp, PJ_EINVAL);
-    
+
     pj_bzero(&srtp->rx_policy_neg, sizeof(srtp->rx_policy_neg));
     pj_bzero(&srtp->tx_policy_neg, sizeof(srtp->tx_policy_neg));
@@ -1275,5 +1272,5 @@
 
 PROPAGATE_MEDIA_CREATE:
-    return pjmedia_transport_media_create(srtp->member_tp, sdp_pool, 
+    return pjmedia_transport_media_create(srtp->member_tp, sdp_pool,
 					  member_tp_option, sdp_remote,
 					  media_index);
@@ -1297,5 +1294,5 @@
 
     PJ_ASSERT_RETURN(tp && sdp_pool && sdp_local, PJ_EINVAL);
-    
+
     pj_bzero(&srtp->rx_policy_neg, sizeof(srtp->rx_policy_neg));
     pj_bzero(&srtp->tx_policy_neg, sizeof(srtp->tx_policy_neg));
@@ -1307,5 +1304,5 @@
 
     /* Bypass if media transport is not RTP/AVP or RTP/SAVP */
-    if (pj_stricmp(&m_loc->desc.transport, &ID_RTP_AVP)  != 0 && 
+    if (pj_stricmp(&m_loc->desc.transport, &ID_RTP_AVP)  != 0 &&
 	pj_stricmp(&m_loc->desc.transport, &ID_RTP_SAVP) != 0)
 	goto BYPASS_SRTP;
@@ -1318,10 +1315,10 @@
      */
     /*
-    if (pjmedia_sdp_media_find_attr(m_loc, &ID_INACTIVE, NULL) || 
+    if (pjmedia_sdp_media_find_attr(m_loc, &ID_INACTIVE, NULL) ||
 	(m_rem && pjmedia_sdp_media_find_attr(m_rem, &ID_INACTIVE, NULL)))
 	goto BYPASS_SRTP;
     */
 
-    /* Check remote media transport & set local media transport 
+    /* Check remote media transport & set local media transport
      * based on SRTP usage option.
      */
@@ -1333,5 +1330,5 @@
 		goto BYPASS_SRTP;
 	    case PJMEDIA_SRTP_OPTIONAL:
-		m_loc->desc.transport = 
+		m_loc->desc.transport =
 				(srtp->peer_use == PJMEDIA_SRTP_MANDATORY)?
 				ID_RTP_SAVP : ID_RTP_AVP;
@@ -1356,5 +1353,5 @@
 		if (buffer_len) {
 		    pj_strset(&attr_value, buffer, buffer_len);
-		    attr = pjmedia_sdp_attr_create(srtp->pool, ID_CRYPTO.ptr, 
+		    attr = pjmedia_sdp_attr_create(srtp->pool, ID_CRYPTO.ptr,
 						   &attr_value);
 		    m_loc->attr[m_loc->attr_count++] = attr;
@@ -1401,9 +1398,9 @@
 		has_crypto_attr = PJ_TRUE;
 
-		status = parse_attr_crypto(srtp->pool, m_rem->attr[i], 
+		status = parse_attr_crypto(srtp->pool, m_rem->attr[i],
 					   &tmp_rx_crypto, &tags[cr_attr_count]);
 		if (status != PJ_SUCCESS)
 		    return status;
-    	 
+
 		/* Check duplicated tag */
 		for (j=0; j<cr_attr_count; ++j) {
@@ -1417,5 +1414,5 @@
 		    /* lets see if the crypto-suite offered is supported */
 		    for (j=0; j<srtp->setting.crypto_count; ++j)
-			if (pj_stricmp(&tmp_rx_crypto.name, 
+			if (pj_stricmp(&tmp_rx_crypto.name,
 				       &srtp->setting.crypto[j].name) == 0)
 			{
@@ -1434,9 +1431,9 @@
 			    //		hex_test_key,
 			    //		strlen(hex_test_key));
-			    //pj_strset(test_key, raw_test_key, 
+			    //pj_strset(test_key, raw_test_key,
 			    //	  crypto_suites[cs_idx].cipher_key_len);
 			    /* EO Force to use test key */
 
-			    if (tmp_rx_crypto.key.slen != 
+			    if (tmp_rx_crypto.key.slen !=
 				(int)crypto_suites[cs_idx].cipher_key_len)
 				return PJMEDIA_SRTP_EINKEYLEN;
@@ -1459,9 +1456,9 @@
 		case PJMEDIA_SRTP_OPTIONAL:
 		    /* bypass SRTP when no crypto-attr and remote uses RTP/AVP */
-		    if (!has_crypto_attr && 
+		    if (!has_crypto_attr &&
 			pj_stricmp(&m_rem->desc.transport, &ID_RTP_AVP) == 0)
 			goto BYPASS_SRTP;
 		    /* bypass SRTP when nothing match and remote uses RTP/AVP */
-		    else if (matched_idx == -1 && 
+		    else if (matched_idx == -1 &&
 			pj_stricmp(&m_rem->desc.transport, &ID_RTP_AVP) == 0)
 			goto BYPASS_SRTP;
@@ -1485,5 +1482,5 @@
 	    }
 
-	    /* we have to generate crypto answer, 
+	    /* we have to generate crypto answer,
 	     * with srtp->tx_policy_neg matched the offer
 	     * and rem_tag contains matched offer tag.
@@ -1497,9 +1494,9 @@
 
 	    srtp->tx_policy_neg = srtp->setting.crypto[matched_idx];
-	    
+
 	    /* If buffer_len==0, just skip the crypto attribute. */
 	    if (buffer_len) {
 		pj_strset(&attr_value, buffer, buffer_len);
-		attr = pjmedia_sdp_attr_create(sdp_pool, ID_CRYPTO.ptr, 
+		attr = pjmedia_sdp_attr_create(sdp_pool, ID_CRYPTO.ptr,
 					       &attr_value);
 		m_loc->attr[m_loc->attr_count++] = attr;
@@ -1508,5 +1505,5 @@
 	    /* At this point, we get valid rx_policy_neg & tx_policy_neg. */
 	}
-	    
+
     }
     goto PROPAGATE_MEDIA_CREATE;
@@ -1519,5 +1516,5 @@
 
 PROPAGATE_MEDIA_CREATE:
-    return pjmedia_transport_encode_sdp(srtp->member_tp, sdp_pool, 
+    return pjmedia_transport_encode_sdp(srtp->member_tp, sdp_pool,
 					sdp_local, sdp_remote, media_index);
 }
@@ -1548,5 +1545,5 @@
     /* For answerer side, this function will just have to start SRTP */
 
-    /* Check remote media transport & set local media transport 
+    /* Check remote media transport & set local media transport
      * based on SRTP usage option.
      */
@@ -1561,5 +1558,5 @@
 	    // Regardless the answer's transport type (RTP/AVP or RTP/SAVP),
 	    // the answer must be processed through in optional mode.
-	    // Please note that at this point transport type is ensured to be 
+	    // Please note that at this point transport type is ensured to be
 	    // RTP/AVP or RTP/SAVP, see transport_media_create()
 	    //if (pj_stricmp(&m_rem->desc.transport, &m_loc->desc.transport)) {
@@ -1574,5 +1571,5 @@
 	}
     }
-    
+
     if (srtp->offerer_side) {
 	/* find supported crypto-suite, get the tag, and assign policy_local */
@@ -1593,5 +1590,5 @@
 	    has_crypto_attr = PJ_TRUE;
 
-	    status = parse_attr_crypto(srtp->pool, m_rem->attr[i], 
+	    status = parse_attr_crypto(srtp->pool, m_rem->attr[i],
 				       &tmp_tx_crypto, &rem_tag);
 	    if (status != PJ_SUCCESS)
@@ -1606,5 +1603,5 @@
 
 	    /* match the crypto name */
-	    if (pj_stricmp(&tmp_tx_crypto.name, 
+	    if (pj_stricmp(&tmp_tx_crypto.name,
 		&srtp->setting.crypto[rem_tag-1].name) != 0)
 	    {
@@ -1634,5 +1631,5 @@
 
     /* Make sure we have the SRTP policies */
-    if (srtp_crypto_empty(&srtp->tx_policy_neg) || 
+    if (srtp_crypto_empty(&srtp->tx_policy_neg) ||
 	srtp_crypto_empty(&srtp->rx_policy_neg))
     {
@@ -1671,5 +1668,5 @@
 
 PROPAGATE_MEDIA_START:
-    return pjmedia_transport_media_start(srtp->member_tp, pool, 
+    return pjmedia_transport_media_start(srtp->member_tp, pool,
 					 sdp_local, sdp_remote,
 				         media_index);
@@ -1685,5 +1682,5 @@
     status = pjmedia_transport_media_stop(srtp->member_tp);
     if (status != PJ_SUCCESS)
-	PJ_LOG(4, (srtp->pool->obj_name, 
+	PJ_LOG(4, (srtp->pool->obj_name,
 		   "SRTP failed stop underlying media transport."));
 
@@ -1720,8 +1717,8 @@
     else
 	err = srtp_unprotect_rtcp(srtp->srtp_rx_ctx, pkt, pkt_len);
-    
+
     if (err != err_status_ok) {
-	PJ_LOG(5,(srtp->pool->obj_name, 
-		  "Failed to unprotect SRTP, pkt size=%d, err=%s", 
+	PJ_LOG(5,(srtp->pool->obj_name,
+		  "Failed to unprotect SRTP, pkt size=%d, err=%s",
 		  *pkt_len, get_libsrtp_errstr(err)));
     }
Index: pjproject/trunk/pjmedia/src/test/jbuf_test.c
===================================================================
--- pjproject/trunk/pjmedia/src/test/jbuf_test.c	(revision 4727)
+++ pjproject/trunk/pjmedia/src/test/jbuf_test.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <stdio.h>
@@ -48,5 +48,5 @@
 } test_cond_t;
 
-static pj_bool_t parse_test_headers(char *line, test_param_t *param, 
+static pj_bool_t parse_test_headers(char *line, test_param_t *param,
 			       test_cond_t *cond)
 {
@@ -57,5 +57,5 @@
 	char mode_st[16];
 
-	sscanf(p+1, "%s %u %u %u", mode_st, &param->init_prefetch, 
+	sscanf(p+1, "%s %u %u %u", mode_st, &param->init_prefetch,
 	       &param->min_prefetch, &param->max_prefetch);
 	param->adaptive = (pj_ansi_stricmp(mode_st, "adaptive") == 0);
@@ -103,5 +103,5 @@
 }
 
-static pj_bool_t process_test_data(char data, pjmedia_jbuf *jb, 
+static pj_bool_t process_test_data(char data, pjmedia_jbuf *jb,
 				   pj_uint16_t *seq, pj_uint16_t *last_seq)
 {
@@ -156,7 +156,9 @@
 
 	pjmedia_jbuf_get_state(jb, &state);
-	printf("seq=%d\t%c\tsize=%d\tprefetch=%d\n", 
+	printf("seq=%d\t%c\tsize=%d\tprefetch=%d\n",
 	       *last_seq, toupper(data), state.size, state.prefetch);
     }
+#else
+    PJ_UNUSED_ARG(print_state); /* Warning about variable set but unused */
 #endif
 
@@ -171,5 +173,5 @@
     int rc = 0;
     const char* input_filename = "Jbtest.dat";
-    const char* input_search_path[] = { 
+    const char* input_search_path[] = {
 	"../build",
 	"pjmedia/build",
@@ -192,5 +194,5 @@
 	}
     }
-    
+
     /* Failed to open test data file. */
     if (input == NULL) {
@@ -245,6 +247,6 @@
 
 	if (param.adaptive) {
-	    pjmedia_jbuf_set_adaptive(jb, 
-				      param.init_prefetch, 
+	    pjmedia_jbuf_set_adaptive(jb,
+				      param.init_prefetch,
 				      param.min_prefetch,
 				      param.max_prefetch);
@@ -255,6 +257,6 @@
 #ifdef REPORT
 	pjmedia_jbuf_get_state(jb, &state);
-	printf("Initial\tsize=%d\tprefetch=%d\tmin.pftch=%d\tmax.pftch=%d\n", 
-	       state.size, state.prefetch, state.min_prefetch, 
+	printf("Initial\tsize=%d\tprefetch=%d\tmin.pftch=%d\tmax.pftch=%d\n",
+	       state.size, state.prefetch, state.min_prefetch,
 	       state.max_prefetch);
 #endif
@@ -264,5 +266,5 @@
 	while (1) {
 	    char c;
-	    
+
 	    /* Get next line of test data */
 	    if (!p || *p == 0) {
@@ -302,22 +304,22 @@
 	printf("  size=%d prefetch=%d\n", state.size, state.prefetch);
 	printf("  delay (min/max/avg/dev)=%d/%d/%d/%d ms\n",
-	       state.min_delay, state.max_delay, state.avg_delay, 
+	       state.min_delay, state.max_delay, state.avg_delay,
 	       state.dev_delay);
-	printf("  lost=%d discard=%d empty=%d burst(avg)=%d\n", 
+	printf("  lost=%d discard=%d empty=%d burst(avg)=%d\n",
 	       state.lost, state.discard, state.empty, state.avg_burst);
 
 	/* Evaluate test session */
 	if (cond.burst >= 0 && (int)state.avg_burst > cond.burst) {
-	    printf("! 'Burst' should be %d, it is %d\n", 
+	    printf("! 'Burst' should be %d, it is %d\n",
 		   cond.burst, state.avg_burst);
 	    rc |= 1;
 	}
 	if (cond.delay >= 0 && (int)state.avg_delay/JB_PTIME > cond.delay) {
-	    printf("! 'Delay' should be %d, it is %d\n", 
+	    printf("! 'Delay' should be %d, it is %d\n",
 		   cond.delay, state.avg_delay/JB_PTIME);
 	    rc |= 2;
 	}
 	if (cond.delay_min >= 0 && (int)state.min_delay/JB_PTIME > cond.delay_min) {
-	    printf("! 'Minimum delay' should be %d, it is %d\n", 
+	    printf("! 'Minimum delay' should be %d, it is %d\n",
 		   cond.delay_min, state.min_delay/JB_PTIME);
 	    rc |= 32;
@@ -329,10 +331,10 @@
 	}
 	if (cond.empty >= 0 && (int)state.empty > cond.empty) {
-	    printf("! 'Empty' should be %d, it is %d\n", 
+	    printf("! 'Empty' should be %d, it is %d\n",
 		   cond.empty, state.empty);
 	    rc |= 8;
 	}
 	if (cond.lost >= 0 && (int)state.lost > cond.lost) {
-	    printf("! 'Lost' should be %d, it is %d\n", 
+	    printf("! 'Lost' should be %d, it is %d\n",
 		   cond.lost, state.lost);
 	    rc |= 16;
Index: pjproject/trunk/pjnath/src/pjnath-test/ice_test.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath-test/ice_test.c	(revision 4727)
+++ pjproject/trunk/pjnath/src/pjnath-test/ice_test.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "test.h"
@@ -113,9 +113,9 @@
 
 static void ice_on_rx_data(pj_ice_strans *ice_st,
-			   unsigned comp_id, 
+			   unsigned comp_id,
 			   void *pkt, pj_size_t size,
 			   const pj_sockaddr_t *src_addr,
 			   unsigned src_addr_len);
-static void ice_on_ice_complete(pj_ice_strans *ice_st, 
+static void ice_on_ice_complete(pj_ice_strans *ice_st,
 			        pj_ice_strans_op op,
 			        pj_status_t status);
@@ -202,5 +202,5 @@
     return PJ_SUCCESS;
 }
-			     
+
 /* Create test session */
 static int create_sess(pj_stun_config *stun_cfg,
@@ -239,5 +239,5 @@
 	return -10;
     }
-    sess->server->turn_respond_allocate = 
+    sess->server->turn_respond_allocate =
 	sess->server->turn_respond_refresh = PJ_TRUE;
 
@@ -319,5 +319,5 @@
 
 static void ice_on_rx_data(pj_ice_strans *ice_st,
-			   unsigned comp_id, 
+			   unsigned comp_id,
 			   void *pkt, pj_size_t size,
 			   const pj_sockaddr_t *src_addr,
@@ -336,5 +336,5 @@
 
 
-static void ice_on_ice_complete(pj_ice_strans *ice_st, 
+static void ice_on_ice_complete(pj_ice_strans *ice_st,
 			        pj_ice_strans_op op,
 			        pj_status_t status)
@@ -437,5 +437,5 @@
     for (; i<max_cnt; ++i) {
 	if (ept1->cfg.comp_cnt>i &&
-	    pj_ice_strans_get_valid_pair(ept1->ice, i+1) != NULL) 
+	    pj_ice_strans_get_valid_pair(ept1->ice, i+1) != NULL)
 	{
 	    PJ_LOG(3,(THIS_FILE, INDENT "err: ice1 shouldn't have valid pair "
@@ -444,5 +444,5 @@
 	}
 	if (ept2->cfg.comp_cnt>i &&
-	    pj_ice_strans_get_valid_pair(ept2->ice, i+1) != NULL) 
+	    pj_ice_strans_get_valid_pair(ept2->ice, i+1) != NULL)
 	{
 	    PJ_LOG(3,(THIS_FILE, INDENT "err: ice2 shouldn't have valid pair "
@@ -464,5 +464,5 @@
 				    pj_gettimeofday(&t); \
 				    if (expr) { \
-					rc = PJ_SUCCESS; \
+					RC = PJ_SUCCESS; \
 					break; \
 				    } \
@@ -478,5 +478,5 @@
     struct test_sess *sess = (struct test_sess *) data;
     pj_stun_config *stun_cfg = sess->stun_cfg;
-    
+
     /* Wait until negotiation is complete on both endpoints */
 #define ALL_DONE    (sess->param->worker_quit || \
@@ -484,5 +484,5 @@
 			 sess->callee.result.nego_status!=PJ_EPENDING))
     WAIT_UNTIL(sess->param->worker_timeout, ALL_DONE, rc);
-    
+    PJ_UNUSED_ARG(rc);
     return 0;
 }
@@ -539,5 +539,5 @@
     }
     /* Init ICE on caller */
-    rc = pj_ice_strans_init_ice(sess->caller.ice, sess->caller.cfg.role, 
+    rc = pj_ice_strans_init_ice(sess->caller.ice, sess->caller.cfg.role,
 				&sess->caller.ufrag, &sess->caller.pass);
     if (rc != PJ_SUCCESS) {
@@ -548,5 +548,5 @@
 
     /* Init ICE on callee */
-    rc = pj_ice_strans_init_ice(sess->callee.ice, sess->callee.cfg.role, 
+    rc = pj_ice_strans_init_ice(sess->callee.ice, sess->callee.cfg.role,
 				&sess->callee.ufrag, &sess->callee.pass);
     if (rc != PJ_SUCCESS) {
@@ -597,5 +597,5 @@
 	goto on_destroy;
     }
-    
+
     WAIT_UNTIL(30000, ALL_DONE, rc);
     if (!ALL_DONE) {
@@ -691,5 +691,5 @@
 	struct test_cfg	 ua1;
 	struct test_cfg	 ua2;
-    } sess_cfg[] = 
+    } sess_cfg[] =
     {
 	/*  Role    comp#   host?   stun?   turn?   flag?  ans_del snd_del des_del */
@@ -741,5 +741,5 @@
     /* Simple test first with host candidate */
     if (1) {
-	struct sess_cfg_t cfg = 
+	struct sess_cfg_t cfg =
 	{
 	    "Basic with host candidates",
@@ -750,5 +750,5 @@
 	};
 
-	rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 
+	rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag,
 			  &cfg.ua1, &cfg.ua2);
 	if (rc != 0)
@@ -757,14 +757,14 @@
 	cfg.ua1.comp_cnt = 2;
 	cfg.ua2.comp_cnt = 2;
-	rc = perform_test("Basic with host candidates, 2 components", 
-			  &stun_cfg, cfg.server_flag, 
-			  &cfg.ua1, &cfg.ua2);
-	if (rc != 0)
-	    goto on_return;
-    }
-    
+	rc = perform_test("Basic with host candidates, 2 components",
+			  &stun_cfg, cfg.server_flag,
+			  &cfg.ua1, &cfg.ua2);
+	if (rc != 0)
+	    goto on_return;
+    }
+
     /* Simple test first with srflx candidate */
     if (1) {
-	struct sess_cfg_t cfg = 
+	struct sess_cfg_t cfg =
 	{
 	    "Basic with srflx candidates",
@@ -775,5 +775,5 @@
 	};
 
-	rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 
+	rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag,
 			  &cfg.ua1, &cfg.ua2);
 	if (rc != 0)
@@ -783,6 +783,6 @@
 	cfg.ua2.comp_cnt = 2;
 
-	rc = perform_test("Basic with srflx candidates, 2 components", 
-			  &stun_cfg, cfg.server_flag, 
+	rc = perform_test("Basic with srflx candidates, 2 components",
+			  &stun_cfg, cfg.server_flag,
 			  &cfg.ua1, &cfg.ua2);
 	if (rc != 0)
@@ -792,5 +792,5 @@
     /* Simple test with relay candidate */
     if (1) {
-	struct sess_cfg_t cfg = 
+	struct sess_cfg_t cfg =
 	{
 	    "Basic with relay candidates",
@@ -801,5 +801,5 @@
 	};
 
-	rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 
+	rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag,
 			  &cfg.ua1, &cfg.ua2);
 	if (rc != 0)
@@ -809,6 +809,6 @@
 	cfg.ua2.comp_cnt = 2;
 
-	rc = perform_test("Basic with relay candidates, 2 components", 
-			  &stun_cfg, cfg.server_flag, 
+	rc = perform_test("Basic with relay candidates, 2 components",
+			  &stun_cfg, cfg.server_flag,
 			  &cfg.ua1, &cfg.ua2);
 	if (rc != 0)
@@ -818,5 +818,5 @@
     /* Failure test with STUN resolution */
     if (1) {
-	struct sess_cfg_t cfg = 
+	struct sess_cfg_t cfg =
 	{
 	    "STUN resolution failure",
@@ -835,6 +835,6 @@
 	cfg.ua2.client_flag |= DEL_ON_ERR;
 
-	rc = perform_test("STUN resolution failure with destroy on callback", 
-			  &stun_cfg, cfg.server_flag, 
+	rc = perform_test("STUN resolution failure with destroy on callback",
+			  &stun_cfg, cfg.server_flag,
 			  &cfg.ua1, &cfg.ua2);
 	if (rc != 0)
@@ -844,5 +844,5 @@
     /* Failure test with TURN resolution */
     if (1) {
-	struct sess_cfg_t cfg = 
+	struct sess_cfg_t cfg =
 	{
 	    "TURN allocation failure",
@@ -853,5 +853,5 @@
 	};
 
-	rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 
+	rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag,
 			  &cfg.ua1, &cfg.ua2);
 	if (rc != 0)
@@ -861,6 +861,6 @@
 	cfg.ua2.client_flag |= DEL_ON_ERR;
 
-	rc = perform_test("TURN allocation failure with destroy on callback", 
-			  &stun_cfg, cfg.server_flag, 
+	rc = perform_test("TURN allocation failure with destroy on callback",
+			  &stun_cfg, cfg.server_flag,
 			  &cfg.ua1, &cfg.ua2);
 	if (rc != 0)
@@ -871,5 +871,5 @@
     /* STUN failure, testing TURN deallocation */
     if (1) {
-	struct sess_cfg_t cfg = 
+	struct sess_cfg_t cfg =
 	{
 	    "STUN failure, testing TURN deallocation",
@@ -888,6 +888,6 @@
 	cfg.ua2.client_flag |= DEL_ON_ERR;
 
-	rc = perform_test("STUN failure, testing TURN deallocation (cb)", 
-			  &stun_cfg, cfg.server_flag, 
+	rc = perform_test("STUN failure, testing TURN deallocation (cb)",
+			  &stun_cfg, cfg.server_flag,
 			  &cfg.ua1, &cfg.ua2);
 	if (rc != 0)
@@ -909,5 +909,5 @@
 		pj_ice_sess_role	ua1;
 		pj_ice_sess_role	ua2;
-	    } role[] = 
+	    } role[] =
 	    {
 		{ ROLE1, ROLE2},
@@ -937,6 +937,6 @@
 			char title[120];
 
-			sprintf(title, 
-				"%s/%s, %dms answer delay, %d vs %d components", 
+			sprintf(title,
+				"%s/%s, %dms answer delay, %d vs %d components",
 				pj_ice_sess_role_name(role[j].ua1),
 				pj_ice_sess_role_name(role[j].ua2),
@@ -944,5 +944,5 @@
 
 			cfg->ua2.comp_cnt = k2;
-			rc = perform_test(title, &stun_cfg, cfg->server_flag, 
+			rc = perform_test(title, &stun_cfg, cfg->server_flag,
 					  &cfg->ua1, &cfg->ua2);
 			if (rc != 0)
@@ -1022,5 +1022,5 @@
     unsigned i;
     int rc;
-    
+
     pool = pj_pool_create(mem, NULL, 512, 512, NULL);
     rc = create_stun_config(pool, &stun_cfg);
@@ -1029,5 +1029,5 @@
 	return -7;
     }
-    
+
     for (i = 0; i < LOOP; i++) {
 	PJ_LOG(3,(THIS_FILE, INDENT "Test %d of %d", i+1, LOOP));
@@ -1039,5 +1039,5 @@
     /* Avoid compiler warning */
     goto on_return;
-    
+
 on_return:
     destroy_stun_config(&stun_cfg);
Index: pjproject/trunk/pjnath/src/pjnath-test/test.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath-test/test.c	(revision 4727)
+++ pjproject/trunk/pjnath/src/pjnath-test/test.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "test.h"
@@ -109,10 +109,10 @@
 
     st->timer_cnt = (unsigned)pj_timer_heap_count(cfg->timer_heap);
-    
+
     cp = (pj_caching_pool*)cfg->pf;
     st->pool_used_cnt = (unsigned)cp->used_count;
 }
 
-int check_pjlib_state(pj_stun_config *cfg, 
+int check_pjlib_state(pj_stun_config *cfg,
 		      const struct pjlib_state *initial_st)
 {
@@ -154,5 +154,5 @@
 pj_pool_factory *mem;
 
-int param_log_decor = PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME | 
+int param_log_decor = PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME |
 		      PJ_LOG_HAS_MICRO_SEC;
 
@@ -179,4 +179,5 @@
     pj_log_set_level(3);
     pj_log_set_decor(param_log_decor);
+    PJ_UNUSED_ARG(test_log_func);
 #elif 1
     log_file = fopen("pjnath-test.log", "wt");
@@ -191,5 +192,5 @@
 	return rc;
     }
-    
+
     pj_dump_config();
     pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, 0 );
@@ -234,5 +235,5 @@
     PJ_CATCH_ANY {
         int id = PJ_GET_EXCEPTION();
-        PJ_LOG(3,("test", "FATAL: unhandled exception id %d (%s)", 
+        PJ_LOG(3,("test", "FATAL: unhandled exception id %d (%s)",
                   id, pj_exception_id_name(id)));
     }
Index: pjproject/trunk/pjnath/src/pjnath/ice_strans.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/ice_strans.c	(revision 4727)
+++ pjproject/trunk/pjnath/src/pjnath/ice_strans.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <pjnath/ice_strans.h>
@@ -66,5 +66,5 @@
 
 /* The candidate type preference when STUN candidate is used */
-static pj_uint8_t srflx_pref_table[PJ_ICE_CAND_TYPE_MAX] = 
+static pj_uint8_t srflx_pref_table[PJ_ICE_CAND_TYPE_MAX] =
 {
 #if PJNATH_ICE_PRIO_STD
@@ -85,5 +85,5 @@
 /* ICE callbacks */
 static void	   on_ice_complete(pj_ice_sess *ice, pj_status_t status);
-static pj_status_t ice_tx_pkt(pj_ice_sess *ice, 
+static pj_status_t ice_tx_pkt(pj_ice_sess *ice,
 			      unsigned comp_id,
 			      unsigned transport_id,
@@ -91,6 +91,6 @@
 			      const pj_sockaddr_t *dst_addr,
 			      unsigned dst_addr_len);
-static void	   ice_rx_data(pj_ice_sess *ice, 
-			       unsigned comp_id, 
+static void	   ice_rx_data(pj_ice_sess *ice,
+			       unsigned comp_id,
 			       unsigned transport_id,
 			       void *pkt, pj_size_t size,
@@ -111,5 +111,5 @@
 				   pj_ssize_t sent);
 /* Notification when the status of the STUN transport has changed. */
-static pj_bool_t stun_on_status(pj_stun_sock *stun_sock, 
+static pj_bool_t stun_on_status(pj_stun_sock *stun_sock,
 				pj_stun_sock_op op,
 				pj_status_t status);
@@ -137,5 +137,5 @@
  * in ICE stream transport typically corresponds to a single socket created
  * for this component, and bound to a specific transport address. This
- * component may have multiple alias addresses, for example one alias 
+ * component may have multiple alias addresses, for example one alias
  * address for each interfaces in multi-homed host, another for server
  * reflexive alias, and another for relayed alias. For each transport
@@ -299,9 +299,9 @@
     /* Override with component specific socket buffer size settings, if any */
     if (ice_st->cfg.comp[comp->comp_id-1].so_rcvbuf_size > 0) {
-	ice_st->cfg.turn.cfg.so_rcvbuf_size = 
+	ice_st->cfg.turn.cfg.so_rcvbuf_size =
 	    ice_st->cfg.comp[comp->comp_id-1].so_rcvbuf_size;
     }
     if (ice_st->cfg.comp[comp->comp_id-1].so_sndbuf_size > 0) {
-	ice_st->cfg.turn.cfg.so_sndbuf_size = 
+	ice_st->cfg.turn.cfg.so_sndbuf_size =
 	    ice_st->cfg.comp[comp->comp_id-1].so_sndbuf_size;
     }
@@ -382,8 +382,8 @@
 	stun_sock_cb.on_status = &stun_on_status;
 	stun_sock_cb.on_data_sent = &stun_on_data_sent;
-	
+
 	/* Override component specific QoS settings, if any */
 	if (ice_st->cfg.comp[comp_id-1].qos_type) {
-	    ice_st->cfg.stun.cfg.qos_type = 
+	    ice_st->cfg.stun.cfg.qos_type =
 		ice_st->cfg.comp[comp_id-1].qos_type;
 	}
@@ -396,9 +396,9 @@
 	/* Override component specific socket buffer size settings, if any */
 	if (ice_st->cfg.comp[comp_id-1].so_rcvbuf_size > 0) {
-	    ice_st->cfg.stun.cfg.so_rcvbuf_size = 
+	    ice_st->cfg.stun.cfg.so_rcvbuf_size =
 		ice_st->cfg.comp[comp_id-1].so_rcvbuf_size;
 	}
 	if (ice_st->cfg.comp[comp_id-1].so_sndbuf_size > 0) {
-	    ice_st->cfg.stun.cfg.so_sndbuf_size = 
+	    ice_st->cfg.stun.cfg.so_sndbuf_size =
 		ice_st->cfg.comp[comp_id-1].so_sndbuf_size;
 	}
@@ -412,6 +412,6 @@
 	    return status;
 
-	/* Start STUN Binding resolution and add srflx candidate 
-	 * only if server is set 
+	/* Start STUN Binding resolution and add srflx candidate
+	 * only if server is set
 	 */
 	if (ice_st->cfg.stun.server.slen) {
@@ -421,5 +421,5 @@
 	    ///sess_add_ref(ice_st);
 
-	    PJ_LOG(4,(ice_st->obj_name, 
+	    PJ_LOG(4,(ice_st->obj_name,
 		      "Comp %d: srflx candidate starts Binding discovery",
 		      comp_id));
@@ -428,7 +428,7 @@
 
 	    /* Start Binding resolution */
-	    status = pj_stun_sock_start(comp->stun_sock, 
+	    status = pj_stun_sock_start(comp->stun_sock,
 					&ice_st->cfg.stun.server,
-					ice_st->cfg.stun.port, 
+					ice_st->cfg.stun.port,
 					ice_st->cfg.resolver);
 	    if (status != PJ_SUCCESS) {
@@ -476,6 +476,6 @@
 		return status;
 
-	    for (i=0; i<stun_sock_info.alias_cnt && 
-		      i<ice_st->cfg.stun.max_host_cands; ++i) 
+	    for (i=0; i<stun_sock_info.alias_cnt &&
+		      i<ice_st->cfg.stun.max_host_cands; ++i)
 	    {
 		char addrinfo[PJ_INET6_ADDRSTRLEN+10];
@@ -488,6 +488,6 @@
 		}
 
-		/* Ignore loopback addresses unless cfg->stun.loop_addr 
-		 * is set 
+		/* Ignore loopback addresses unless cfg->stun.loop_addr
+		 * is set
 		 */
 		if ((pj_ntohl(addr->ipv4.sin_addr.s_addr)>>24)==127) {
@@ -509,5 +509,5 @@
 				       cand->type, &cand->base_addr);
 
-		PJ_LOG(4,(ice_st->obj_name, 
+		PJ_LOG(4,(ice_st->obj_name,
 			  "Comp %d: host candidate %s added",
 			  comp_id, pj_sockaddr_print(&cand->addr, addrinfo,
@@ -533,6 +533,6 @@
 
 
-/* 
- * Create ICE stream transport 
+/*
+ * Create ICE stream transport
  */
 PJ_DEF(pj_status_t) pj_ice_strans_create( const char *name,
@@ -565,5 +565,5 @@
     ice_st->user_data = user_data;
 
-    PJ_LOG(4,(ice_st->obj_name, 
+    PJ_LOG(4,(ice_st->obj_name,
 	      "Creating ICE stream transport with %d component(s)",
 	      comp_cnt));
@@ -587,5 +587,5 @@
 
     ice_st->comp_cnt = comp_cnt;
-    ice_st->comp = (pj_ice_strans_comp**) 
+    ice_st->comp = (pj_ice_strans_comp**)
 		   pj_pool_calloc(pool, comp_cnt, sizeof(pj_ice_strans_comp*));
 
@@ -593,5 +593,5 @@
     ice_st->state = PJ_ICE_STRANS_STATE_INIT;
 
-    /* Acquire initialization mutex to prevent callback to be 
+    /* Acquire initialization mutex to prevent callback to be
      * called before we finish initialization.
      */
@@ -750,5 +750,5 @@
     ice_st->state = PJ_ICE_STRANS_STATE_READY;
     if (ice_st->cb.on_ice_complete)
-	(*ice_st->cb.on_ice_complete)(ice_st, PJ_ICE_STRANS_OP_INIT, 
+	(*ice_st->cb.on_ice_complete)(ice_st, PJ_ICE_STRANS_OP_INIT,
 				      PJ_SUCCESS);
 }
@@ -786,5 +786,5 @@
 
 /*
- * Specify various options for this ICE stream transport. 
+ * Specify various options for this ICE stream transport.
  */
 PJ_DEF(pj_status_t) pj_ice_strans_set_options(pj_ice_strans *ice_st,
@@ -835,5 +835,5 @@
     /* Create! */
     status = pj_ice_sess_create(&ice_st->cfg.stun_cfg, ice_st->obj_name, role,
-			        ice_st->comp_cnt, &ice_cb, 
+			        ice_st->comp_cnt, &ice_cb,
 			        local_ufrag, local_passwd,
 			        ice_st->grp_lock,
@@ -853,5 +853,5 @@
      */
     if (ice_st->comp[0]->default_cand >= 0 &&
-	ice_st->comp[0]->cand_list[ice_st->comp[0]->default_cand].type 
+	ice_st->comp[0]->cand_list[ice_st->comp[0]->default_cand].type
 	    == PJ_ICE_CAND_TYPE_SRFLX)
     {
@@ -866,5 +866,5 @@
 	/* Re-enable logging for Send/Data indications */
 	if (comp->turn_sock) {
-	    PJ_LOG(5,(ice_st->obj_name, 
+	    PJ_LOG(5,(ice_st->obj_name,
 		      "Disabling STUN Indication logging for "
 		      "component %d", i+1));
@@ -879,5 +879,5 @@
 	    /* Skip if candidate is not ready */
 	    if (cand->status != PJ_SUCCESS) {
-		PJ_LOG(5,(ice_st->obj_name, 
+		PJ_LOG(5,(ice_st->obj_name,
 			  "Candidate %d of comp %d is not added (pending)",
 			  j, i));
@@ -889,8 +889,8 @@
 
 	    /* Add the candidate */
-	    status = pj_ice_sess_add_cand(ice_st->ice, comp->comp_id, 
-					  cand->transport_id, cand->type, 
-					  cand->local_pref, 
-					  &cand->foundation, &cand->addr, 
+	    status = pj_ice_sess_add_cand(ice_st->ice, comp->comp_id,
+					  cand->transport_id, cand->type,
+					  cand->local_pref,
+					  &cand->foundation, &cand->addr,
 					  &cand->base_addr,  &cand->rel_addr,
 					  pj_sockaddr_get_len(&cand->addr),
@@ -912,5 +912,5 @@
 
 /*
- * Check if the ICE stream transport has the ICE session created. 
+ * Check if the ICE stream transport has the ICE session created.
  */
 PJ_DEF(pj_bool_t) pj_ice_strans_has_sess(pj_ice_strans *ice_st)
@@ -985,5 +985,5 @@
     unsigned i, cnt;
 
-    PJ_ASSERT_RETURN(ice_st && ice_st->ice && comp_id && 
+    PJ_ASSERT_RETURN(ice_st && ice_st->ice && comp_id &&
 		     comp_id <= ice_st->comp_cnt, 0);
 
@@ -1008,5 +1008,5 @@
     unsigned i, cnt;
 
-    PJ_ASSERT_RETURN(ice_st && ice_st->ice && comp_id && 
+    PJ_ASSERT_RETURN(ice_st && ice_st->ice && comp_id &&
 		     comp_id <= ice_st->comp_cnt && count && cand, PJ_EINVAL);
 
@@ -1042,5 +1042,5 @@
 	pj_ice_strans_comp *comp = ice_st->comp[comp_id - 1];
 	pj_assert(comp->default_cand>=0 && comp->default_cand<comp->cand_cnt);
-	pj_memcpy(cand, &comp->cand_list[comp->default_cand], 
+	pj_memcpy(cand, &comp->cand_list[comp->default_cand],
 		  sizeof(pj_ice_sess_cand));
     }
@@ -1108,5 +1108,5 @@
 
 	    if (count) {
-		status = pj_turn_sock_set_perm(comp->turn_sock, count, 
+		status = pj_turn_sock_set_perm(comp->turn_sock, count,
 					       addrs, 0);
 		if (status != PJ_SUCCESS) {
@@ -1132,5 +1132,5 @@
  * Get valid pair.
  */
-PJ_DEF(const pj_ice_sess_check*) 
+PJ_DEF(const pj_ice_sess_check*)
 pj_ice_strans_get_valid_pair(const pj_ice_strans *ice_st,
 			     unsigned comp_id)
@@ -1138,8 +1138,8 @@
     PJ_ASSERT_RETURN(ice_st && comp_id && comp_id <= ice_st->comp_cnt,
 		     NULL);
-    
+
     if (ice_st->ice == NULL)
 	return NULL;
-    
+
     return ice_st->ice->comp[comp_id-1].valid_check;
 }
@@ -1171,5 +1171,4 @@
 					  int dst_addr_len)
 {
-    pj_ssize_t pkt_size;
     pj_ice_strans_comp *comp;
     unsigned def_cand;
@@ -1220,5 +1219,5 @@
 	    if (!comp->turn_log_off) {
 		/* Disable logging for Send/Data indications */
-		PJ_LOG(5,(ice_st->obj_name, 
+		PJ_LOG(5,(ice_st->obj_name,
 			  "Disabling STUN Indication logging for "
 			  "component %d", comp->comp_id));
@@ -1227,16 +1226,15 @@
 	    }
 
-	    status = pj_turn_sock_sendto(comp->turn_sock, 
-					 (const pj_uint8_t*)data, 
+	    status = pj_turn_sock_sendto(comp->turn_sock,
+					 (const pj_uint8_t*)data,
 					 (unsigned)data_len,
 					 dst_addr, dst_addr_len);
-	    return (status==PJ_SUCCESS||status==PJ_EPENDING) ? 
+	    return (status==PJ_SUCCESS||status==PJ_EPENDING) ?
 		    PJ_SUCCESS : status;
 	} else {
-	    pkt_size = data_len;
-	    status = pj_stun_sock_sendto(comp->stun_sock, NULL, data, 
-					 (unsigned)data_len, 0, dst_addr, 
+	    status = pj_stun_sock_sendto(comp->stun_sock, NULL, data,
+					 (unsigned)data_len, 0, dst_addr,
 					 dst_addr_len);
-	    return (status==PJ_SUCCESS||status==PJ_EPENDING) ? 
+	    return (status==PJ_SUCCESS||status==PJ_EPENDING) ?
 		    PJ_SUCCESS : status;
 	}
@@ -1266,6 +1264,6 @@
 	    char errmsg[PJ_ERR_MSG_SIZE];
 	    pj_strerror(status, errmsg, sizeof(errmsg));
-	    PJ_LOG(4,(ice_st->obj_name, 
-		      "ICE negotiation failed after %ds:%03d: %s", 
+	    PJ_LOG(4,(ice_st->obj_name,
+		      "ICE negotiation failed after %ds:%03d: %s",
 		      msec/1000, msec%1000, errmsg));
 	} else {
@@ -1277,5 +1275,5 @@
 	    };
 
-	    PJ_LOG(4,(ice_st->obj_name, 
+	    PJ_LOG(4,(ice_st->obj_name,
 		      "ICE negotiation success after %ds:%03d",
 		      msec/1000, msec%1000));
@@ -1289,7 +1287,7 @@
 		    char rip[PJ_INET6_ADDRSTRLEN+10];
 
-		    pj_sockaddr_print(&check->lcand->addr, lip, 
+		    pj_sockaddr_print(&check->lcand->addr, lip,
 				      sizeof(lip), 3);
-		    pj_sockaddr_print(&check->rcand->addr, rip, 
+		    pj_sockaddr_print(&check->rcand->addr, rip,
 				      sizeof(rip), 3);
 
@@ -1304,5 +1302,5 @@
 
 			/* Disable logging for Send/Data indications */
-			PJ_LOG(5,(ice_st->obj_name, 
+			PJ_LOG(5,(ice_st->obj_name,
 				  "Disabling STUN Indication logging for "
 				  "component %d", i+1));
@@ -1315,12 +1313,12 @@
 			      "sending from %s candidate %s to "
 			      "%s candidate %s",
-			      i+1, 
+			      i+1,
 			      pj_ice_get_cand_type_name(check->lcand->type),
 			      lip,
 			      pj_ice_get_cand_type_name(check->rcand->type),
 			      rip));
-			      
+
 		} else {
-		    PJ_LOG(4,(ice_st->obj_name, 
+		    PJ_LOG(4,(ice_st->obj_name,
 			      "Comp %d: disabled", i+1));
 		}
@@ -1332,8 +1330,8 @@
 
 	pj_log_push_indent();
-	(*ice_st->cb.on_ice_complete)(ice_st, PJ_ICE_STRANS_OP_NEGOTIATION, 
+	(*ice_st->cb.on_ice_complete)(ice_st, PJ_ICE_STRANS_OP_NEGOTIATION,
 				      status);
 	pj_log_pop_indent();
-	
+
     }
 
@@ -1344,6 +1342,6 @@
  * Callback called by ICE session when it wants to send outgoing packet.
  */
-static pj_status_t ice_tx_pkt(pj_ice_sess *ice, 
-			      unsigned comp_id, 
+static pj_status_t ice_tx_pkt(pj_ice_sess *ice,
+			      unsigned comp_id,
 			      unsigned transport_id,
 			      const void *pkt, pj_size_t size,
@@ -1362,7 +1360,7 @@
     comp = ice_st->comp[comp_id-1];
 
-    TRACE_PKT((comp->ice_st->obj_name, 
+    TRACE_PKT((comp->ice_st->obj_name,
 	       "Component %d TX packet to %s:%d with transport %d",
-	       comp_id, 
+	       comp_id,
 	       pj_sockaddr_print(dst_addr, daddr, sizeof(addr), 0),
 	       pj_sockaddr_get_port(dst_addr),
@@ -1371,6 +1369,6 @@
     if (transport_id == TP_TURN) {
 	if (comp->turn_sock) {
-	    status = pj_turn_sock_sendto(comp->turn_sock, 
-					 (const pj_uint8_t*)pkt, 
+	    status = pj_turn_sock_sendto(comp->turn_sock,
+					 (const pj_uint8_t*)pkt,
 					 (unsigned)size,
 					 dst_addr, dst_addr_len);
@@ -1379,5 +1377,5 @@
 	}
     } else if (transport_id == TP_STUN) {
-	status = pj_stun_sock_sendto(comp->stun_sock, NULL, 
+	status = pj_stun_sock_sendto(comp->stun_sock, NULL,
 				     pkt, (unsigned)size, 0,
 				     dst_addr, dst_addr_len);
@@ -1386,5 +1384,5 @@
 	status = PJ_EINVALIDOP;
     }
-    
+
     return (status==PJ_SUCCESS||status==PJ_EPENDING) ? PJ_SUCCESS : status;
 }
@@ -1393,6 +1391,6 @@
  * Callback called by ICE session when it receives application data.
  */
-static void ice_rx_data(pj_ice_sess *ice, 
-		        unsigned comp_id, 
+static void ice_rx_data(pj_ice_sess *ice,
+		        unsigned comp_id,
 			unsigned transport_id,
 		        void *pkt, pj_size_t size,
@@ -1405,5 +1403,5 @@
 
     if (ice_st->cb.on_rx_data) {
-	(*ice_st->cb.on_rx_data)(ice_st, comp_id, pkt, size, 
+	(*ice_st->cb.on_rx_data)(ice_st, comp_id, pkt, size,
 				 src_addr, src_addr_len);
     }
@@ -1411,5 +1409,5 @@
 
 /* Notification when incoming packet has been received from
- * the STUN socket. 
+ * the STUN socket.
  */
 static pj_bool_t stun_on_rx_data(pj_stun_sock *stun_sock,
@@ -1439,5 +1437,5 @@
 	 */
 	if (ice_st->cb.on_rx_data) {
-	    (*ice_st->cb.on_rx_data)(ice_st, comp->comp_id, pkt, pkt_len, 
+	    (*ice_st->cb.on_rx_data)(ice_st, comp->comp_id, pkt, pkt_len,
 				     src_addr, addr_len);
 	}
@@ -1446,10 +1444,10 @@
 
 	/* Hand over the packet to ICE session */
-	status = pj_ice_sess_on_rx_pkt(comp->ice_st->ice, comp->comp_id, 
+	status = pj_ice_sess_on_rx_pkt(comp->ice_st->ice, comp->comp_id,
 				       TP_STUN, pkt, pkt_len,
 				       src_addr, addr_len);
 
 	if (status != PJ_SUCCESS) {
-	    ice_st_perror(comp->ice_st, "Error processing packet", 
+	    ice_st_perror(comp->ice_st, "Error processing packet",
 			  status);
 	}
@@ -1460,5 +1458,5 @@
 
 /* Notifification when asynchronous send operation to the STUN socket
- * has completed. 
+ * has completed.
  */
 static pj_bool_t stun_on_data_sent(pj_stun_sock *stun_sock,
@@ -1473,5 +1471,5 @@
 
 /* Notification when the status of the STUN transport has changed. */
-static pj_bool_t stun_on_status(pj_stun_sock *stun_sock, 
+static pj_bool_t stun_on_status(pj_stun_sock *stun_sock,
 				pj_stun_sock_op op,
 				pj_status_t status)
@@ -1573,9 +1571,9 @@
 		}
 
-		PJ_LOG(4,(comp->ice_st->obj_name, 
+		PJ_LOG(4,(comp->ice_st->obj_name,
 			  "Comp %d: %s, "
 			  "srflx address is %s",
-			  comp->comp_id, op_name, 
-			  pj_sockaddr_print(&info.mapped_addr, ipaddr, 
+			  comp->comp_id, op_name,
+			  pj_sockaddr_print(&info.mapped_addr, ipaddr,
 					     sizeof(ipaddr), 3)));
 
@@ -1663,6 +1661,6 @@
 
 	if (status != PJ_SUCCESS) {
-	    ice_st_perror(comp->ice_st, 
-			  "Error processing packet from TURN relay", 
+	    ice_st_perror(comp->ice_st,
+			  "Error processing packet from TURN relay",
 			  status);
 	}
@@ -1722,6 +1720,6 @@
 	pj_sockaddr_cp(&cand->base_addr, &rel_info.relay_addr);
 	pj_sockaddr_cp(&cand->rel_addr, &rel_info.mapped_addr);
-	pj_ice_calc_foundation(comp->ice_st->pool, &cand->foundation, 
-			       PJ_ICE_CAND_TYPE_RELAYED, 
+	pj_ice_calc_foundation(comp->ice_st->pool, &cand->foundation,
+			       PJ_ICE_CAND_TYPE_RELAYED,
 			       &rel_info.relay_addr);
 	cand->status = PJ_SUCCESS;
@@ -1730,8 +1728,8 @@
 	comp->default_cand = (unsigned)(cand - comp->cand_list);
 
-	PJ_LOG(4,(comp->ice_st->obj_name, 
+	PJ_LOG(4,(comp->ice_st->obj_name,
 		  "Comp %d: TURN allocation complete, relay address is %s",
-		  comp->comp_id, 
-		  pj_sockaddr_print(&rel_info.relay_addr, ipaddr, 
+		  comp->comp_id,
+		  pj_sockaddr_print(&rel_info.relay_addr, ipaddr,
 				     sizeof(ipaddr), 3)));
 
Index: pjproject/trunk/pjnath/src/pjturn-srv/allocation.c
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-srv/allocation.c	(revision 4727)
+++ pjproject/trunk/pjnath/src/pjturn-srv/allocation.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "turn.h"
@@ -63,6 +63,6 @@
 				pj_turn_relay_res *relay);
 static void destroy_relay(pj_turn_relay_res *relay);
-static void on_rx_from_peer(pj_ioqueue_key_t *key, 
-                            pj_ioqueue_op_key_t *op_key, 
+static void on_rx_from_peer(pj_ioqueue_key_t *key,
+                            pj_ioqueue_op_key_t *op_key,
                             pj_ssize_t bytes_read);
 static pj_status_t stun_on_send_msg(pj_stun_session *sess,
@@ -125,5 +125,5 @@
     /* Check if we can satisfy the bandwidth */
     if (cfg->bandwidth > MAX_CLIENT_BANDWIDTH) {
-	pj_stun_session_respond(sess, rdata, 
+	pj_stun_session_respond(sess, rdata,
 				PJ_STUN_SC_ALLOCATION_QUOTA_REACHED,
 			        "Invalid bandwidth", NULL, PJ_TRUE,
@@ -137,5 +137,5 @@
     if (attr_req_tp == NULL) {
 	pj_stun_session_respond(sess, rdata, PJ_STUN_SC_BAD_REQUEST,
-			        "Missing REQUESTED-TRANSPORT attribute", 
+			        "Missing REQUESTED-TRANSPORT attribute",
 				NULL, PJ_TRUE, src_addr, src_addr_len);
 	return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_BAD_REQUEST);
@@ -157,7 +157,7 @@
     if (attr_res_token) {
 	/* We don't support RESERVATION-TOKEN for now */
-	pj_stun_session_respond(sess, rdata, 
+	pj_stun_session_respond(sess, rdata,
 				PJ_STUN_SC_BAD_REQUEST,
-				"RESERVATION-TOKEN is not supported", NULL, 
+				"RESERVATION-TOKEN is not supported", NULL,
 				PJ_TRUE, src_addr, src_addr_len);
 	return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_BAD_REQUEST);
@@ -171,5 +171,5 @@
 	if (cfg->lifetime < MIN_LIFETIME) {
 	    pj_stun_session_respond(sess, rdata, PJ_STUN_SC_BAD_REQUEST,
-				    "LIFETIME too short", NULL, 
+				    "LIFETIME too short", NULL,
 				    PJ_TRUE, src_addr, src_addr_len);
 	    return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_BAD_REQUEST);
@@ -207,5 +207,5 @@
     /* Add LIFETIME. */
     pj_stun_msg_add_uint_attr(tdata->pool, tdata->msg,
-			      PJ_STUN_ATTR_LIFETIME, 
+			      PJ_STUN_ATTR_LIFETIME,
 			      (unsigned)alloc->relay.lifetime);
 
@@ -223,8 +223,8 @@
 				  &alloc->hkey.clt_addr,
 				  pj_sockaddr_get_len(&alloc->hkey.clt_addr));
-    
+
     /* Send the response */
     return pj_stun_session_send_msg(srv_sess, transport, PJ_TRUE,
-				    PJ_FALSE, &alloc->hkey.clt_addr, 
+				    PJ_FALSE, &alloc->hkey.clt_addr,
 				    pj_sockaddr_get_len(&alloc->hkey.clt_addr),
 				    tdata);
@@ -256,7 +256,7 @@
 
     /* Lookup the password */
-    status = pj_turn_get_password(NULL, NULL, &realm->value, 
-				  &user->value, alloc->pool, 
-				  &alloc->cred.data.static_cred.data_type, 
+    status = pj_turn_get_password(NULL, NULL, &realm->value,
+				  &user->value, alloc->pool,
+				  &alloc->cred.data.static_cred.data_type,
 				  &alloc->cred.data.static_cred.data);
     if (status != PJ_SUCCESS)
@@ -315,5 +315,5 @@
     pj_memcpy(&alloc->hkey.clt_addr, src_addr, src_addr_len);
 
-    status = pj_lock_create_recursive_mutex(pool, alloc->obj_name, 
+    status = pj_lock_create_recursive_mutex(pool, alloc->obj_name,
 					    &alloc->lock);
     if (status != PJ_SUCCESS) {
@@ -328,5 +328,5 @@
 
     /* Print info */
-    pj_ansi_strcpy(alloc->info, 
+    pj_ansi_strcpy(alloc->info,
 		   pj_turn_tp_type_name(transport->listener->tp_type));
     alloc->info[3] = ':';
@@ -372,7 +372,7 @@
 
     /* Done */
-    pj_sockaddr_print(&alloc->relay.hkey.addr, str_tmp, 
+    pj_sockaddr_print(&alloc->relay.hkey.addr, str_tmp,
 		      sizeof(str_tmp), 3);
-    PJ_LOG(4,(alloc->obj_name, "Client %s created, relay addr=%s:%s", 
+    PJ_LOG(4,(alloc->obj_name, "Client %s created, relay addr=%s:%s",
 	      alloc->info, pj_turn_tp_type_name(req.tp_type), str_tmp));
 
@@ -384,5 +384,5 @@
     /* Send reply to the ALLOCATE request */
     pj_strerror(status, str_tmp, sizeof(str_tmp));
-    pj_stun_session_respond(srv_sess, rdata, PJ_STUN_SC_BAD_REQUEST, str_tmp, 
+    pj_stun_session_respond(srv_sess, rdata, PJ_STUN_SC_BAD_REQUEST, str_tmp,
 			    transport, PJ_TRUE, src_addr, src_addr_len);
 
@@ -397,5 +397,5 @@
 {
     if (relay->timer.id) {
-	pj_timer_heap_cancel(relay->allocation->server->core.timer_heap, 
+	pj_timer_heap_cancel(relay->allocation->server->core.timer_heap,
 			     &relay->timer);
 	relay->timer.id = PJ_FALSE;
@@ -483,6 +483,6 @@
 
 /* Initiate shutdown sequence for this allocation and start destroy timer.
- * Once allocation is marked as shutting down, any packets will be 
- * rejected/discarded 
+ * Once allocation is marked as shutting down, any packets will be
+ * rejected/discarded
  */
 static void alloc_shutdown(pj_turn_allocation *alloc)
@@ -502,5 +502,5 @@
 	 */
 	return;
-    } 
+    }
 
     pj_assert(alloc->relay.timer.id == TIMER_ID_NONE);
@@ -531,5 +531,5 @@
     pj_assert(alloc->relay.timer.id != TIMER_ID_DESTROY);
     if (alloc->relay.timer.id != 0) {
-	pj_timer_heap_cancel(alloc->server->core.timer_heap, 
+	pj_timer_heap_cancel(alloc->server->core.timer_heap,
 			     &alloc->relay.timer);
 	alloc->relay.timer.id = TIMER_ID_NONE;
@@ -540,5 +540,5 @@
 
     alloc->relay.timer.id = TIMER_ID_TIMEOUT;
-    status = pj_timer_heap_schedule(alloc->server->core.timer_heap, 
+    status = pj_timer_heap_schedule(alloc->server->core.timer_heap,
 				    &alloc->relay.timer, &delay);
     if (status != PJ_SUCCESS) {
@@ -566,6 +566,6 @@
 	e->id = TIMER_ID_NONE;
 
-	PJ_LOG(4,(alloc->obj_name, 
-		  "Client %s refresh timed-out, shutting down..", 
+	PJ_LOG(4,(alloc->obj_name,
+		  "Client %s refresh timed-out, shutting down..",
 		  alloc->info));
 
@@ -575,5 +575,5 @@
 	e->id = TIMER_ID_NONE;
 
-	PJ_LOG(4,(alloc->obj_name, "Client %s destroying..", 
+	PJ_LOG(4,(alloc->obj_name, "Client %s destroying..",
 		  alloc->info));
 
@@ -601,8 +601,8 @@
 
     pj_bzero(relay, sizeof(*relay));
-    
+
     relay->allocation = alloc;
     relay->tp.sock = PJ_INVALID_SOCKET;
-    
+
     /* TODO: get the requested address family from somewhere */
     af = alloc->transport->listener->addr.addr.sa_family;
@@ -622,8 +622,8 @@
     /* Lifetime and timeout */
     relay->lifetime = req->lifetime;
-    pj_timer_entry_init(&relay->timer, TIMER_ID_NONE, relay, 
+    pj_timer_entry_init(&relay->timer, TIMER_ID_NONE, relay,
 			&relay_timeout_cb);
     resched_timeout(alloc);
-    
+
     /* Transport type */
     relay->hkey.tp_type = req->tp_type;
@@ -677,5 +677,5 @@
 	pj_sockaddr_init(af, &bound_addr, NULL, port);
 
-	status = pj_sock_bind(relay->tp.sock, &bound_addr, 
+	status = pj_sock_bind(relay->tp.sock, &bound_addr,
 			      pj_sockaddr_get_len(&bound_addr));
 	if (status == PJ_SUCCESS)
@@ -685,5 +685,5 @@
     if (status != PJ_SUCCESS) {
 	/* Unable to allocate port */
-	PJ_LOG(4,(THIS_FILE, "Unable to allocate relay, giving up: err %d", 
+	PJ_LOG(4,(THIS_FILE, "Unable to allocate relay, giving up: err %d",
 		  status));
 	pj_sock_close(relay->tp.sock);
@@ -696,5 +696,5 @@
     status = pj_sock_getsockname(relay->tp.sock, &relay->hkey.addr, &namelen);
     if (status != PJ_SUCCESS) {
-	PJ_LOG(4,(THIS_FILE, "pj_sock_getsockname() failed: err %d", 
+	PJ_LOG(4,(THIS_FILE, "pj_sock_getsockname() failed: err %d",
 		  status));
 	pj_sock_close(relay->tp.sock);
@@ -703,5 +703,5 @@
     }
     if (!pj_sockaddr_has_addr(&relay->hkey.addr)) {
-	pj_sockaddr_copy_addr(&relay->hkey.addr, 
+	pj_sockaddr_copy_addr(&relay->hkey.addr,
 			      &alloc->transport->listener->addr);
     }
@@ -719,5 +719,5 @@
 				      relay, &icb, &relay->tp.key);
     if (status != PJ_SUCCESS) {
-	PJ_LOG(4,(THIS_FILE, "pj_ioqueue_register_sock() failed: err %d", 
+	PJ_LOG(4,(THIS_FILE, "pj_ioqueue_register_sock() failed: err %d",
 		  status));
 	pj_sock_close(relay->tp.sock);
@@ -737,10 +737,10 @@
 static void send_reply_err(pj_turn_allocation *alloc,
 			   const pj_stun_rx_data *rdata,
-			   pj_bool_t cache, 
+			   pj_bool_t cache,
 			   int code, const char *errmsg)
 {
     pj_status_t status;
 
-    status = pj_stun_session_respond(alloc->sess, rdata, code, errmsg, NULL, 
+    status = pj_stun_session_respond(alloc->sess, rdata, code, errmsg, NULL,
 				     cache, &alloc->hkey.clt_addr,
 				     pj_sockaddr_get_len(&alloc->hkey.clt_addr.addr));
@@ -787,7 +787,7 @@
     }
 
-    status = pj_stun_session_send_msg(alloc->sess, NULL, PJ_TRUE, 
-				      PJ_FALSE, &alloc->hkey.clt_addr,  
-				      pj_sockaddr_get_len(&alloc->hkey.clt_addr), 
+    status = pj_stun_session_send_msg(alloc->sess, NULL, PJ_TRUE,
+				      PJ_FALSE, &alloc->hkey.clt_addr,
+				      pj_sockaddr_get_len(&alloc->hkey.clt_addr),
 				      tdata);
     if (status != PJ_SUCCESS) {
@@ -807,5 +807,5 @@
     perm = PJ_POOL_ZALLOC_T(alloc->pool, pj_turn_permission);
     pj_memcpy(&perm->hkey.peer_addr, peer_addr, addr_len);
-    
+
     perm->allocation = alloc;
     perm->channel = PJ_TURN_INVALID_CHANNEL;
@@ -815,6 +815,6 @@
 
     /* Register to hash table (only the address part!) */
-    pj_hash_set(alloc->pool, alloc->peer_table, 
-		pj_sockaddr_get_addr(&perm->hkey.peer_addr), 
+    pj_hash_set(alloc->pool, alloc->peer_table,
+		pj_sockaddr_get_addr(&perm->hkey.peer_addr),
 	        pj_sockaddr_get_addr_len(&perm->hkey.peer_addr), 0, perm);
 
@@ -835,11 +835,11 @@
 
     /* Remove from permission hash table */
-    pj_hash_set(NULL, alloc->peer_table, 
-		pj_sockaddr_get_addr(&perm->hkey.peer_addr), 
+    pj_hash_set(NULL, alloc->peer_table,
+		pj_sockaddr_get_addr(&perm->hkey.peer_addr),
 	        pj_sockaddr_get_addr_len(&perm->hkey.peer_addr), 0, NULL);
 
     /* Remove from channel hash table, if assigned a channel number */
     if (perm->channel != PJ_TURN_INVALID_CHANNEL) {
-	pj_hash_set(NULL, alloc->ch_table, &perm->channel, 
+	pj_hash_set(NULL, alloc->ch_table, &perm->channel,
 		    sizeof(perm->channel), 0, NULL);
     }
@@ -859,8 +859,8 @@
 
     /* Lookup in peer hash table */
-    perm = (pj_turn_permission*) 
-	   pj_hash_get(alloc->peer_table, 
+    perm = (pj_turn_permission*)
+	   pj_hash_get(alloc->peer_table,
 		       pj_sockaddr_get_addr(peer_addr),
-		       pj_sockaddr_get_addr_len(peer_addr), 
+		       pj_sockaddr_get_addr_len(peer_addr),
 		       NULL);
     return perm ? check_permission_expiry(perm) : NULL;
@@ -881,5 +881,5 @@
 }
 
-/* Update permission because of data from client to peer. 
+/* Update permission because of data from client to peer.
  * Return PJ_TRUE is permission is found.
  */
@@ -917,5 +917,5 @@
 	 * callbacks.
 	 *
-	 * Note: currently it is necessary to specify the 
+	 * Note: currently it is necessary to specify the
 	 * PJ_STUN_NO_FINGERPRINT_CHECK otherwise the FINGERPRINT
 	 * attribute inside STUN Send Indication message will mess up
@@ -930,5 +930,5 @@
 	status = pj_stun_session_on_rx_pkt(alloc->sess, pkt->pkt, pkt->len,
 					   options, NULL, &parsed_len,
-					   &pkt->src.clt_addr, 
+					   &pkt->src.clt_addr,
 					   pkt->src_addr_len);
 
@@ -963,5 +963,5 @@
 	if (alloc->transport->listener->tp_type == PJ_TURN_TP_UDP) {
 	    if (pkt->len < pj_ntohs(cd->length)+sizeof(*cd)) {
-		PJ_LOG(4,(alloc->obj_name, 
+		PJ_LOG(4,(alloc->obj_name,
 			  "ChannelData from %s discarded: UDP size error",
 			  alloc->info));
@@ -976,5 +976,5 @@
 	if (!perm) {
 	    /* Discard */
-	    PJ_LOG(4,(alloc->obj_name, 
+	    PJ_LOG(4,(alloc->obj_name,
 		      "ChannelData from %s discarded: ch#0x%x not found",
 		      alloc->info, pj_ntohs(cd->ch_number)));
@@ -999,5 +999,5 @@
 
 /*
- * Handle incoming packet from peer. This function is called by 
+ * Handle incoming packet from peer. This function is called by
  * on_rx_from_peer().
  */
@@ -1010,5 +1010,5 @@
 
     /* Lookup permission */
-    perm = lookup_permission_by_addr(alloc, src_addr, 
+    perm = lookup_permission_by_addr(alloc, src_addr,
 				     pj_sockaddr_get_len(src_addr));
     if (perm == NULL) {
@@ -1050,5 +1050,5 @@
 	pj_status_t status;
 
-	status = pj_stun_session_create_ind(alloc->sess, 
+	status = pj_stun_session_create_ind(alloc->sess,
 					    PJ_STUN_DATA_INDICATION, &tdata);
 	if (status != PJ_SUCCESS) {
@@ -1057,14 +1057,14 @@
 	}
 
-	pj_stun_msg_add_sockaddr_attr(tdata->pool, tdata->msg, 
+	pj_stun_msg_add_sockaddr_attr(tdata->pool, tdata->msg,
 				      PJ_STUN_ATTR_XOR_PEER_ADDR, PJ_TRUE,
 				      src_addr, pj_sockaddr_get_len(src_addr));
 	pj_stun_msg_add_binary_attr(tdata->pool, tdata->msg,
-				    PJ_STUN_ATTR_DATA, 
+				    PJ_STUN_ATTR_DATA,
 				    (const pj_uint8_t*)pkt, len);
 
-	pj_stun_session_send_msg(alloc->sess, NULL, PJ_FALSE, 
-				 PJ_FALSE, &alloc->hkey.clt_addr, 
-				 pj_sockaddr_get_len(&alloc->hkey.clt_addr), 
+	pj_stun_session_send_msg(alloc->sess, NULL, PJ_FALSE,
+				 PJ_FALSE, &alloc->hkey.clt_addr,
+				 pj_sockaddr_get_len(&alloc->hkey.clt_addr),
 				 tdata);
     }
@@ -1074,6 +1074,6 @@
  * ioqueue notification on RX packets from the relay socket.
  */
-static void on_rx_from_peer(pj_ioqueue_key_t *key, 
-                            pj_ioqueue_op_key_t *op_key, 
+static void on_rx_from_peer(pj_ioqueue_key_t *key,
+                            pj_ioqueue_op_key_t *op_key,
                             pj_ssize_t bytes_read)
 {
@@ -1097,5 +1097,5 @@
 	status = pj_ioqueue_recvfrom(key, op_key,
 				     rel->tp.rx_pkt, &bytes_read, 0,
-				     &rel->tp.src_addr, 
+				     &rel->tp.src_addr,
 				     &rel->tp.src_addr_len);
 
@@ -1157,5 +1157,5 @@
     if (alloc->relay.lifetime == 0) {
 	/* Reject with 437 if we're shutting down */
-	send_reply_err(alloc, rdata, PJ_TRUE, 
+	send_reply_err(alloc, rdata, PJ_TRUE,
 		       PJ_STUN_SC_ALLOCATION_MISMATCH, NULL);
 	return PJ_SUCCESS;
@@ -1163,6 +1163,6 @@
 
     if (msg->hdr.type == PJ_STUN_REFRESH_REQUEST) {
-	/* 
-	 * Handle REFRESH request 
+	/*
+	 * Handle REFRESH request
 	 */
 	pj_stun_lifetime_attr *lifetime;
@@ -1176,4 +1176,7 @@
 	bandwidth = (pj_stun_bandwidth_attr*)
 	            pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_BANDWIDTH, 0);
+
+	/* TODO: process bandwidth */
+	PJ_UNUSED_ARG(bandwidth);
 
 	if (lifetime && lifetime->value==0) {
@@ -1187,5 +1190,5 @@
 
 	    /* Shutdown allocation */
-	    PJ_LOG(4,(alloc->obj_name, 
+	    PJ_LOG(4,(alloc->obj_name,
 		      "Client %s request to dealloc, shutting down",
 		      alloc->info));
@@ -1197,5 +1200,5 @@
 	     * This is a refresh request.
 	     */
-	    
+
 	    /* Update lifetime */
 	    if (lifetime) {
@@ -1227,5 +1230,5 @@
 
 	if (!ch_attr || !peer_attr) {
-	    send_reply_err(alloc, rdata, PJ_TRUE, 
+	    send_reply_err(alloc, rdata, PJ_TRUE,
 			   PJ_STUN_SC_BAD_REQUEST, NULL);
 	    return PJ_SUCCESS;
@@ -1235,5 +1238,5 @@
 	p1 = lookup_permission_by_chnum(alloc, PJ_STUN_GET_CH_NB(ch_attr->value));
 
-	/* If permission is found, this is supposed to be a channel bind 
+	/* If permission is found, this is supposed to be a channel bind
 	 * refresh. Make sure it's for the same peer.
 	 */
@@ -1241,6 +1244,6 @@
 	    if (pj_sockaddr_cmp(&p1->hkey.peer_addr, &peer_attr->sockaddr)) {
 		/* Address mismatch. Send 400 */
-		send_reply_err(alloc, rdata, PJ_TRUE, 
-			       PJ_STUN_SC_BAD_REQUEST, 
+		send_reply_err(alloc, rdata, PJ_TRUE,
+			       PJ_STUN_SC_BAD_REQUEST,
 			       "Peer address mismatch");
 		return PJ_SUCCESS;
@@ -1263,5 +1266,5 @@
 				       pj_sockaddr_get_len(&peer_attr->sockaddr));
 	if (p2 && p2->channel != PJ_TURN_INVALID_CHANNEL) {
-	    send_reply_err(alloc, rdata, PJ_TRUE, PJ_STUN_SC_BAD_REQUEST, 
+	    send_reply_err(alloc, rdata, PJ_TRUE, PJ_STUN_SC_BAD_REQUEST,
 			   "Peer address already assigned a channel number");
 	    return PJ_SUCCESS;
@@ -1281,5 +1284,5 @@
 	/* Register to hash table */
 	pj_assert(sizeof(p2->channel==2));
-	pj_hash_set(alloc->pool, alloc->ch_table, &p2->channel, 
+	pj_hash_set(alloc->pool, alloc->ch_table, &p2->channel,
 		    sizeof(p2->channel), 0, p2);
 
@@ -1368,5 +1371,5 @@
     /* Relay the data to peer */
     len = data_attr->length;
-    pj_sock_sendto(alloc->relay.tp.sock, data_attr->data, 
+    pj_sock_sendto(alloc->relay.tp.sock, data_attr->data,
 		   &len, 0, &peer_attr->sockaddr,
 		   pj_sockaddr_get_len(&peer_attr->sockaddr));
Index: pjproject/trunk/pjnath/src/pjturn-srv/server.c
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-srv/server.c	(revision 4727)
+++ pjproject/trunk/pjnath/src/pjturn-srv/server.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "turn.h"
@@ -77,5 +77,5 @@
  * Create server.
  */
-PJ_DEF(pj_status_t) pj_turn_srv_create(pj_pool_factory *pf, 
+PJ_DEF(pj_status_t) pj_turn_srv_create(pj_pool_factory *pf,
 				       pj_turn_srv **p_srv)
 {
@@ -95,5 +95,5 @@
     srv->core.pool = pool;
     srv->core.tls_key = srv->core.tls_data = -1;
-    
+
     /* Create ioqueue */
     status = pj_ioqueue_create(pool, MAX_HANDLES, &srv->core.ioqueue);
@@ -102,5 +102,5 @@
 
     /* Server mutex */
-    status = pj_lock_create_recursive_mutex(pool, srv->obj_name, 
+    status = pj_lock_create_recursive_mutex(pool, srv->obj_name,
 					    &srv->core.lock);
     if (status != PJ_SUCCESS)
@@ -115,5 +115,5 @@
     if (status != PJ_SUCCESS)
 	goto on_error;
-    
+
     /* Create timer heap */
     status = pj_timer_heap_create(pool, MAX_TIMER, &srv->core.timer_heap);
@@ -126,5 +126,5 @@
     /* Array of listeners */
     srv->core.listener = (pj_turn_listener**)
-			 pj_pool_calloc(pool, MAX_LISTENERS, 
+			 pj_pool_calloc(pool, MAX_LISTENERS,
 					sizeof(srv->core.listener[0]));
 
@@ -170,10 +170,10 @@
     srv->core.thread_cnt = MAX_THREADS;
     srv->core.thread = (pj_thread_t**)
-		       pj_pool_calloc(pool, srv->core.thread_cnt, 
+		       pj_pool_calloc(pool, srv->core.thread_cnt,
 				      sizeof(pj_thread_t*));
 
     /* Start the worker threads */
     for (i=0; i<srv->core.thread_cnt; ++i) {
-	status = pj_thread_create(pool, srv->obj_name, &server_thread_proc, 
+	status = pj_thread_create(pool, srv->obj_name, &server_thread_proc,
 				  srv, 0, 0, &srv->core.thread[i]);
 	if (status != PJ_SUCCESS)
@@ -182,5 +182,5 @@
 
     /* We're done. Application should add listeners now */
-    PJ_LOG(4,(srv->obj_name, "TURN server v%s is running", 
+    PJ_LOG(4,(srv->obj_name, "TURN server v%s is running",
 	      pj_get_version()));
 
@@ -194,6 +194,6 @@
 
 
-/* 
- * Handle timer and network events 
+/*
+ * Handle timer and network events
  */
 static void srv_handle_events(pj_turn_srv *srv, const pj_time_val *max_timeout)
@@ -204,6 +204,6 @@
     int c;
 
-    /* Poll the timer. The timer heap has its own mutex for better 
-     * granularity, so we don't need to lock the server. 
+    /* Poll the timer. The timer heap has its own mutex for better
+     * granularity, so we don't need to lock the server.
      */
     timeout.sec = timeout.msec = 0;
@@ -223,5 +223,5 @@
     }
 
-    /* Poll ioqueue. 
+    /* Poll ioqueue.
      * Repeat polling the ioqueue while we have immediate events, because
      * timer heap may process more than one events, so if we only process
@@ -293,5 +293,5 @@
 	}
     }
-    
+
     /* Destroy all listeners. */
     for (i=0; i<srv->core.lis_cnt; ++i) {
@@ -313,5 +313,5 @@
 	srv->tables.res = NULL;
     }
-    
+
     /* Destroy timer heap */
     if (srv->core.timer_heap) {
@@ -461,5 +461,5 @@
 
 
-/* Callback from our own STUN session whenever it needs to send 
+/* Callback from our own STUN session whenever it needs to send
  * outgoing STUN packet.
  */
@@ -472,10 +472,10 @@
 {
     pj_turn_transport *transport = (pj_turn_transport*) token;
-    
+
     PJ_ASSERT_RETURN(transport!=NULL, PJ_EINVALIDOP);
 
     PJ_UNUSED_ARG(sess);
 
-    return transport->sendto(transport, pdu, pdu_size, 0, 
+    return transport->sendto(transport, pdu, pdu_size, 0,
 			     dst_addr, addr_len);
 }
@@ -483,11 +483,11 @@
 
 /* Respond to STUN request */
-static pj_status_t stun_respond(pj_stun_session *sess, 
+static pj_status_t stun_respond(pj_stun_session *sess,
 				pj_turn_transport *transport,
 				const pj_stun_rx_data *rdata,
-				unsigned code, 
+				unsigned code,
 				const char *errmsg,
-				pj_bool_t cache, 
-				const pj_sockaddr_t *dst_addr, 
+				pj_bool_t cache,
+				const pj_sockaddr_t *dst_addr,
 				unsigned addr_len)
 {
@@ -497,5 +497,5 @@
 
     /* Create response */
-    status = pj_stun_session_create_res(sess, rdata, code, 
+    status = pj_stun_session_create_res(sess, rdata, code,
 					(errmsg?pj_cstr(&reason,errmsg):NULL),
 					&tdata);
@@ -504,5 +504,5 @@
 
     /* Send the response */
-    return pj_stun_session_send_msg(sess, transport, cache, PJ_FALSE, 
+    return pj_stun_session_send_msg(sess, transport, cache, PJ_FALSE,
 				    dst_addr,  addr_len, tdata);
 }
@@ -523,5 +523,4 @@
     pj_turn_transport *transport;
     const pj_stun_msg *msg = rdata->msg;
-    pj_turn_srv *srv;
     pj_turn_allocation *alloc;
     pj_status_t status;
@@ -531,5 +530,4 @@
 
     transport = (pj_turn_transport*) token;
-    srv = transport->listener->server;
 
     /* Respond any requests other than ALLOCATE with 437 response */
@@ -570,5 +568,5 @@
 
     /* Create response */
-    status = pj_stun_msg_create_response(pkt->pool, request, 0, NULL, 
+    status = pj_stun_msg_create_response(pkt->pool, request, 0, NULL,
 					 &response);
     if (status != PJ_SUCCESS)
@@ -576,5 +574,5 @@
 
     /* Add XOR-MAPPED-ADDRESS */
-    pj_stun_msg_add_sockaddr_attr(pkt->pool, response, 
+    pj_stun_msg_add_sockaddr_attr(pkt->pool, response,
 				  PJ_STUN_ATTR_XOR_MAPPED_ADDR,
 				  PJ_TRUE,
@@ -588,5 +586,5 @@
 
     /* Send response */
-    pkt->transport->sendto(pkt->transport, pdu, len, 0, 
+    pkt->transport->sendto(pkt->transport, pdu, len, 0,
 			   &pkt->src.clt_addr, pkt->src_addr_len);
 }
@@ -599,5 +597,5 @@
  * if an allocation is not found.
  */
-PJ_DEF(void) pj_turn_srv_on_rx_pkt(pj_turn_srv *srv, 
+PJ_DEF(void) pj_turn_srv_on_rx_pkt(pj_turn_srv *srv,
 				   pj_turn_pkt *pkt)
 {
@@ -639,5 +637,5 @@
 	    if ((*pkt->pkt != 0x00 && *pkt->pkt != 0x01) ||
 		pkt->len > 1600 ||
-		(options & PJ_STUN_IS_DATAGRAM)) 
+		(options & PJ_STUN_IS_DATAGRAM))
 	    {
 		char errmsg[PJ_ERR_MSG_SIZE];
@@ -647,5 +645,5 @@
 
 		pj_strerror(status, errmsg, sizeof(errmsg));
-		PJ_LOG(5,(srv->obj_name, 
+		PJ_LOG(5,(srv->obj_name,
 			  "Non-STUN packet from %s is dropped: %s",
 			  pj_sockaddr_print(&pkt->src.clt_addr, ip, sizeof(ip), 3),
@@ -655,5 +653,5 @@
 	}
 
-	/* Special handling for Binding Request. We won't give it to the 
+	/* Special handling for Binding Request. We won't give it to the
 	 * STUN session since this request is not authenticated.
 	 */
@@ -669,7 +667,7 @@
 	options &= ~PJ_STUN_CHECK_PACKET;
 	parsed_len = 0;
-	status = pj_stun_session_on_rx_pkt(srv->core.stun_sess, pkt->pkt, 
+	status = pj_stun_session_on_rx_pkt(srv->core.stun_sess, pkt->pkt,
 					   pkt->len, options, pkt->transport,
-					   &parsed_len, &pkt->src.clt_addr, 
+					   &parsed_len, &pkt->src.clt_addr,
 					   pkt->src_addr_len);
 	if (status != PJ_SUCCESS) {
@@ -678,5 +676,5 @@
 
 	    pj_strerror(status, errmsg, sizeof(errmsg));
-	    PJ_LOG(5,(srv->obj_name, 
+	    PJ_LOG(5,(srv->obj_name,
 		      "Error processing STUN packet from %s: %s",
 		      pj_sockaddr_print(&pkt->src.clt_addr, ip, sizeof(ip), 3),
Index: pjproject/trunk/pjsip-apps/src/pjsystest/systest.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsystest/systest.c	(revision 4727)
+++ pjproject/trunk/pjsip-apps/src/pjsystest/systest.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  *
@@ -15,5 +15,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "systest.h"
@@ -57,10 +57,10 @@
 static gui_menu menu_getsets = { "View Settings", &systest_display_settings };
 
-static gui_menu menu_tests = { 
-    "Tests", NULL, 
-    10, 
+static gui_menu menu_tests = {
+    "Tests", NULL,
+    10,
     {
 	&menu_wizard,
-	&menu_audtest, 
+	&menu_audtest,
 	&menu_playtn,
 	&menu_playwv1,
@@ -69,12 +69,12 @@
 	&menu_calclat,
 	&menu_sndaec,
-	NULL, 
+	NULL,
 	&menu_exit
     }
 };
 
-static gui_menu menu_options = { 
-    "Options", NULL, 
-    2, 
+static gui_menu menu_options = {
+    "Options", NULL,
+    2,
     {
 	&menu_listdev,
@@ -83,6 +83,6 @@
 };
 
-static gui_menu root_menu = { 
-    "Root", NULL, 2, {&menu_tests, &menu_options} 
+static gui_menu root_menu = {
+    "Root", NULL, 2, {&menu_tests, &menu_options}
 };
 
@@ -134,5 +134,5 @@
     else
 	errmsg[0] = '\0';
-    
+
     strcpy(themsg, title);
     strncat(themsg, errmsg, sizeof(themsg)-1);
@@ -159,5 +159,5 @@
 
 /*****************************************************************************
- * test: play simple ringback tone and hear it 
+ * test: play simple ringback tone and hear it
  */
 static void systest_play_tone(void)
@@ -202,5 +202,5 @@
 
     pool = pjsua_pool_create("ringback", 512, 512);
-    samples_per_frame = systest.media_cfg.audio_frame_ptime * 
+    samples_per_frame = systest.media_cfg.audio_frame_ptime *
 			systest.media_cfg.clock_rate *
 			systest.media_cfg.channel_count / 1000;
@@ -208,9 +208,9 @@
     /* Ringback tone (call is ringing) */
     name = pj_str("ringback");
-    status = pjmedia_tonegen_create2(pool, &name, 
+    status = pjmedia_tonegen_create2(pool, &name,
 				     systest.media_cfg.clock_rate,
-				     systest.media_cfg.channel_count, 
+				     systest.media_cfg.channel_count,
 				     samples_per_frame,
-				     16, PJMEDIA_TONEGEN_LOOP, 
+				     16, PJMEDIA_TONEGEN_LOOP,
 				     &ringback_port);
     if (status != PJ_SUCCESS)
@@ -270,5 +270,5 @@
  * the file.
  */
-static pj_status_t create_player(unsigned path_cnt, const char *paths[], 
+static pj_status_t create_player(unsigned path_cnt, const char *paths[],
 				 pjsua_player_id *p_id)
 {
@@ -365,5 +365,5 @@
 
 /*****************************************************************************
- * test: record audio 
+ * test: record audio
  */
 static void systest_rec_audio(void)
@@ -388,5 +388,5 @@
 		     "from the microphone, and playback the "
 		     "audio to the speaker. Press OK to start recording, "
-		     "CANCEL to skip.", 
+		     "CANCEL to skip.",
 		     WITH_OKCANCEL);
     if (key != KEY_OK) {
@@ -433,5 +433,5 @@
 		     "The recorded audio is being played now to "
 		     "the speaker device, in a loop. Listen for "
-		     "any audio impairments. Press OK to stop.", 
+		     "any audio impairments. Press OK to stop.",
 		     WITH_OK);
 
@@ -526,9 +526,9 @@
     param.clock_rate = systest.media_cfg.snd_clock_rate;
     param.channel_count = systest.media_cfg.channel_count;
-    param.samples_per_frame = param.clock_rate * param.channel_count * 
+    param.samples_per_frame = param.clock_rate * param.channel_count *
 			      systest.media_cfg.audio_frame_ptime / 1000;
 
     /* Latency settings */
-    param.flags |= (PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY | 
+    param.flags |= (PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY |
 		    PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY);
     param.input_latency_ms = systest.media_cfg.snd_rec_latency;
@@ -554,9 +554,9 @@
 
     if (result.rec.frame_cnt==0) {
-	problems[problem_count++] = 
+	problems[problem_count++] =
 	    "No audio frames were captured from the microphone. "
 	    "This means the audio device is not working properly.";
     } else {
-	pj_ansi_snprintf(textbuf+textbufpos, 
+	pj_ansi_snprintf(textbuf+textbufpos,
 			 sizeof(textbuf)-textbufpos,
 			 "Rec : interval (min/max/avg/dev)=\r\n"
@@ -571,5 +571,5 @@
 
 	if (result.rec.max_burst > GOOD_MAX_INTERVAL) {
-	    problems[problem_count++] = 
+	    problems[problem_count++] =
 		"Recording max burst is quite high";
 	}
@@ -577,9 +577,9 @@
 
     if (result.play.frame_cnt==0) {
-	problems[problem_count++] = 
+	problems[problem_count++] =
 	    "No audio frames were played to the speaker. "
 	    "This means the audio device is not working properly.";
     } else {
-	pj_ansi_snprintf(textbuf+textbufpos, 
+	pj_ansi_snprintf(textbuf+textbufpos,
 			 sizeof(textbuf)-textbufpos,
 			 "Play: interval (min/max/avg/dev)=\r\n"
@@ -594,5 +594,5 @@
 
 	if (result.play.max_burst > GOOD_MAX_INTERVAL) {
-	    problems[problem_count++] = 
+	    problems[problem_count++] =
 		"Playback max burst is quite high";
 	}
@@ -601,5 +601,5 @@
     if (result.rec_drift_per_sec) {
 	const char *which = result.rec_drift_per_sec>=0 ? "faster" : "slower";
-	unsigned drift = result.rec_drift_per_sec>=0 ? 
+	unsigned drift = result.rec_drift_per_sec>=0 ?
 			    result.rec_drift_per_sec :
 			    -result.rec_drift_per_sec;
@@ -614,5 +614,5 @@
 
     if (problem_count == 0) {
-	pj_ansi_snprintf(textbuf+textbufpos, 
+	pj_ansi_snprintf(textbuf+textbufpos,
 			 sizeof(textbuf)-textbufpos,
 			 "\r\nThe sound device seems to be okay!");
@@ -624,5 +624,5 @@
 
 	pj_ansi_snprintf(textbuf+textbufpos,
-			 sizeof(textbuf)-textbufpos, 
+			 sizeof(textbuf)-textbufpos,
 			 "There could be %d problem(s) with the "
 			 "sound device:\r\n",
@@ -632,5 +632,5 @@
 	for (i=0; i<problem_count; ++i) {
 	    pj_ansi_snprintf(textbuf+textbufpos,
-			     sizeof(textbuf)-textbufpos, 
+			     sizeof(textbuf)-textbufpos,
 			     " %d: %s\r\n", i+1, problems[i]);
 	    textbufpos = strlen(textbuf);
@@ -650,5 +650,5 @@
  */
 static int calculate_latency(pj_pool_t *pool, pjmedia_port *wav,
-			     unsigned *lat_sum, unsigned *lat_cnt, 
+			     unsigned *lat_sum, unsigned *lat_cnt,
 			     unsigned *lat_min, unsigned *lat_max)
 {
@@ -689,5 +689,5 @@
     }
 
-    /* Zero the first 500ms to remove loud click noises 
+    /* Zero the first 500ms to remove loud click noises
      * (keypad press, etc.)
      */
@@ -784,5 +784,5 @@
 	return;
     }
-    key = gui_msgbox(title, 
+    key = gui_msgbox(title,
 		     "For this test to work, we must be able to capture "
 		     "the audio played in the speaker (the echo), and only"
@@ -798,5 +798,5 @@
     PJ_LOG(3,(THIS_FILE, "Running %s", title));
 
-    status = create_player(PJ_ARRAY_SIZE(ref_wav_paths), ref_wav_paths, 
+    status = create_player(PJ_ARRAY_SIZE(ref_wav_paths), ref_wav_paths,
 			   &play_id);
     if (status != PJ_SUCCESS)
@@ -817,5 +817,5 @@
     status = pjsua_conf_connect(0, rec_slot);
     status = pjsua_conf_connect(play_slot, rec_slot);
-    
+
 
     /* We're running */
@@ -870,5 +870,5 @@
 	goto on_return;
 
-    status = calculate_latency(pool, wav_port, &lat_sum, &lat_cnt, 
+    status = calculate_latency(pool, wav_port, &lat_sum, &lat_cnt,
 			       &lat_min, &lat_max);
     if (status != PJ_SUCCESS)
@@ -913,5 +913,5 @@
 	    msglen = strlen(msg);
 	}
-	
+
 	key = gui_msgbox(title, msg, WITH_OK);
 
@@ -965,5 +965,5 @@
      * Create player and recorder
      */
-    status = create_player(PJ_ARRAY_SIZE(ref_wav_paths), ref_wav_paths, 
+    status = create_player(PJ_ARRAY_SIZE(ref_wav_paths), ref_wav_paths,
 			   &player_id);
     if (status != PJ_SUCCESS) {
@@ -1018,5 +1018,5 @@
     gui_msgbox(title, "We are now playing the captured audio from the mic. "
 		      "Check if echo (of the audio played back previously) is "
-		      "present in the audio. The recording is stored in " 
+		      "present in the audio. The recording is stored in "
 		      AEC_REC_PATH " for offline analysis. "
 		      "Press OK to stop.",
@@ -1074,5 +1074,5 @@
     enum gui_key key;
     const char *title = "Audio Device List";
-    
+
     ti = systest_alloc_test_item(title);
     if (!ti)
@@ -1083,5 +1083,5 @@
     dev_count = pjmedia_aud_dev_count();
     if (dev_count == 0) {
-	key = gui_msgbox(title, 
+	key = gui_msgbox(title,
 			 "No audio devices are found", WITH_OK);
 	ti->success = PJ_FALSE;
@@ -1107,5 +1107,5 @@
 	pj_ansi_snprintf(ti->reason+len, sizeof(ti->reason)-len,
 			 " %2d: %s [%s] (%d/%d)\r\n",
-		          i, info.driver, info.name, 
+		          i, info.driver, info.name,
 			  info.input_count, info.output_count);
 	len = strlen(ti->reason);
@@ -1114,4 +1114,5 @@
     ti->reason[len] = '\0';
     key = gui_msgbox(title, ti->reason, WITH_OK);
+    PJ_UNUSED_ARG(key);
 
     ti->success = PJ_TRUE;
@@ -1205,5 +1206,5 @@
     ti->reason[sizeof(ti->reason)-1] = '\0';
     key = gui_msgbox(title, textbuf, WITH_OK);
-
+    PJ_UNUSED_ARG(key); /* Warning about unused var */
 }
 
@@ -1243,5 +1244,5 @@
     systest.media_cfg.snd_rec_latency = OVERRIDE_AUDDEV_REC_LAT;
 #endif
-	
+
     status = pjsua_init(&systest.ua_cfg, &log_cfg, &systest.media_cfg);
     if (status != PJ_SUCCESS) {
Index: pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c	(revision 4727)
+++ pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -138,5 +138,5 @@
 /*
  * Create response digest based on the parameters and store the
- * digest ASCII in 'result'. 
+ * digest ASCII in 'result'.
  */
 PJ_DEF(void) pjsip_auth_create_digest( pj_str_t *result,
@@ -160,6 +160,6 @@
 
     if ((cred_info->data_type & PASSWD_MASK) == PJSIP_CRED_DATA_PLAIN_PASSWD) {
-	/*** 
-	 *** ha1 = MD5(username ":" realm ":" password) 
+	/***
+	 *** ha1 = MD5(username ":" realm ":" password)
 	 ***/
 	pj_md5_init(&pms);
@@ -183,5 +183,5 @@
 
     /***
-     *** ha2 = MD5(method ":" req_uri) 
+     *** ha2 = MD5(method ":" req_uri)
      ***/
     pj_md5_init(&pms);
@@ -196,5 +196,5 @@
     /***
      *** When qop is not used:
-     ***    response = MD5(ha1 ":" nonce ":" ha2) 
+     ***    response = MD5(ha1 ":" nonce ":" ha2)
      ***
      *** When qop=auth is used:
@@ -218,5 +218,5 @@
     /* This is the final response digest. */
     pj_md5_final(&pms, digest);
-    
+
     /* Convert digest to string and store in chal->response. */
     result->slen = PJSIP_MD5STRLEN;
@@ -259,5 +259,5 @@
 
 /*
- * Generate response digest. 
+ * Generate response digest.
  * Most of the parameters to generate the digest (i.e. username, realm, uri,
  * and nonce) are expected to be in the credential. Additional parameters (i.e.
@@ -308,16 +308,16 @@
 	if ((cred_info->data_type & EXT_MASK) == PJSIP_CRED_DATA_EXT_AKA) {
 	    /* Call application callback to create the response digest */
-	    return (*cred_info->ext.aka.cb)(pool, chal, cred_info, 
+	    return (*cred_info->ext.aka.cb)(pool, chal, cred_info,
 					    method, cred);
-	} 
+	}
 	else {
 	    /* Convert digest to string and store in chal->response. */
-	    pjsip_auth_create_digest( &cred->response, &cred->nonce, NULL, 
-				      NULL,  NULL, uri, &chal->realm, 
+	    pjsip_auth_create_digest( &cred->response, &cred->nonce, NULL,
+				      NULL,  NULL, uri, &chal->realm,
 				      cred_info, method);
 	}
 
     } else if (has_auth_qop(pool, &chal->qop)) {
-	/* Server requires quality of protection. 
+	/* Server requires quality of protection.
 	 * We respond with selecting "qop=auth" protection.
 	 */
@@ -335,10 +335,10 @@
 	if ((cred_info->data_type & EXT_MASK) == PJSIP_CRED_DATA_EXT_AKA) {
 	    /* Call application callback to create the response digest */
-	    return (*cred_info->ext.aka.cb)(pool, chal, cred_info, 
+	    return (*cred_info->ext.aka.cb)(pool, chal, cred_info,
 					    method, cred);
 	}
 	else {
-	    pjsip_auth_create_digest( &cred->response, &cred->nonce, 
-				      &cred->nc, cnonce, &pjsip_AUTH_STR, 
+	    pjsip_auth_create_digest( &cred->response, &cred->nonce,
+				      &cred->nc, cnonce, &pjsip_AUTH_STR,
 				      uri, &chal->realm, cred_info, method );
 	}
@@ -346,5 +346,5 @@
     } else {
 	/* Server requires quality protection that we don't support. */
-	PJ_LOG(4,(THIS_FILE, "Unsupported qop offer %.*s", 
+	PJ_LOG(4,(THIS_FILE, "Unsupported qop offer %.*s",
 		  chal->qop.slen, chal->qop.ptr));
 	return PJSIP_EINVALIDQOP;
@@ -358,5 +358,5 @@
  * Update authentication session with a challenge.
  */
-static void update_digest_session( pj_pool_t *ses_pool, 
+static void update_digest_session( pj_pool_t *ses_pool,
 				   pjsip_cached_auth *cached_auth,
 				   const pjsip_www_authenticate_hdr *hdr )
@@ -371,5 +371,5 @@
 	     * than the one in the cache, to reduce memory usage.
 	     */
-	    const pjsip_digest_challenge *d1 = 
+	    const pjsip_digest_challenge *d1 =
 			&cached_auth->last_chal->challenge.digest;
 	    const pjsip_digest_challenge *d2 = &hdr->challenge.digest;
@@ -407,5 +407,5 @@
 	*/
 	if (cached_auth->realm.slen == 0) {
-	    pj_strdup(ses_pool, &cached_auth->realm, 
+	    pj_strdup(ses_pool, &cached_auth->realm,
 		      &hdr->challenge.digest.realm);
 	}
@@ -413,6 +413,6 @@
     } else {
 	/* Update last_nonce and nonce-count */
-	if (!pj_strcmp(&hdr->challenge.digest.nonce, 
-		       &cached_auth->last_chal->challenge.digest.nonce)) 
+	if (!pj_strcmp(&hdr->challenge.digest.nonce,
+		       &cached_auth->last_chal->challenge.digest.nonce))
 	{
 	    /* Same nonce, increment nonce-count */
@@ -424,7 +424,7 @@
 	    /* Has the opaque changed? */
 	    if (pj_strcmp(&cached_auth->last_chal->challenge.digest.opaque,
-			  &hdr->challenge.digest.opaque)) 
+			  &hdr->challenge.digest.opaque))
 	    {
-		pj_strdup(ses_pool, 
+		pj_strdup(ses_pool,
 			  &cached_auth->last_chal->challenge.digest.opaque,
 			  &hdr->challenge.digest.opaque);
@@ -485,5 +485,5 @@
 PJ_DEF(pj_status_t) pjsip_auth_clt_init(  pjsip_auth_clt_sess *sess,
 					  pjsip_endpoint *endpt,
-					  pj_pool_t *pool, 
+					  pj_pool_t *pool,
 					  unsigned options)
 {
@@ -510,13 +510,13 @@
 
     pjsip_auth_clt_init(sess, (pjsip_endpoint*)rhs->endpt, pool, 0);
-    
+
     sess->cred_cnt = rhs->cred_cnt;
     sess->cred_info = (pjsip_cred_info*)
-    		      pj_pool_alloc(pool, 
+    		      pj_pool_alloc(pool,
 				    sess->cred_cnt*sizeof(pjsip_cred_info));
     for (i=0; i<rhs->cred_cnt; ++i) {
 	pj_strdup(pool, &sess->cred_info[i].realm, &rhs->cred_info[i].realm);
 	pj_strdup(pool, &sess->cred_info[i].scheme, &rhs->cred_info[i].scheme);
-	pj_strdup(pool, &sess->cred_info[i].username, 
+	pj_strdup(pool, &sess->cred_info[i].username,
 		  &rhs->cred_info[i].username);
 	sess->cred_info[i].data_type = rhs->cred_info[i].data_type;
@@ -553,5 +553,5 @@
 	    sess->cred_info[i].data_type = c[i].data_type;
 
-	    /* When data_type is PJSIP_CRED_DATA_EXT_AKA, 
+	    /* When data_type is PJSIP_CRED_DATA_EXT_AKA,
 	     * callback must be specified.
 	     */
@@ -569,9 +569,9 @@
 
 		/* Verify K len */
-		PJ_ASSERT_RETURN(c[i].ext.aka.k.slen <= PJSIP_AKA_KLEN, 
+		PJ_ASSERT_RETURN(c[i].ext.aka.k.slen <= PJSIP_AKA_KLEN,
 				 PJSIP_EAUTHINAKACRED);
 
 		/* Verify OP len */
-		PJ_ASSERT_RETURN(c[i].ext.aka.op.slen <= PJSIP_AKA_OPLEN, 
+		PJ_ASSERT_RETURN(c[i].ext.aka.op.slen <= PJSIP_AKA_OPLEN,
 				 PJSIP_EAUTHINAKACRED);
 
@@ -631,5 +631,5 @@
 
 
-/* 
+/*
  * Create Authorization/Proxy-Authorization response header based on the challege
  * in WWW-Authenticate/Proxy-Authenticate header.
@@ -786,5 +786,5 @@
     if (status != PJ_SUCCESS)
 	return status;
-    
+
     pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)hauth);
 
@@ -832,4 +832,5 @@
     /* Get the method. */
     method = &tdata->msg->line.req.method;
+    PJ_UNUSED_ARG(method); /* Warning about unused var caused by #if below */
 
     auth = sess->cached_auth.next;
@@ -870,10 +871,10 @@
 #	    endif
 
-	} 
+	}
 #	if defined(PJSIP_AUTH_QOP_SUPPORT) && \
 	   defined(PJSIP_AUTH_AUTO_SEND_NEXT) && \
 	   (PJSIP_AUTH_QOP_SUPPORT && PJSIP_AUTH_AUTO_SEND_NEXT)
 	else if (auth->qop_value == PJSIP_AUTH_QOP_AUTH) {
-	    /* For qop="auth", we have to re-create the authorization header. 
+	    /* For qop="auth", we have to re-create the authorization header.
 	     */
 	    const pjsip_cred_info *cred;
@@ -881,5 +882,5 @@
 	    pj_status_t status;
 
-	    cred = auth_find_cred(sess, &auth->realm, 
+	    cred = auth_find_cred(sess, &auth->realm,
 				  &auth->last_chal->scheme);
 	    if (!cred) {
@@ -888,6 +889,6 @@
 	    }
 
-	    status = auth_respond( tdata->pool, auth->last_chal, 
-				   tdata->msg->line.req.uri, 
+	    status = auth_respond( tdata->pool, auth->last_chal,
+				   tdata->msg->line.req.uri,
 				   cred,
 				   &tdata->msg->line.req.method,
@@ -895,5 +896,5 @@
 	    if (status != PJ_SUCCESS)
 		return status;
-	    
+
 	    //pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)hauth);
 	    pj_list_push_back(&added, hauth);
@@ -984,5 +985,5 @@
 	{
 	    sent_auth = (pjsip_authorization_hdr*) hdr;
-	    if (pj_stricmp(&hchal->challenge.common.realm, 
+	    if (pj_stricmp(&hchal->challenge.common.realm,
 			   &sent_auth->credential.common.realm )==0)
 	    {
@@ -1055,11 +1056,11 @@
 
     /* Find credential to be used for the challenge. */
-    cred = auth_find_cred( sess, &hchal->challenge.common.realm, 
+    cred = auth_find_cred( sess, &hchal->challenge.common.realm,
 			   &hchal->scheme);
     if (!cred) {
 	const pj_str_t *realm = &hchal->challenge.common.realm;
-	PJ_LOG(4,(THIS_FILE, 
+	PJ_LOG(4,(THIS_FILE,
 		  "Unable to set auth for %s: can not find credential for %.*s/%.*s",
-		  tdata->obj_name, 
+		  tdata->obj_name,
 		  realm->slen, realm->ptr,
 		  hchal->scheme.slen, hchal->scheme.ptr));
@@ -1068,6 +1069,6 @@
 
     /* Respond to authorization challenge. */
-    status = auth_respond( req_pool, hchal, uri, cred, 
-			   &tdata->msg->line.req.method, 
+    status = auth_respond( req_pool, hchal, uri, cred,
+			   &tdata->msg->line.req.method,
 			   sess->pool, cached_auth, h_auth);
     return status;
@@ -1148,5 +1149,5 @@
 	 * authorization session.
 	 */
-	status = process_auth( tdata->pool, hchal, tdata->msg->line.req.uri, 
+	status = process_auth( tdata->pool, hchal, tdata->msg->line.req.uri,
 			       tdata, sess, cached_auth, &hauth);
 	if (status != PJ_SUCCESS)
Index: pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_dialog.c	(revision 4727)
+++ pjproject/trunk/pjsip/src/pjsip/sip_dialog.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <pjsip/sip_dialog.h>
@@ -74,6 +74,6 @@
 	return PJ_EINVALIDOP;
 
-    pool = pjsip_endpt_create_pool(endpt, "dlg%p", 
-				   PJSIP_POOL_LEN_DIALOG, 
+    pool = pjsip_endpt_create_pool(endpt, "dlg%p",
+				   PJSIP_POOL_LEN_DIALOG,
 				   PJSIP_POOL_INC_DIALOG);
     if (!pool)
@@ -195,6 +195,6 @@
     dlg->local.info = pjsip_from_hdr_create(dlg->pool);
     pj_strdup_with_null(dlg->pool, &dlg->local.info_str, local_uri);
-    dlg->local.info->uri = pjsip_parse_uri(dlg->pool, 
-					   dlg->local.info_str.ptr, 
+    dlg->local.info->uri = pjsip_parse_uri(dlg->pool,
+					   dlg->local.info_str.ptr,
 					   dlg->local.info_str.slen, 0);
     if (!dlg->local.info->uri) {
@@ -215,8 +215,8 @@
 
     /* Init local contact. */
-    pj_strdup_with_null(dlg->pool, &tmp, 
+    pj_strdup_with_null(dlg->pool, &tmp,
 			local_contact ? local_contact : local_uri);
     dlg->local.contact = (pjsip_contact_hdr*)
-			 pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp.ptr, 
+			 pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp.ptr,
 					 tmp.slen, NULL);
     if (!dlg->local.contact) {
@@ -228,6 +228,6 @@
     dlg->remote.info = pjsip_to_hdr_create(dlg->pool);
     pj_strdup_with_null(dlg->pool, &dlg->remote.info_str, remote_uri);
-    dlg->remote.info->uri = pjsip_parse_uri(dlg->pool, 
-					    dlg->remote.info_str.ptr, 
+    dlg->remote.info->uri = pjsip_parse_uri(dlg->pool,
+					    dlg->remote.info_str.ptr,
 					    dlg->remote.info_str.slen, 0);
     if (!dlg->remote.info->uri) {
@@ -240,5 +240,5 @@
 	PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri))
     {
-	pjsip_sip_uri *sip_uri = (pjsip_sip_uri *) 
+	pjsip_sip_uri *sip_uri = (pjsip_sip_uri *)
 				 pjsip_uri_get_uri(dlg->remote.info->uri);
 	if (!pj_list_empty(&sip_uri->header_param)) {
@@ -249,8 +249,8 @@
 
 	    /* Print URI */
-	    tmp.ptr = (char*) pj_pool_alloc(dlg->pool, 
+	    tmp.ptr = (char*) pj_pool_alloc(dlg->pool,
 	    				    dlg->remote.info_str.slen);
 	    tmp.slen = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR,
-				       sip_uri, tmp.ptr, 
+				       sip_uri, tmp.ptr,
 				       dlg->remote.info_str.slen);
 
@@ -283,5 +283,5 @@
 
     /* Init client authentication session. */
-    status = pjsip_auth_clt_init(&dlg->auth_sess, dlg->endpt, 
+    status = pjsip_auth_clt_init(&dlg->auth_sess, dlg->endpt,
 				 dlg->pool, 0);
     if (status != PJ_SUCCESS)
@@ -333,9 +333,9 @@
 		     PJSIP_ENOTREQUESTMSG);
 
-    /* Request must not have To tag. 
+    /* Request must not have To tag.
      * This should have been checked in the user agent (or application?).
      */
     PJ_ASSERT_RETURN(rdata->msg_info.to->tag.slen == 0, PJ_EINVALIDOP);
-		     
+
     /* The request must be a dialog establishing request. */
     PJ_ASSERT_RETURN(
@@ -385,7 +385,7 @@
     /* TODO:
      *  Section 12.1.1, paragraph about using SIPS URI in Contact.
-     *  If the request that initiated the dialog contained a SIPS URI 
-     *  in the Request-URI or in the top Record-Route header field value, 
-     *  if there was any, or the Contact header field if there was no 
+     *  If the request that initiated the dialog contained a SIPS URI
+     *  in the Request-URI or in the top Record-Route header field value,
+     *  if there was any, or the Contact header field if there was no
      *  Record-Route header field, the Contact header field in the response
      *  MUST be a SIPS URI.
@@ -396,5 +396,5 @@
 	pj_strdup_with_null(dlg->pool, &tmp, contact);
 	dlg->local.contact = (pjsip_contact_hdr*)
-			     pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp.ptr, 
+			     pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp.ptr,
 					     tmp.slen, NULL);
 	if (!dlg->local.contact) {
@@ -409,5 +409,5 @@
 
     /* Init remote info from the From header. */
-    dlg->remote.info = (pjsip_fromto_hdr*) 
+    dlg->remote.info = (pjsip_fromto_hdr*)
     		       pjsip_hdr_clone(dlg->pool, rdata->msg_info.from);
     pjsip_fromto_hdr_set_to(dlg->remote.info);
@@ -426,5 +426,5 @@
 
 
-    /* Init remote's contact from Contact header. 
+    /* Init remote's contact from Contact header.
      * Iterate the Contact URI until we find sip: or sips: scheme.
      */
@@ -452,5 +452,5 @@
     }
 
-    dlg->remote.contact = (pjsip_contact_hdr*) 
+    dlg->remote.contact = (pjsip_contact_hdr*)
     			  pjsip_hdr_clone(dlg->pool, (pjsip_hdr*)contact_hdr);
 
@@ -464,7 +464,7 @@
     dlg->role = PJSIP_ROLE_UAS;
 
-    /* Secure? 
+    /* Secure?
      *  RFC 3261 Section 12.1.1:
-     *  If the request arrived over TLS, and the Request-URI contained a 
+     *  If the request arrived over TLS, and the Request-URI contained a
      *  SIPS URI, the 'secure' flag is set to TRUE.
      */
@@ -473,11 +473,11 @@
 
     /* Call-ID */
-    dlg->call_id = (pjsip_cid_hdr*) 
+    dlg->call_id = (pjsip_cid_hdr*)
     		   pjsip_hdr_clone(dlg->pool, rdata->msg_info.cid);
 
-    /* Route set. 
+    /* Route set.
      *  RFC 3261 Section 12.1.1:
-     *  The route set MUST be set to the list of URIs in the Record-Route 
-     *  header field from the request, taken in order and preserving all URI 
+     *  The route set MUST be set to the list of URIs in the Record-Route
+     *  header field from the request, taken in order and preserving all URI
      *  parameters. If no Record-Route header field is present in the request,
      * the route set MUST be set to the empty set.
@@ -499,5 +499,5 @@
 	if (rr == (void*)&rdata->msg_info.msg->hdr)
 	    break;
-	rr = (pjsip_route_hdr*) pjsip_msg_find_hdr(rdata->msg_info.msg, 
+	rr = (pjsip_route_hdr*) pjsip_msg_find_hdr(rdata->msg_info.msg,
 						   PJSIP_H_RECORD_ROUTE, rr);
     }
@@ -621,5 +621,5 @@
     /* Check arguments. */
     PJ_ASSERT_RETURN(first_dlg && rdata && new_dlg, PJ_EINVAL);
-    
+
     /* rdata must be response message. */
     PJ_ASSERT_RETURN(msg->type == PJSIP_RESPONSE_MSG,
@@ -649,5 +649,5 @@
 
     /* Clone local info. */
-    dlg->local.info = (pjsip_fromto_hdr*) 
+    dlg->local.info = (pjsip_fromto_hdr*)
     		      pjsip_hdr_clone(dlg->pool, first_dlg->local.info);
 
@@ -661,9 +661,9 @@
 
     /* Clone local Contact. */
-    dlg->local.contact = (pjsip_contact_hdr*) 
+    dlg->local.contact = (pjsip_contact_hdr*)
     			 pjsip_hdr_clone(dlg->pool, first_dlg->local.contact);
 
     /* Clone remote info. */
-    dlg->remote.info = (pjsip_fromto_hdr*) 
+    dlg->remote.info = (pjsip_fromto_hdr*)
     		       pjsip_hdr_clone(dlg->pool, first_dlg->remote.info);
 
@@ -690,5 +690,5 @@
 
     /* Clone Call-ID header. */
-    dlg->call_id = (pjsip_cid_hdr*) 
+    dlg->call_id = (pjsip_cid_hdr*)
     		   pjsip_hdr_clone(dlg->pool, first_dlg->call_id);
 
@@ -708,5 +708,5 @@
 
     /* Clone client authentication session. */
-    status = pjsip_auth_clt_clone(dlg->pool, &dlg->auth_sess, 
+    status = pjsip_auth_clt_clone(dlg->pool, &dlg->auth_sess,
 				  &first_dlg->auth_sess);
     if (status != PJ_SUCCESS)
@@ -842,5 +842,5 @@
 PJ_DEF(void) pjsip_dlg_inc_lock(pjsip_dialog *dlg)
 {
-    PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_inc_lock(), sess_count=%d", 
+    PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_inc_lock(), sess_count=%d",
 	      dlg->sess_count));
 
@@ -848,5 +848,5 @@
     dlg->sess_count++;
 
-    PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_inc_lock(), sess_count=%d", 
+    PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_inc_lock(), sess_count=%d",
 	      dlg->sess_count));
 }
@@ -859,5 +859,5 @@
     pj_status_t status;
 
-    PJ_LOG(6,(dlg->obj_name,"Entering pjsip_dlg_try_inc_lock(), sess_count=%d", 
+    PJ_LOG(6,(dlg->obj_name,"Entering pjsip_dlg_try_inc_lock(), sess_count=%d",
 	      dlg->sess_count));
 
@@ -870,5 +870,5 @@
     dlg->sess_count++;
 
-    PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_try_inc_lock(), sess_count=%d", 
+    PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_try_inc_lock(), sess_count=%d",
 	      dlg->sess_count));
 
@@ -885,5 +885,5 @@
     PJ_ASSERT_ON_FAIL(dlg!=NULL, return);
 
-    PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_dec_lock(), sess_count=%d", 
+    PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_dec_lock(), sess_count=%d",
 	      dlg->sess_count));
 
@@ -960,5 +960,5 @@
     PJ_ASSERT_RETURN(dlg->usage_cnt < PJSIP_MAX_MODULE, PJ_EBUG);
 
-    PJ_LOG(5,(dlg->obj_name, 
+    PJ_LOG(5,(dlg->obj_name,
 	      "Module %.*s added as dialog usage, data=%p",
 	      (int)mod->name.slen, mod->name.ptr, mod_data));
@@ -977,5 +977,5 @@
 	     * So return PJ_SUCCESS here.
 	     */
-	    PJ_LOG(4,(dlg->obj_name, 
+	    PJ_LOG(4,(dlg->obj_name,
 		      "Module %.*s already registered as dialog usage, "
 		      "updating the data %p",
@@ -1000,5 +1000,5 @@
     pj_array_insert(dlg->usage, sizeof(dlg->usage[0]), dlg->usage_cnt,
 		    index, &mod);
-    
+
     /* Set module data. */
     dlg->mod_data[mod->id] = mod_data;
@@ -1014,5 +1014,5 @@
 
 /*
- * Attach module specific data to the dialog. Application can also set 
+ * Attach module specific data to the dialog. Application can also set
  * the value directly by accessing dlg->mod_data[module_id].
  */
@@ -1044,5 +1044,5 @@
 /*
  * Create a new request within dialog (i.e. after the dialog session has been
- * established). The construction of such requests follows the rule in 
+ * established). The construction of such requests follows the rule in
  * RFC3261 section 12.2.1.
  */
@@ -1058,5 +1058,5 @@
 
     /* Contact Header field.
-     * Contact can only be present in requests that establish dialog (in the 
+     * Contact can only be present in requests that establish dialog (in the
      * core SIP spec, only INVITE).
      */
@@ -1083,5 +1083,5 @@
 	return status;
 
-    /* Just copy dialog route-set to Route header. 
+    /* Just copy dialog route-set to Route header.
      * The transaction will do the processing as specified in Section 12.2.1
      * of RFC 3261 in function tsx_process_route() in sip_transaction.c.
@@ -1193,8 +1193,8 @@
      */
     if (msg->line.req.method.id != PJSIP_CANCEL_METHOD &&
-	msg->line.req.method.id != PJSIP_ACK_METHOD) 
+	msg->line.req.method.id != PJSIP_ACK_METHOD)
     {
 	pjsip_cseq_hdr *ch;
-	
+
 	ch = PJSIP_MSG_CSEQ_HDR(msg);
 	PJ_ASSERT_RETURN(ch!=NULL, PJ_EBUG);
@@ -1245,5 +1245,5 @@
 
 	/* Send request */
-	status = pjsip_endpt_send_request_stateless(dlg->endpt, tdata, 
+	status = pjsip_endpt_send_request_stateless(dlg->endpt, tdata,
 						    NULL, NULL);
 	if (status != PJ_SUCCESS)
@@ -1260,5 +1260,5 @@
     /* Unlock dialog, may destroy dialog. */
     pjsip_dlg_dec_lock(dlg);
-   
+
     /* Whatever happen delete the message. */
     pjsip_tx_data_dec_ref( tdata );
@@ -1287,11 +1287,11 @@
 	/* Add Contact header for 1xx, 2xx, 3xx and 485 response. */
 	if (st_class==2 || st_class==3 || (st_class==1 && st_code != 100) ||
-	    st_code==485) 
+	    st_code==485)
 	{
 	    /* Add contact header only if one is not present. */
 	    if (pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, NULL) == 0 &&
-		pjsip_msg_find_hdr_by_name(tdata->msg, &HCONTACT, NULL) == 0) 
+		pjsip_msg_find_hdr_by_name(tdata->msg, &HCONTACT, NULL) == 0)
 	    {
-		hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, 
+		hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool,
 						   dlg->local.contact);
 		pjsip_msg_add_hdr(tdata->msg, hdr);
@@ -1302,5 +1302,5 @@
 	if ((((st_code/10==18 || st_class==2) && dlg->add_allow)
 	     || st_code==405) &&
-	    pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ALLOW, NULL)==NULL) 
+	    pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ALLOW, NULL)==NULL)
 	{
 	    c_hdr = pjsip_endpt_get_capability(dlg->endpt,
@@ -1313,6 +1313,6 @@
 
 	/* Add Supported header in 2xx response. */
-	if (st_class==2 && 
-	    pjsip_msg_find_hdr(tdata->msg, PJSIP_H_SUPPORTED, NULL)==NULL) 
+	if (st_class==2 &&
+	    pjsip_msg_find_hdr(tdata->msg, PJSIP_H_SUPPORTED, NULL)==NULL)
 	{
 	    c_hdr = pjsip_endpt_get_capability(dlg->endpt,
@@ -1401,5 +1401,5 @@
     }
 
-    /* Remove existing Contact header (without this, when dialog sent 
+    /* Remove existing Contact header (without this, when dialog sent
      * 180 and then 302, the Contact in 302 will not get updated).
      */
@@ -1446,5 +1446,5 @@
 	      pjsip_tx_data_get_info(tdata)));
 
-    /* Check that transaction method and cseq match the response. 
+    /* Check that transaction method and cseq match the response.
      * This operation is sloooww (search CSeq header twice), that's why
      * we only do it in debug mode.
@@ -1452,5 +1452,5 @@
 #if defined(PJ_DEBUG) && PJ_DEBUG!=0
     PJ_ASSERT_RETURN( PJSIP_MSG_CSEQ_HDR(tdata->msg)->cseq == tsx->cseq &&
-		      pjsip_method_cmp(&PJSIP_MSG_CSEQ_HDR(tdata->msg)->method, 
+		      pjsip_method_cmp(&PJSIP_MSG_CSEQ_HDR(tdata->msg)->method,
 				       &tsx->method)==0,
 		      PJ_EINVALIDOP);
@@ -1478,5 +1478,5 @@
     status = pjsip_tsx_send_msg(tsx, tdata);
 
-    /* This function must decrement transmit data request counter 
+    /* This function must decrement transmit data request counter
      * regardless of the operation status. The transaction only
      * decrements the counter if the operation is successful.
@@ -1563,5 +1563,5 @@
     if (rdata->msg_info.cseq->cseq <= dlg->remote.cseq &&
 	rdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD &&
-	rdata->msg_info.msg->line.req.method.id != PJSIP_CANCEL_METHOD) 
+	rdata->msg_info.msg->line.req.method.id != PJSIP_CANCEL_METHOD)
     {
 	/* Invalid CSeq.
@@ -1595,6 +1595,6 @@
 
     /* Create UAS transaction for this request. */
-    if (pjsip_rdata_get_tsx(rdata) == NULL && 
-	rdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD) 
+    if (pjsip_rdata_get_tsx(rdata) == NULL &&
+	rdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD)
     {
 	status = pjsip_tsx_create_uas(dlg->ua, rdata, &tsx);
@@ -1630,5 +1630,5 @@
 
 	contact = (pjsip_contact_hdr*)
-		  pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, 
+		  pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
 				     NULL);
 	if (contact && contact->uri &&
@@ -1638,5 +1638,5 @@
 			   contact->uri)))
 	{
-	    dlg->remote.contact = (pjsip_contact_hdr*) 
+	    dlg->remote.contact = (pjsip_contact_hdr*)
 	    			  pjsip_hdr_clone(dlg->pool, contact);
 	    dlg->target = dlg->remote.contact->uri;
@@ -1688,9 +1688,9 @@
 {
     const pjsip_hdr *hdr, *end_hdr;
-    pj_int32_t msg_cseq;
+    //pj_int32_t msg_cseq;
     const pjsip_msg *msg;
 
     msg = rdata->msg_info.msg;
-    msg_cseq = rdata->msg_info.cseq->cseq;
+    //msg_cseq = rdata->msg_info.cseq->cseq;
 
     /* Ignore if route set has been frozen */
@@ -1708,5 +1708,5 @@
 
 	/* Ignore subsequent responses with higher CSeq than initial CSeq.
-	 * Unfortunately this would be broken when the first request is 
+	 * Unfortunately this would be broken when the first request is
 	 * challenged!
 	 */
@@ -1747,6 +1747,6 @@
     PJ_LOG(5,(dlg->obj_name, "Route-set updated"));
 
-    /* Freeze the route set only when the route set comes in 2xx response. 
-     * If it is in 1xx response, prepare to recompute the route set when 
+    /* Freeze the route set only when the route set comes in 2xx response.
+     * If it is in 1xx response, prepare to recompute the route set when
      * the 2xx response comes in.
      *
@@ -1756,9 +1756,9 @@
      * upon receiving 2xx response). Also RFC 3261 says so in 13.2.2.4.
      *
-     * The pjsip_method_creates_dialog() check protects from wrongly 
+     * The pjsip_method_creates_dialog() check protects from wrongly
      * freezing the route set upon receiving 200/OK response for PRACK.
      */
     if (pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) &&
-	PJSIP_IS_STATUS_IN_CLASS(msg->line.status.code, 200)) 
+	PJSIP_IS_STATUS_IN_CLASS(msg->line.status.code, 200))
     {
 	dlg->route_set_frozen = PJ_TRUE;
@@ -1789,5 +1789,5 @@
     res_code = rdata->msg_info.msg->line.status.code;
 
-    /* When we receive response that establishes dialog, update To tag, 
+    /* When we receive response that establishes dialog, update To tag,
      * route set and dialog target.
      *
@@ -1803,11 +1803,11 @@
      * New update:
      * We also need to update the dialog for 1xx responses, to handle the
-     * case when 100rel is used, otherwise PRACK will be sent to the 
+     * case when 100rel is used, otherwise PRACK will be sent to the
      * wrong target.
      */
-    if ((dlg->state == PJSIP_DIALOG_STATE_NULL && 
+    if ((dlg->state == PJSIP_DIALOG_STATE_NULL &&
 	 pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) &&
 	 (res_code > 100 && res_code < 300) &&
-	 rdata->msg_info.to->tag.slen) 
+	 rdata->msg_info.to->tag.slen)
 	 ||
 	(dlg->role==PJSIP_ROLE_UAC &&
@@ -1820,5 +1820,5 @@
 	pjsip_contact_hdr *contact;
 
-	/* Update remote capability info, when To tags in the dialog remote 
+	/* Update remote capability info, when To tags in the dialog remote
 	 * info and the incoming response are different, e.g: first response
 	 * with To-tag or forking, apply strict update.
@@ -1834,7 +1834,7 @@
 	/* RFC 3271 Section 12.1.2:
 	 * The route set MUST be set to the list of URIs in the Record-Route
-	 * header field from the response, taken in reverse order and 
-	 * preserving all URI parameters. If no Record-Route header field 
-	 * is present in the response, the route set MUST be set to the 
+	 * header field from the response, taken in reverse order and
+	 * preserving all URI parameters. If no Record-Route header field
+	 * is present in the response, the route set MUST be set to the
 	 * empty set. This route set, even if empty, overrides any pre-existing
 	 * route set for future requests in this dialog.
@@ -1842,9 +1842,9 @@
 	dlg_update_routeset(dlg, rdata);
 
-	/* The remote target MUST be set to the URI from the Contact header 
+	/* The remote target MUST be set to the URI from the Contact header
 	 * field of the response.
 	 */
 	contact = (pjsip_contact_hdr*)
-		  pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, 
+		  pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
 				     NULL);
 	if (contact && contact->uri &&
@@ -1854,5 +1854,5 @@
 			   contact->uri)))
 	{
-	    dlg->remote.contact = (pjsip_contact_hdr*) 
+	    dlg->remote.contact = (pjsip_contact_hdr*)
 	    			  pjsip_hdr_clone(dlg->pool, contact);
 	    dlg->target = dlg->remote.contact->uri;
@@ -1864,6 +1864,6 @@
 	 * gets through this dialog (it shouldn't happen).
 	 */
-	if (dlg->role==PJSIP_ROLE_UAC && !dlg->uac_has_2xx && 
-	    res_code/100==2) 
+	if (dlg->role==PJSIP_ROLE_UAC && !dlg->uac_has_2xx &&
+	    res_code/100==2)
 	{
 	    dlg->uac_has_2xx = PJ_TRUE;
@@ -1872,5 +1872,5 @@
 
     /* Update remote target (again) when receiving 2xx response messages
-     * that's defined as target refresh. 
+     * that's defined as target refresh.
      *
      * Also upon receiving 2xx response, recheck again the route set.
@@ -1882,5 +1882,5 @@
 	the "confirmed" state, and the route set for the dialog MUST be
 	recomputed based on the 2xx response using the procedures of Section
-	12.2.1.2. 
+	12.2.1.2.
 
 	Note that the only piece of state that is recomputed is the route
@@ -1897,5 +1897,5 @@
 
 	contact = (pjsip_contact_hdr*) pjsip_msg_find_hdr(rdata->msg_info.msg,
-							  PJSIP_H_CONTACT, 
+							  PJSIP_H_CONTACT,
 				     			  NULL);
 	if (contact && contact->uri &&
@@ -1905,5 +1905,5 @@
 			   contact->uri)))
 	{
-	    dlg->remote.contact = (pjsip_contact_hdr*) 
+	    dlg->remote.contact = (pjsip_contact_hdr*)
 	    			  pjsip_hdr_clone(dlg->pool, contact);
 	    dlg->target = dlg->remote.contact->uri;
@@ -1943,6 +1943,6 @@
 	pj_status_t status;
 
-	if (rdata->msg_info.cseq->method.id==PJSIP_INVITE_METHOD && 
-	    rdata->msg_info.msg->line.status.code/100 == 2) 
+	if (rdata->msg_info.cseq->method.id==PJSIP_INVITE_METHOD &&
+	    rdata->msg_info.msg->line.status.code/100 == 2)
 	{
 	    pjsip_tx_data *ack;
@@ -1958,9 +1958,9 @@
 	    pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
 	    pjsip_tx_data *tdata;
-	    
-	    status = pjsip_auth_clt_reinit_req( &dlg->auth_sess, 
+
+	    status = pjsip_auth_clt_reinit_req( &dlg->auth_sess,
 						rdata, tsx->last_tx,
 						&tdata);
-	    
+
 	    if (status == PJ_SUCCESS) {
 		/* Re-send request. */
@@ -2015,5 +2015,5 @@
      */
     if (tsx->state == PJSIP_TSX_STATE_TERMINATED &&
-	tsx->mod_data[dlg->ua->id] == dlg) 
+	tsx->mod_data[dlg->ua->id] == dlg)
     {
 	pj_assert(dlg->tsx_count>0);
@@ -2045,5 +2045,5 @@
     pjsip_dlg_inc_lock(dlg);
 
-    hdr = (const pjsip_generic_array_hdr*) 
+    hdr = (const pjsip_generic_array_hdr*)
 	   pjsip_dlg_get_remote_cap_hdr(dlg, htype, hname);
     if (!hdr) {
@@ -2072,5 +2072,5 @@
 						pj_bool_t strict)
 {
-    pjsip_hdr_e htypes[] = 
+    pjsip_hdr_e htypes[] =
 	{ PJSIP_H_ACCEPT, PJSIP_H_ALLOW, PJSIP_H_SUPPORTED };
     unsigned i;
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 4727)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <pjsua-lib/pjsua.h>
@@ -39,5 +39,5 @@
  * The INFO method.
  */
-const pjsip_method pjsip_info_method = 
+const pjsip_method pjsip_info_method =
 {
     PJSIP_OTHER_METHOD,
@@ -49,5 +49,5 @@
  * session state has changed.
  */
-static void pjsua_call_on_state_changed(pjsip_inv_session *inv, 
+static void pjsua_call_on_state_changed(pjsip_inv_session *inv,
 					pjsip_event *e);
 
@@ -55,5 +55,5 @@
  * has forked.
  */
-static void pjsua_call_on_forked( pjsip_inv_session *inv, 
+static void pjsua_call_on_forked( pjsip_inv_session *inv,
 				  pjsip_event *e);
 
@@ -164,5 +164,5 @@
     /* Check the route URI's and force loose route if required */
     for (i=0; i<pjsua_var.ua_cfg.outbound_proxy_cnt; ++i) {
-	status = normalize_route_uri(pjsua_var.pool, 
+	status = normalize_route_uri(pjsua_var.pool,
 				     &pjsua_var.ua_cfg.outbound_proxy[i]);
 	if (status != PJ_SUCCESS)
@@ -258,5 +258,5 @@
 #if 1
     /* New algorithm: round-robin */
-    if (pjsua_var.next_call_id >= (int)pjsua_var.ua_cfg.max_calls || 
+    if (pjsua_var.next_call_id >= (int)pjsua_var.ua_cfg.max_calls ||
 	pjsua_var.next_call_id < 0)
     {
@@ -264,7 +264,7 @@
     }
 
-    for (cid=pjsua_var.next_call_id; 
-	 cid<(int)pjsua_var.ua_cfg.max_calls; 
-	 ++cid) 
+    for (cid=pjsua_var.next_call_id;
+	 cid<(int)pjsua_var.ua_cfg.max_calls;
+	 ++cid)
     {
 	if (pjsua_var.calls[cid].inv == NULL &&
@@ -310,10 +310,10 @@
     if (pj_stristr(dst_uri, &sips))
 	return 2;
-    
+
     if (!pj_list_empty(&acc->route_set)) {
 	pjsip_route_hdr *r = acc->route_set.next;
 	pjsip_uri *uri = r->name_addr.uri;
 	pjsip_sip_uri *sip_uri;
-	
+
 	sip_uri = (pjsip_sip_uri*)pjsip_uri_get_uri(uri);
 	if (pj_stricmp2(&sip_uri->transport_param, "tls")==0)
@@ -338,5 +338,5 @@
 	pjsip_uri *uri = r->name_addr.uri;
 	pjsip_sip_uri *sip_uri;
-	
+
 	sip_uri = (pjsip_sip_uri*)pjsip_uri_get_uri(uri);
 	if (pj_stricmp2(&sip_uri->transport_param, "tls")==0)
@@ -468,5 +468,5 @@
     /* Set credentials: */
     if (acc->cred_cnt) {
-	pjsip_auth_clt_set_credentials( &dlg->auth_sess, 
+	pjsip_auth_clt_set_credentials( &dlg->auth_sess,
 					acc->cred_cnt, acc->cred);
     }
@@ -479,5 +479,5 @@
     status = pjsip_inv_invite(inv, &tdata);
     if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Unable to create initial INVITE request", 
+	pjsua_perror(THIS_FILE, "Unable to create initial INVITE request",
 		     status);
 	goto on_error;
@@ -499,5 +499,5 @@
 	cb_called = PJ_TRUE;
 
-	/* Upon failure to send first request, the invite 
+	/* Upon failure to send first request, the invite
 	 * session would have been cleared.
 	 */
@@ -617,5 +617,5 @@
 
     /* Check that account is valid */
-    PJ_ASSERT_RETURN(acc_id>=0 || acc_id<(int)PJ_ARRAY_SIZE(pjsua_var.acc), 
+    PJ_ASSERT_RETURN(acc_id>=0 || acc_id<(int)PJ_ARRAY_SIZE(pjsua_var.acc),
 		     PJ_EINVAL);
 
@@ -631,10 +631,10 @@
 
     /* Create sound port if none is instantiated, to check if sound device
-     * can be used. But only do this with the conference bridge, as with 
-     * audio switchboard (i.e. APS-Direct), we can only open the sound 
+     * can be used. But only do this with the conference bridge, as with
+     * audio switchboard (i.e. APS-Direct), we can only open the sound
      * device once the correct format has been known
      */
-    if (!pjsua_var.is_mswitch && pjsua_var.snd_port==NULL && 
-	pjsua_var.null_snd==NULL && !pjsua_var.no_snd) 
+    if (!pjsua_var.is_mswitch && pjsua_var.snd_port==NULL &&
+	pjsua_var.null_snd==NULL && !pjsua_var.no_snd)
     {
 	status = pjsua_set_snd_dev(pjsua_var.cap_dev, pjsua_var.play_dev);
@@ -679,6 +679,6 @@
     tmp_pool = pjsua_pool_create("tmpcall10", 512, 256);
 
-    /* Verify that destination URI is valid before calling 
-     * pjsua_acc_create_uac_contact, or otherwise there  
+    /* Verify that destination URI is valid before calling
+     * pjsua_acc_create_uac_contact, or otherwise there
      * a misleading "Invalid Contact URI" error will be printed
      * when pjsua_acc_create_uac_contact() fails.
@@ -692,5 +692,5 @@
 
 	if (uri == NULL) {
-	    pjsua_perror(THIS_FILE, "Unable to make call", 
+	    pjsua_perror(THIS_FILE, "Unable to make call",
 			 PJSIP_EINVALIDREQURI);
 	    status = PJSIP_EINVALIDREQURI;
@@ -714,5 +714,5 @@
 					      acc_id, dest_uri);
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror(THIS_FILE, "Unable to generate Contact header", 
+	    pjsua_perror(THIS_FILE, "Unable to generate Contact header",
 			 status);
 	    goto on_error;
@@ -721,5 +721,5 @@
 
     /* Create outgoing dialog: */
-    status = pjsip_dlg_create_uac( pjsip_ua_instance(), 
+    status = pjsip_dlg_create_uac( pjsip_ua_instance(),
 				   &acc->cfg.id, &contact,
 				   dest_uri,
@@ -745,5 +745,5 @@
     /* Attach user data */
     call->user_data = user_data;
-    
+
     /* Store variables required for the callback after the async
      * media transport creation is completed.
@@ -762,5 +762,5 @@
 
     /* Init media channel */
-    status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 
+    status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC,
 				      call->secure_level, dlg->pool,
 				      NULL, NULL, PJ_TRUE,
@@ -813,5 +813,5 @@
 
 /* Get the NAT type information in remote's SDP */
-static void update_remote_nat_type(pjsua_call *call, 
+static void update_remote_nat_type(pjsua_call *call,
 				   const pjmedia_sdp_session *sdp)
 {
@@ -900,5 +900,5 @@
 {
     struct call_answer *answer, *next;
-    
+
     answer = call->async_call.call_var.inc_call.answers.next;
     while (answer != &call->async_call.call_var.inc_call.answers) {
@@ -906,5 +906,5 @@
 	pjsua_call_answer2(call->index, answer->opt, answer->code,
 			   answer->reason, answer->msg_data);
-        
+
         /* Call might have been disconnected if application is answering
          * with 200/OK and the media failed to start.
@@ -953,5 +953,5 @@
 
     status = pjsua_media_channel_create_sdp(call_id,
-                                            call->async_call.dlg->pool, 
+                                            call->async_call.dlg->pool,
 					    offer, &answer, &sip_err_code);
     if (status != PJ_SUCCESS) {
@@ -977,5 +977,5 @@
         sip_err_code = PJSIP_ERRNO_TO_SIP_STATUS(status);
 	goto on_return;
-    } 
+    }
 
 on_return:
@@ -1007,5 +1007,5 @@
 	if (call->async_call.call_var.inc_call.replaced_dlg) {
 	    /* Process pending call replace */
-	    pjsip_dialog *replaced_dlg = 
+	    pjsip_dialog *replaced_dlg =
 			call->async_call.call_var.inc_call.replaced_dlg;
 	    process_incoming_call_replace(call, replaced_dlg);
@@ -1054,5 +1054,5 @@
     /* Don't want to accept the call if shutdown is in progress */
     if (pjsua_var.thread_quit_flag) {
-	pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 
+	pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata,
 				      PJSIP_SC_TEMPORARILY_UNAVAILABLE, NULL,
 				      NULL, NULL);
@@ -1069,8 +1069,8 @@
 
     if (call_id == PJSUA_INVALID_ID) {
-	pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 
+	pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata,
 				      PJSIP_SC_BUSY_HERE, NULL,
 				      NULL, NULL);
-	PJ_LOG(2,(THIS_FILE, 
+	PJ_LOG(2,(THIS_FILE,
 		  "Unable to accept incoming call (too many calls)"));
 	goto on_return;
@@ -1098,5 +1098,5 @@
 
 	    pjsip_get_response_addr(response->pool, rdata, &res_addr);
-	    pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, response, 
+	    pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, response,
 				      NULL, NULL);
 
@@ -1152,5 +1152,5 @@
 		st_text = *pjsip_get_status_text(st_code);
 
-	    pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 
+	    pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata,
 				st_code, &st_text, NULL, NULL, NULL);
 	    goto on_return;
@@ -1158,5 +1158,5 @@
     }
 
-    /* 
+    /*
      * Get which account is most likely to be associated with this incoming
      * call. We need the account to find which contact URI to put for
@@ -1190,8 +1190,8 @@
 	    pjsip_warning_hdr *w;
 
-	    pjsua_perror(THIS_FILE, "Bad SDP in incoming INVITE", 
+	    pjsua_perror(THIS_FILE, "Bad SDP in incoming INVITE",
 			 status);
 
-	    w = pjsip_warning_hdr_create_from_status(rdata->tp_info.pool, 
+	    w = pjsip_warning_hdr_create_from_status(rdata->tp_info.pool,
 					     pjsip_endpt_name(pjsua_var.endpt),
 					     status);
@@ -1199,15 +1199,15 @@
 	    pj_list_push_back(&hdr_list, w);
 
-	    pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400, 
+	    pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400,
 				&reason, &hdr_list, NULL, NULL);
 	    goto on_return;
 	}
 
-	/* Do quick checks on SDP before passing it to transports. More elabore 
+	/* Do quick checks on SDP before passing it to transports. More elabore
 	 * checks will be done in pjsip_inv_verify_request2() below.
 	 */
 	if (offer->media_count==0) {
 	    const pj_str_t reason = pj_str("Missing media in SDP");
-	    pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400, &reason, 
+	    pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400, &reason,
 				NULL, NULL, NULL);
 	    goto on_return;
@@ -1241,5 +1241,5 @@
 
 	    pjsip_get_response_addr(response->pool, rdata, &res_addr);
-	    pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, response, 
+	    pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, response,
 				      NULL, NULL);
 
@@ -1251,5 +1251,5 @@
 
 	goto on_return;
-    } 
+    }
 
     /* Get suitable Contact header */
@@ -1260,5 +1260,5 @@
 					      acc_id, rdata);
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror(THIS_FILE, "Unable to generate Contact header", 
+	    pjsua_perror(THIS_FILE, "Unable to generate Contact header",
 			 status);
 	    pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL,
@@ -1286,5 +1286,5 @@
     /* Set credentials */
     if (pjsua_var.acc[acc_id].cred_cnt) {
-	pjsip_auth_clt_set_credentials(&dlg->auth_sess, 
+	pjsip_auth_clt_set_credentials(&dlg->auth_sess,
 				       pjsua_var.acc[acc_id].cred_cnt,
 				       pjsua_var.acc[acc_id].cred);
@@ -1292,5 +1292,5 @@
 
     /* Set preference */
-    pjsip_auth_clt_set_prefs(&dlg->auth_sess, 
+    pjsip_auth_clt_set_prefs(&dlg->auth_sess,
 			     &pjsua_var.acc[acc_id].cfg.auth_pref);
 
@@ -1298,5 +1298,5 @@
      * did not require it.
      */
-    if (pjsua_var.acc[acc_id].cfg.use_timer == PJSUA_SIP_TIMER_INACTIVE && 
+    if (pjsua_var.acc[acc_id].cfg.use_timer == PJSUA_SIP_TIMER_INACTIVE &&
 	(options & PJSIP_INV_REQUIRE_TIMER) == 0)
     {
@@ -1323,5 +1323,5 @@
 	pjsip_warning_hdr *w;
 
-	w = pjsip_warning_hdr_create_from_status(dlg->pool, 
+	w = pjsip_warning_hdr_create_from_status(dlg->pool,
 						 pjsip_endpt_name(pjsua_var.endpt),
 						 status);
@@ -1361,6 +1361,6 @@
      */
     if (offer || replaced_dlg) {
-	status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS, 
-					  call->secure_level, 
+	status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS,
+					  call->secure_level,
 					  rdata->tp_info.pool,
 					  offer,
@@ -1377,5 +1377,5 @@
 		 */
 		pjsip_dlg_respond(dlg, rdata, sip_err_code, NULL, NULL, NULL);
-		pjsip_inv_terminate(call->inv, sip_err_code, PJ_FALSE); 
+		pjsip_inv_terminate(call->inv, sip_err_code, PJ_FALSE);
 		call->inv = NULL;
 		call->async_call.dlg = NULL;
@@ -1385,6 +1385,6 @@
 	    pjsua_perror(THIS_FILE, "Error initializing media channel", status);
 	    pjsip_dlg_respond(dlg, rdata, sip_err_code, NULL, NULL, NULL);
-	    pjsip_inv_terminate(call->inv, sip_err_code, PJ_FALSE); 
-	    call->inv = NULL; 
+	    pjsip_inv_terminate(call->inv, sip_err_code, PJ_FALSE);
+	    call->inv = NULL;
 	    call->async_call.dlg = NULL;
 	    goto on_return;
@@ -1393,6 +1393,6 @@
 
     /* Create answer */
-/*  
-    status = pjsua_media_channel_create_sdp(call->index, rdata->tp_info.pool, 
+/*
+    status = pjsua_media_channel_create_sdp(call->index, rdata->tp_info.pool,
 					    offer, &answer, &sip_err_code);
     if (status != PJ_SUCCESS) {
@@ -1405,5 +1405,5 @@
 
     /* Init Session Timers */
-    status = pjsip_timer_init_session(inv, 
+    status = pjsip_timer_init_session(inv,
 				    &pjsua_var.acc[acc_id].cfg.timer_setting);
     if (status != PJ_SUCCESS) {
@@ -1420,8 +1420,8 @@
 
     /* Update NAT type of remote endpoint, only when there is SDP in
-     * incoming INVITE! 
+     * incoming INVITE!
      */
     if (pjsua_var.ua_cfg.nat_type_in_sdp && inv->neg &&
-	pjmedia_sdp_neg_get_state(inv->neg) > PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER) 
+	pjmedia_sdp_neg_get_state(inv->neg) > PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER)
     {
 	const pjmedia_sdp_session *remote_sdp;
@@ -1489,5 +1489,5 @@
 	}
     } else {
-	/* Notify application if on_incoming_call() is overriden, 
+	/* Notify application if on_incoming_call() is overriden,
 	 * otherwise hangup the call with 480
 	 */
@@ -1495,5 +1495,5 @@
 	    pjsua_var.ua_cfg.cb.on_incoming_call(acc_id, call_id, rdata);
 	} else {
-	    pjsua_call_hangup(call_id, PJSIP_SC_TEMPORARILY_UNAVAILABLE, 
+	    pjsua_call_hangup(call_id, PJSIP_SC_TEMPORARILY_UNAVAILABLE,
 			      NULL, NULL);
 	}
@@ -1551,5 +1551,5 @@
                 break;
         }
-	
+
 	has_pjsua_lock = PJ_FALSE;
 
@@ -1596,5 +1596,5 @@
 	return PJ_ETIMEDOUT;
     }
-    
+
     *p_call = call;
     *p_dlg = dlg;
@@ -1701,5 +1701,5 @@
 		   sizeof(info->buf_.last_status_text));
     }
-    
+
     /* Audio & video count offered by remote */
     info->rem_offerer   = call->rem_offerer;
@@ -1727,5 +1727,5 @@
 	    pjmedia_vid_dev_index cap_dev = PJMEDIA_VID_INVALID_DEV;
 
-	    info->media[info->media_cnt].stream.vid.win_in = 
+	    info->media[info->media_cnt].stream.vid.win_in =
 						call_med->strm.v.rdr_win_id;
 
@@ -1763,5 +1763,5 @@
 	    pjmedia_vid_dev_index cap_dev = PJMEDIA_VID_INVALID_DEV;
 
-	    info->prov_media[info->prov_media_cnt].stream.vid.win_in = 
+	    info->prov_media[info->prov_media_cnt].stream.vid.win_in =
 						call_med->strm.v.rdr_win_id;
 
@@ -1874,5 +1874,5 @@
  * Get media transport info for the specified media index.
  */
-PJ_DEF(pj_status_t) 
+PJ_DEF(pj_status_t)
 pjsua_call_get_med_transport_info(pjsua_call_id call_id,
                                   unsigned med_idx,
@@ -1890,5 +1890,5 @@
 
     call = &pjsua_var.calls[call_id];
-    
+
     if (med_idx >= call->med_cnt) {
 	PJSUA_UNLOCK();
@@ -1900,5 +1900,5 @@
     pjmedia_transport_info_init(t);
     status = pjmedia_transport_get_info(call_med->tp, t);
-    
+
     PJSUA_UNLOCK();
     return status;
@@ -1932,5 +1932,5 @@
 
     status = pjsua_media_channel_create_sdp(call_id,
-                                            call->async_call.dlg->pool, 
+                                            call->async_call.dlg->pool,
 					    NULL, &sdp, &sip_err_code);
     if (status != PJ_SUCCESS) {
@@ -1984,5 +1984,5 @@
  * Send response to incoming INVITE request.
  */
-PJ_DEF(pj_status_t) pjsua_call_answer( pjsua_call_id call_id, 
+PJ_DEF(pj_status_t) pjsua_call_answer( pjsua_call_id call_id,
 				       unsigned code,
 				       const pj_str_t *reason,
@@ -2042,8 +2042,8 @@
      *   answer code 183 or 2xx is issued
      */
-    if (!call->med_ch_cb && 
+    if (!call->med_ch_cb &&
 	(call->opt_inited || (code==183 || code/100==2)) &&
 	(!call->inv->neg ||
-	 pjmedia_sdp_neg_get_state(call->inv->neg) == 
+	 pjmedia_sdp_neg_get_state(call->inv->neg) ==
 		PJMEDIA_SDP_NEG_STATE_NULL))
     {
@@ -2076,5 +2076,5 @@
     if (call->med_ch_cb) {
         struct call_answer *answer;
-        
+
         PJ_LOG(4,(THIS_FILE, "Pending answering call %d upon completion "
                              "of media transport", call_id));
@@ -2114,5 +2114,5 @@
     status = pjsip_inv_answer(call->inv, code, reason, NULL, &tdata);
     if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Error creating response", 
+	pjsua_perror(THIS_FILE, "Error creating response",
 		     status);
 	goto on_return;
@@ -2131,5 +2131,5 @@
     status = pjsip_inv_send_msg(call->inv, tdata);
     if (status != PJ_SUCCESS)
-	pjsua_perror(THIS_FILE, "Error sending response", 
+	pjsua_perror(THIS_FILE, "Error sending response",
 		     status);
 
@@ -2160,5 +2160,5 @@
 			     call_id));
     }
-    
+
     PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
 		     PJ_EINVAL);
@@ -2186,5 +2186,5 @@
 		       sizeof(call->last_text_buf_));
         }
-        
+
         goto on_return;
     }
@@ -2201,11 +2201,11 @@
     status = pjsip_inv_end_session(call->inv, code, reason, &tdata);
     if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, 
-		     "Failed to create end session message", 
+	pjsua_perror(THIS_FILE,
+		     "Failed to create end session message",
 		     status);
 	goto on_return;
     }
 
-    /* pjsip_inv_end_session may return PJ_SUCCESS with NULL 
+    /* pjsip_inv_end_session may return PJ_SUCCESS with NULL
      * as p_tdata when INVITE transaction has not been answered
      * with any provisional responses.
@@ -2220,6 +2220,6 @@
     status = pjsip_inv_send_msg(call->inv, tdata);
     if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, 
-		     "Failed to send end session message", 
+	pjsua_perror(THIS_FILE,
+		     "Failed to send end session message",
 		     status);
 	goto on_return;
@@ -2252,5 +2252,5 @@
 		     PJ_EINVAL);
 
-    status = acquire_call("pjsua_call_process_redirect()", call_id, 
+    status = acquire_call("pjsua_call_process_redirect()", call_id,
 			  &call, &dlg);
     if (status != PJ_SUCCESS)
@@ -2398,105 +2398,4 @@
 	goto on_return;
     }
-
-    status = apply_call_setting(call, opt, NULL);
-    if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Failed to apply call setting", status);
-	goto on_return;
-    }
-
-    /* Create SDP */
-    if (call->local_hold && (call->opt.flag & PJSUA_CALL_UNHOLD)==0) {
-	status = create_sdp_of_call_hold(call, &sdp);
-    } else {
-	status = pjsua_media_channel_create_sdp(call->index, 
-						call->inv->pool_prov,
-						NULL, &sdp, NULL);
-	call->local_hold = PJ_FALSE;
-    }
-    if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint", 
-		     status);
-	goto on_return;
-    }
-
-    if ((call->opt.flag & PJSUA_CALL_UPDATE_CONTACT) &&
-	    pjsua_acc_is_valid(call->acc_id))
-    {
-	new_contact = &pjsua_var.acc[call->acc_id].contact;
-    }
-
-    /* Create re-INVITE with new offer */
-    status = pjsip_inv_reinvite( call->inv, new_contact, sdp, &tdata);
-    if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Unable to create re-INVITE", status);
-	goto on_return;
-    }
-
-    /* Add additional headers etc */
-    pjsua_process_msg_data( tdata, msg_data);
-
-    /* Send the request */
-    status = pjsip_inv_send_msg( call->inv, tdata);
-    if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status);
-	goto on_return;
-    }
-
-on_return:
-    if (dlg) pjsip_dlg_dec_lock(dlg);
-    pj_log_pop_indent();
-    return status;
-}
-
-
-/*
- * Send UPDATE request.
- */
-PJ_DEF(pj_status_t) pjsua_call_update( pjsua_call_id call_id,
-				       unsigned options,
-				       const pjsua_msg_data *msg_data)
-{
-    pjsua_call *call;
-    pjsip_dialog *dlg = NULL;
-    pj_status_t status;
-
-    status = acquire_call("pjsua_call_update()", call_id, &call, &dlg);
-    if (status != PJ_SUCCESS)
-	goto on_return;
-
-    if (options != call->opt.flag)
-	call->opt.flag = options;
-
-    status = pjsua_call_update2(call_id, NULL, msg_data);
-
-on_return:
-    if (dlg) pjsip_dlg_dec_lock(dlg);
-    return status;
-}
-
-
-/*
- * Send UPDATE request.
- */
-PJ_DEF(pj_status_t) pjsua_call_update2(pjsua_call_id call_id,
-				       const pjsua_call_setting *opt,
-				       const pjsua_msg_data *msg_data)
-{
-    pjmedia_sdp_session *sdp;
-    pj_str_t *new_contact = NULL;
-    pjsip_tx_data *tdata;
-    pjsua_call *call;
-    pjsip_dialog *dlg = NULL;
-    pj_status_t status;
-
-    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
-		     PJ_EINVAL);
-
-    PJ_LOG(4,(THIS_FILE, "Sending UPDATE on call %d", call_id));
-    pj_log_push_indent();
-
-    status = acquire_call("pjsua_call_update2()", call_id, &call, &dlg);
-    if (status != PJ_SUCCESS)
-	goto on_return;
 
     status = apply_call_setting(call, opt, NULL);
@@ -2515,5 +2414,4 @@
 	call->local_hold = PJ_FALSE;
     }
-
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint",
@@ -2528,8 +2426,8 @@
     }
 
-    /* Create UPDATE with new offer */
-    status = pjsip_inv_update(call->inv, new_contact, sdp, &tdata);
-    if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Unable to create UPDATE request", status);
+    /* Create re-INVITE with new offer */
+    status = pjsip_inv_reinvite( call->inv, new_contact, sdp, &tdata);
+    if (status != PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "Unable to create re-INVITE", status);
 	goto on_return;
     }
@@ -2541,5 +2439,5 @@
     status = pjsip_inv_send_msg( call->inv, tdata);
     if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Unable to send UPDATE request", status);
+	pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status);
 	goto on_return;
     }
@@ -2553,7 +2451,109 @@
 
 /*
+ * Send UPDATE request.
+ */
+PJ_DEF(pj_status_t) pjsua_call_update( pjsua_call_id call_id,
+				       unsigned options,
+				       const pjsua_msg_data *msg_data)
+{
+    pjsua_call *call;
+    pjsip_dialog *dlg = NULL;
+    pj_status_t status;
+
+    status = acquire_call("pjsua_call_update()", call_id, &call, &dlg);
+    if (status != PJ_SUCCESS)
+	goto on_return;
+
+    if (options != call->opt.flag)
+	call->opt.flag = options;
+
+    status = pjsua_call_update2(call_id, NULL, msg_data);
+
+on_return:
+    if (dlg) pjsip_dlg_dec_lock(dlg);
+    return status;
+}
+
+
+/*
+ * Send UPDATE request.
+ */
+PJ_DEF(pj_status_t) pjsua_call_update2(pjsua_call_id call_id,
+				       const pjsua_call_setting *opt,
+				       const pjsua_msg_data *msg_data)
+{
+    pjmedia_sdp_session *sdp;
+    pj_str_t *new_contact = NULL;
+    pjsip_tx_data *tdata;
+    pjsua_call *call;
+    pjsip_dialog *dlg = NULL;
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
+		     PJ_EINVAL);
+
+    PJ_LOG(4,(THIS_FILE, "Sending UPDATE on call %d", call_id));
+    pj_log_push_indent();
+
+    status = acquire_call("pjsua_call_update2()", call_id, &call, &dlg);
+    if (status != PJ_SUCCESS)
+	goto on_return;
+
+    status = apply_call_setting(call, opt, NULL);
+    if (status != PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "Failed to apply call setting", status);
+	goto on_return;
+    }
+
+    /* Create SDP */
+    if (call->local_hold && (call->opt.flag & PJSUA_CALL_UNHOLD)==0) {
+	status = create_sdp_of_call_hold(call, &sdp);
+    } else {
+	status = pjsua_media_channel_create_sdp(call->index,
+						call->inv->pool_prov,
+						NULL, &sdp, NULL);
+	call->local_hold = PJ_FALSE;
+    }
+
+    if (status != PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint",
+		     status);
+	goto on_return;
+    }
+
+    if ((call->opt.flag & PJSUA_CALL_UPDATE_CONTACT) &&
+	    pjsua_acc_is_valid(call->acc_id))
+    {
+	new_contact = &pjsua_var.acc[call->acc_id].contact;
+    }
+
+    /* Create UPDATE with new offer */
+    status = pjsip_inv_update(call->inv, new_contact, sdp, &tdata);
+    if (status != PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "Unable to create UPDATE request", status);
+	goto on_return;
+    }
+
+    /* Add additional headers etc */
+    pjsua_process_msg_data( tdata, msg_data);
+
+    /* Send the request */
+    status = pjsip_inv_send_msg( call->inv, tdata);
+    if (status != PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "Unable to send UPDATE request", status);
+	goto on_return;
+    }
+
+on_return:
+    if (dlg) pjsip_dlg_dec_lock(dlg);
+    pj_log_pop_indent();
+    return status;
+}
+
+
+/*
  * Initiate call transfer to the specified address.
  */
-PJ_DEF(pj_status_t) pjsua_call_xfer( pjsua_call_id call_id, 
+PJ_DEF(pj_status_t) pjsua_call_xfer( pjsua_call_id call_id,
 				     const pj_str_t *dest,
 				     const pjsua_msg_data *msg_data)
@@ -2571,5 +2571,5 @@
     PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls &&
                      dest, PJ_EINVAL);
-    
+
     PJ_LOG(4,(THIS_FILE, "Transferring call %d to %.*s", call_id,
 			 (int)dest->slen, dest->ptr));
@@ -2579,5 +2579,5 @@
     if (status != PJ_SUCCESS)
 	goto on_return;
-   
+
     /* Create xfer client subscription. */
     pj_bzero(&xfer_cb, sizeof(xfer_cb));
@@ -2618,5 +2618,5 @@
     }
 
-    /* For simplicity (that's what this program is intended to be!), 
+    /* For simplicity (that's what this program is intended to be!),
      * leave the original invite session as it is. More advanced application
      * may want to hold the INVITE, or terminate the invite, or whatever.
@@ -2633,5 +2633,5 @@
  * Initiate attended call transfer to the specified address.
  */
-PJ_DEF(pj_status_t) pjsua_call_xfer_replaces( pjsua_call_id call_id, 
+PJ_DEF(pj_status_t) pjsua_call_xfer_replaces( pjsua_call_id call_id,
 					      pjsua_call_id dest_call_id,
 					      unsigned options,
@@ -2645,17 +2645,17 @@
     pjsip_uri *uri;
     pj_status_t status;
-    
+
 
     PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,
 		     PJ_EINVAL);
-    PJ_ASSERT_RETURN(dest_call_id>=0 && 
+    PJ_ASSERT_RETURN(dest_call_id>=0 &&
 		      dest_call_id<(int)pjsua_var.ua_cfg.max_calls,
 		     PJ_EINVAL);
-    
+
     PJ_LOG(4,(THIS_FILE, "Transferring call %d replacing with call %d",
 			 call_id, dest_call_id));
     pj_log_push_indent();
 
-    status = acquire_call("pjsua_call_xfer_replaces()", dest_call_id, 
+    status = acquire_call("pjsua_call_xfer_replaces()", dest_call_id,
 			  &dest_call, &dest_dlg);
     if (status != PJ_SUCCESS) {
@@ -2663,6 +2663,6 @@
 	return status;
     }
-        
-    /* 
+
+    /*
      * Create REFER destination URI with Replaces field.
      */
@@ -2672,5 +2672,5 @@
 		      dest_dlg->call_id->id.slen +
 		      dest_dlg->remote.info->tag.slen +
-		      dest_dlg->local.info->tag.slen + 32 
+		      dest_dlg->local.info->tag.slen + 32
 		      < (long)sizeof(str_dest_buf),
 		      { status=PJSIP_EURITOOLONG; goto on_error; });
@@ -2681,5 +2681,5 @@
 
     uri = (pjsip_uri*) pjsip_uri_get_uri(dest_dlg->remote.info->uri);
-    len = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, uri, 
+    len = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, uri,
 		          str_dest_buf+1, sizeof(str_dest_buf)-1);
     if (len < 0) {
@@ -2692,5 +2692,5 @@
 
     /* Build the URI */
-    len = pj_ansi_snprintf(str_dest_buf + str_dest.slen, 
+    len = pj_ansi_snprintf(str_dest_buf + str_dest.slen,
 			   sizeof(str_dest_buf) - str_dest.slen,
 			   "?%s"
@@ -2709,10 +2709,10 @@
     PJ_ASSERT_ON_FAIL(len > 0 && len <= (int)sizeof(str_dest_buf)-str_dest.slen,
 		      { status=PJSIP_EURITOOLONG; goto on_error; });
-    
+
     str_dest.ptr = str_dest_buf;
     str_dest.slen += len;
 
     pjsip_dlg_dec_lock(dest_dlg);
-    
+
     status = pjsua_call_xfer(call_id, &str_dest, msg_data);
 
@@ -2730,5 +2730,5 @@
  * Send instant messaging inside INVITE session.
  */
-PJ_DEF(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id, 
+PJ_DEF(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
 					const pj_str_t *mime_type,
 					const pj_str_t *content,
@@ -2754,5 +2754,5 @@
     if (status != PJ_SUCCESS)
 	goto on_return;
-    
+
     /* Set default media type if none is specified */
     if (mime_type == NULL) {
@@ -2769,5 +2769,5 @@
 
     /* Add accept header. */
-    pjsip_msg_add_hdr( tdata->msg, 
+    pjsip_msg_add_hdr( tdata->msg,
 		       (pjsip_hdr*)pjsua_im_create_accept(tdata->pool));
 
@@ -2797,5 +2797,5 @@
 
     /* Send the request. */
-    status = pjsip_dlg_send_request( call->inv->dlg, tdata, 
+    status = pjsip_dlg_send_request( call->inv->dlg, tdata,
 				     pjsua_var.mod.id, im_data);
     if (status != PJ_SUCCESS) {
@@ -2814,5 +2814,5 @@
  * Send IM typing indication inside INVITE session.
  */
-PJ_DEF(pj_status_t) pjsua_call_send_typing_ind( pjsua_call_id call_id, 
+PJ_DEF(pj_status_t) pjsua_call_send_typing_ind( pjsua_call_id call_id,
 						pj_bool_t is_typing,
 						const pjsua_msg_data*msg_data)
@@ -3099,5 +3099,5 @@
 	pjmedia_transport_info tpinfo;
 	pjmedia_ice_transport_info *ice_info;
-	
+
 	if (call_med->tp_st == PJSUA_MED_TP_NULL ||
 	    call_med->tp_st == PJSUA_MED_TP_DISABLED ||
@@ -3106,5 +3106,5 @@
 	    continue;
 	}
-	
+
 	pjmedia_transport_info_init(&tpinfo);
 	pjmedia_transport_get_info(call_med->tp, &tpinfo);
@@ -3122,5 +3122,5 @@
 	    break;
 	}
-	
+
 	/* Check if ICE needs to send reinvite */
 	if (!ice_need_reinv &&
@@ -3137,8 +3137,8 @@
 	}
     }
-    
+
     if (ice_complete && need_reinv)
 	*need_reinv = ice_need_reinv;
-    
+
     return ice_complete;
 }
@@ -3177,5 +3177,5 @@
      * remote does not support UPDATE method.
      */
-    if (inv->state == PJSIP_INV_STATE_EARLY && 
+    if (inv->state == PJSIP_INV_STATE_EARLY &&
 	pjsip_dlg_remote_has_cap(inv->dlg, PJSIP_H_ALLOW, NULL, &ST_UPDATE)!=
 	PJSIP_DIALOG_CAP_SUPPORTED)
@@ -3197,5 +3197,5 @@
 	return PJ_SUCCESS;
 
-    
+
     /* Okay! So we need to send re-INVITE/UPDATE */
 
@@ -3218,5 +3218,5 @@
 		  ));
     }
-    
+
     /* Generate SDP re-offer */
     status = pjsua_media_channel_create_sdp(call->index, pool, NULL,
@@ -3235,10 +3235,10 @@
     if (need_lock_codec) {
 	const pjmedia_sdp_session *ref_sdp;
-	
+
 	/* Get local active SDP as reference */
 	status = pjmedia_sdp_neg_get_active_local(call->inv->neg, &ref_sdp);
 	if (status != PJ_SUCCESS)
 	    return status;
-	
+
 	/* Verify media count. Note that remote may add/remove media line
 	 * in the answer. When answer has less media, it must have been
@@ -3262,5 +3262,5 @@
 	    pjmedia_sdp_media *m = new_offer->media[i];
 	    pjsua_call_media *call_med = &call->media[i];
-    
+
 	    /* Verify if media is deactivated */
 	    if (call_med->state == PJSUA_CALL_MEDIA_NONE ||
@@ -3270,10 +3270,10 @@
 		continue;
 	    }
-    
+
 	    /* Reset formats */
 	    m->desc.fmt_count = 0;
 	    pjmedia_sdp_attr_remove_all(&m->attr_count, m->attr, "rtpmap");
 	    pjmedia_sdp_attr_remove_all(&m->attr_count, m->attr, "fmtp");
-	    
+
 	    /* Copy only the first format + any non-AV formats from
 	     * the active local SDP.
@@ -3284,5 +3284,5 @@
 		if (is_non_av_fmt(ref_m, fmt) || (++codec_cnt == 1)) {
 		    pjmedia_sdp_attr *a;
-		    
+
 		    m->desc.fmt[m->desc.fmt_count++] = *fmt;
 		    a = pjmedia_sdp_attr_find2(ref_m->attr_count, ref_m->attr,
@@ -3300,5 +3300,5 @@
     {
 	const pjmedia_sdp_session *cur_sdp;
-	
+
 	/* Get local active SDP */
 	status = pjmedia_sdp_neg_get_active_local(call->inv->neg, &cur_sdp);
@@ -3356,5 +3356,5 @@
     }
 
-    
+
     if (rem_can_update) {
 	status = pjsip_inv_update(inv, NULL, new_offer, &tdata);
@@ -3388,5 +3388,5 @@
     if (need_lock_codec)
 	++call->lock_codec.retry_cnt;
-    
+
     return PJ_SUCCESS;
 }
@@ -3397,5 +3397,5 @@
  * session state has changed.
  */
-static void pjsua_call_on_state_changed(pjsip_inv_session *inv, 
+static void pjsua_call_on_state_changed(pjsip_inv_session *inv,
 					pjsip_event *e)
 {
@@ -3418,7 +3418,7 @@
 	    if (call->res_time.sec == 0)
 		pj_gettimeofday(&call->res_time);
-	    call->last_code = (pjsip_status_code) 
+	    call->last_code = (pjsip_status_code)
 	    		      e->body.tsx_state.tsx->status_code;
-	    pj_strncpy(&call->last_text, 
+	    pj_strncpy(&call->last_text,
 		       &e->body.tsx_state.tsx->status_text,
 		       sizeof(call->last_text_buf_));
@@ -3439,10 +3439,10 @@
 	    if (call->res_time.sec == 0)
 		pj_gettimeofday(&call->res_time);
-	    if (e->type == PJSIP_EVENT_TSX_STATE && 
-		e->body.tsx_state.tsx->status_code > call->last_code) 
+	    if (e->type == PJSIP_EVENT_TSX_STATE &&
+		e->body.tsx_state.tsx->status_code > call->last_code)
 	    {
-		call->last_code = (pjsip_status_code) 
+		call->last_code = (pjsip_status_code)
 				  e->body.tsx_state.tsx->status_code;
-		pj_strncpy(&call->last_text, 
+		pj_strncpy(&call->last_text,
 			   &e->body.tsx_state.tsx->status_text,
 			   sizeof(call->last_text_buf_));
@@ -3461,7 +3461,7 @@
 	    break;
 	default:
-	    call->last_code = (pjsip_status_code) 
+	    call->last_code = (pjsip_status_code)
 	    		      e->body.tsx_state.tsx->status_code;
-	    pj_strncpy(&call->last_text, 
+	    pj_strncpy(&call->last_text,
 		       &e->body.tsx_state.tsx->status_text,
 		       sizeof(call->last_text_buf_));
@@ -3475,5 +3475,5 @@
 	int st_code = -1;
 	pjsip_evsub_state ev_state = PJSIP_EVSUB_STATE_ACTIVE;
-	
+
 
 	switch (call->inv->state) {
@@ -3554,5 +3554,5 @@
 
 	PJSUA_LOCK();
-	
+
 	pjsua_media_channel_deinit(call->index);
 
@@ -3577,5 +3577,5 @@
  * has forked.
  */
-static void pjsua_call_on_forked( pjsip_inv_session *inv, 
+static void pjsua_call_on_forked( pjsip_inv_session *inv,
 				  pjsip_event *e)
 {
@@ -3592,8 +3592,8 @@
 pjsip_dialog* on_dlg_forked(pjsip_dialog *dlg, pjsip_rx_data *res)
 {
-    if (dlg->uac_has_2xx && 
+    if (dlg->uac_has_2xx &&
 	res->msg_info.cseq->method.id == PJSIP_INVITE_METHOD &&
 	pjsip_rdata_get_tsx(res) == NULL &&
-	res->msg_info.msg->line.status.code/100 == 2) 
+	res->msg_info.msg->line.status.code/100 == 2)
     {
 	pjsip_dialog *forked_dlg;
@@ -3631,12 +3631,9 @@
  * Disconnect call upon error.
  */
-static void call_disconnect( pjsip_inv_session *inv, 
+static void call_disconnect( pjsip_inv_session *inv,
 			     int code )
 {
-    pjsua_call *call;
     pjsip_tx_data *tdata;
     pj_status_t status;
-
-    call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id];
 
     status = pjsip_inv_end_session(inv, code, NULL, &tdata);
@@ -3644,8 +3641,12 @@
 	return;
 
+#if DISABLED_FOR_TICKET_1185
+    pjsua_call *call;
+
     /* Add SDP in 488 status */
-#if DISABLED_FOR_TICKET_1185
+    call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id];
+
     if (call && call->tp && tdata->msg->type==PJSIP_RESPONSE_MSG &&
-	code==PJSIP_SC_NOT_ACCEPTABLE_HERE) 
+	code==PJSIP_SC_NOT_ACCEPTABLE_HERE)
     {
 	pjmedia_sdp_session *local_sdp;
@@ -3654,5 +3655,5 @@
 	pjmedia_transport_info_init(&ti);
 	pjmedia_transport_get_info(call->med_tp, &ti);
-	status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, tdata->pool, 
+	status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, tdata->pool,
 					  1, &ti.sock_info, &local_sdp);
 	if (status == PJ_SUCCESS) {
@@ -3699,8 +3700,8 @@
 
 	/* Disconnect call if we're not in the middle of initializing an
-	 * UAS dialog and if this is not a re-INVITE 
+	 * UAS dialog and if this is not a re-INVITE
 	 */
 	if (inv->state != PJSIP_INV_STATE_NULL &&
-	    inv->state != PJSIP_INV_STATE_CONFIRMED) 
+	    inv->state != PJSIP_INV_STATE_CONFIRMED)
 	{
 	    call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE);
@@ -3714,6 +3715,6 @@
     status = pjmedia_sdp_neg_get_active_local(call->inv->neg, &local_sdp);
     if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, 
-		     "Unable to retrieve currently active local SDP", 
+	pjsua_perror(THIS_FILE,
+		     "Unable to retrieve currently active local SDP",
 		     status);
 	//call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE);
@@ -3723,6 +3724,6 @@
     status = pjmedia_sdp_neg_get_active_remote(call->inv->neg, &remote_sdp);
     if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, 
-		     "Unable to retrieve currently active remote SDP", 
+	pjsua_perror(THIS_FILE,
+		     "Unable to retrieve currently active remote SDP",
 		     status);
 	//call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE);
@@ -3738,5 +3739,5 @@
     status = pjsua_media_channel_update(call->index, local_sdp, remote_sdp);
     if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Unable to create media session", 
+	pjsua_perror(THIS_FILE, "Unable to create media session",
 		     status);
 	call_disconnect(inv, PJSIP_SC_NOT_ACCEPTABLE_HERE);
@@ -3768,10 +3769,10 @@
     unsigned mi;
 
-    /* Call-hold is done by set the media direction to 'sendonly' 
-     * (PJMEDIA_DIR_ENCODING), except when current media direction is 
+    /* Call-hold is done by set the media direction to 'sendonly'
+     * (PJMEDIA_DIR_ENCODING), except when current media direction is
      * 'inactive' (PJMEDIA_DIR_NONE).
      * (See RFC 3264 Section 8.4 and RFC 4317 Section 3.1)
      */
-    /* http://trac.pjsip.org/repos/ticket/880 
+    /* http://trac.pjsip.org/repos/ticket/880
        if (call->dir != PJMEDIA_DIR_ENCODING) {
      */
@@ -3883,5 +3884,5 @@
 	pjsip_status_code code = PJSIP_SC_OK;
 	pjsua_call_setting opt = call->opt;
-	
+
 	(*pjsua_var.ua_cfg.cb.on_call_rx_offer)(call->index, offer, NULL,
 						&code, &opt);
@@ -3895,5 +3896,5 @@
 	call->opt = opt;
     }
-    
+
     /* Re-init media for the new remote offer before creating SDP */
     status = apply_call_setting(call, &call->opt, offer);
@@ -3901,6 +3902,6 @@
 	goto on_return;
 
-    status = pjsua_media_channel_create_sdp(call->index, 
-					    call->inv->pool_prov, 
+    status = pjsua_media_channel_create_sdp(call->index,
+					    call->inv->pool_prov,
 					    offer, &answer, NULL);
     if (status != PJ_SUCCESS) {
@@ -3972,5 +3973,5 @@
     /* See if we've put call on hold. */
     if (call->local_hold) {
-	PJ_LOG(4,(THIS_FILE, 
+	PJ_LOG(4,(THIS_FILE,
 		  "Call %d: call is on-hold locally, creating call-hold SDP ",
 		  call->index));
@@ -3980,6 +3981,6 @@
 		  call->index));
 
-	status = pjsua_media_channel_create_sdp(call->index, 
-						call->inv->pool_prov, 
+	status = pjsua_media_channel_create_sdp(call->index,
+						call->inv->pool_prov,
 					        NULL, offer, NULL);
     }
@@ -4001,5 +4002,5 @@
 static void xfer_client_on_evsub_state( pjsip_evsub *sub, pjsip_event *event)
 {
-    
+
     PJ_UNUSED_ARG(event);
 
@@ -4007,5 +4008,5 @@
 
     /*
-     * When subscription is accepted (got 200/OK to REFER), check if 
+     * When subscription is accepted (got 200/OK to REFER), check if
      * subscription suppressed.
      */
@@ -4020,5 +4021,5 @@
 
 	/* Must be receipt of response message */
-	pj_assert(event->type == PJSIP_EVENT_TSX_STATE && 
+	pj_assert(event->type == PJSIP_EVENT_TSX_STATE &&
 		  event->body.tsx_state.type == PJSIP_EVENT_RX_MSG);
 	rdata = event->body.tsx_state.src.rdata;
@@ -4026,5 +4027,5 @@
 	/* Find Refer-Sub header */
 	refer_sub = (pjsip_generic_string_hdr*)
-		    pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, 
+		    pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,
 					       &REFER_SUB, NULL);
 
@@ -4037,5 +4038,5 @@
 		const pj_str_t ACCEPTED = { "Accepted", 8 };
 		pj_bool_t cont = PJ_FALSE;
-		(*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index, 
+		(*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index,
 							       200,
 							       &ACCEPTED,
@@ -4052,5 +4053,5 @@
 
 	} else {
-	    /* Notify application about call transfer progress. 
+	    /* Notify application about call transfer progress.
 	     * Initially notify with 100/Accepted status.
 	     */
@@ -4058,5 +4059,5 @@
 		const pj_str_t ACCEPTED = { "Accepted", 8 };
 		pj_bool_t cont = PJ_FALSE;
-		(*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index, 
+		(*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index,
 							       100,
 							       &ACCEPTED,
@@ -4070,5 +4071,5 @@
      */
     else if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_ACTIVE ||
-	     pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED) 
+	     pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED)
     {
 	pjsua_call *call;
@@ -4082,5 +4083,5 @@
 	call = (pjsua_call*) pjsip_evsub_get_mod_data(sub, pjsua_var.mod.id);
 
-	/* When subscription is terminated, clear the xfer_sub member of 
+	/* When subscription is terminated, clear the xfer_sub member of
 	 * the inv_data.
 	 */
@@ -4108,5 +4109,5 @@
 	    body = msg->body;
 	    if (!body) {
-		PJ_LOG(2,(THIS_FILE, 
+		PJ_LOG(2,(THIS_FILE,
 			  "Warning: received NOTIFY without message body"));
 		goto on_return;
@@ -4117,5 +4118,5 @@
 		pj_stricmp2(&body->content_type.subtype, "sipfrag") != 0)
 	    {
-		PJ_LOG(2,(THIS_FILE, 
+		PJ_LOG(2,(THIS_FILE,
 			  "Warning: received NOTIFY with non message/sipfrag "
 			  "content"));
@@ -4124,8 +4125,8 @@
 
 	    /* Try to parse the content */
-	    status = pjsip_parse_status_line((char*)body->data, body->len, 
+	    status = pjsip_parse_status_line((char*)body->data, body->len,
 					     &status_line);
 	    if (status != PJ_SUCCESS) {
-		PJ_LOG(2,(THIS_FILE, 
+		PJ_LOG(2,(THIS_FILE,
 			  "Warning: received NOTIFY with invalid "
 			  "message/sipfrag content"));
@@ -4141,5 +4142,5 @@
 	is_last = (pjsip_evsub_get_state(sub)==PJSIP_EVSUB_STATE_TERMINATED);
 	cont = !is_last;
-	(*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index, 
+	(*pjsua_var.ua_cfg.cb.on_call_transfer_status)(call->index,
 						       status_line.code,
 						       &status_line.reason,
@@ -4156,5 +4157,5 @@
 	    pjsip_tx_data *tdata;
 
-	    status = pjsip_evsub_initiate(sub, &pjsip_subscribe_method, 
+	    status = pjsip_evsub_initiate(sub, &pjsip_subscribe_method,
 					  0, &tdata);
 	    if (status == PJ_SUCCESS)
@@ -4179,5 +4180,5 @@
 
     /*
-     * When subscription is terminated, clear the xfer_sub member of 
+     * When subscription is terminated, clear the xfer_sub member of
      * the inv_data.
      */
@@ -4254,5 +4255,5 @@
      */
     ref_by_hdr = (pjsip_hdr*)
-		 pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_ref_by, 
+		 pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_ref_by,
 					    NULL);
 
@@ -4261,5 +4262,5 @@
     if (pjsua_var.ua_cfg.cb.on_call_transfer_request) {
 	(*pjsua_var.ua_cfg.cb.on_call_transfer_request)(existing_call->index,
-							&refer_to->hvalue, 
+							&refer_to->hvalue,
 							&code);
     }
@@ -4268,5 +4269,5 @@
     if (pjsua_var.ua_cfg.cb.on_call_transfer_request2) {
 	(*pjsua_var.ua_cfg.cb.on_call_transfer_request2)(existing_call->index,
-							 &refer_to->hvalue, 
+							 &refer_to->hvalue,
 							 &code,
 							 &call_opt);
@@ -4284,5 +4285,5 @@
 	      (int)inv->dlg->remote.info_str.slen,
 	      inv->dlg->remote.info_str.ptr,
-	      (int)refer_to->hvalue.slen, 
+	      (int)refer_to->hvalue.slen,
 	      refer_to->hvalue.ptr));
 
@@ -4295,5 +4296,5 @@
 	pjsip_hdr *hdr;
 
-	status = pjsip_dlg_create_response(inv->dlg, rdata, code, NULL, 
+	status = pjsip_dlg_create_response(inv->dlg, rdata, code, NULL,
 					   &tdata);
 	if (status != PJ_SUCCESS) {
@@ -4304,5 +4305,5 @@
 
 	/* Add Refer-Sub header */
-	hdr = (pjsip_hdr*) 
+	hdr = (pjsip_hdr*)
 	       pjsip_generic_string_hdr_create(tdata->pool, &str_refer_sub,
 					      &str_false);
@@ -4348,6 +4349,6 @@
 	    pjsip_hdr *hdr;
 
-	    hdr = (pjsip_hdr*) 
-		   pjsip_generic_string_hdr_create(inv->dlg->pool, 
+	    hdr = (pjsip_hdr*)
+		   pjsip_generic_string_hdr_create(inv->dlg->pool,
 						   &str_refer_sub,
 						   &str_true);
@@ -4363,5 +4364,5 @@
 				    100, NULL, &tdata);
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER", 
+	    pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER",
 			 status);
 	    goto on_return;
@@ -4379,5 +4380,5 @@
      * We need to get a null terminated string from a pj_str_t.
      * So grab the pointer from the hvalue and NULL terminate it, knowing
-     * that the NULL position will be occupied by a newline. 
+     * that the NULL position will be occupied by a newline.
      */
     uri = refer_to->hvalue.ptr;
@@ -4399,5 +4400,5 @@
     tmp = pj_str(uri);
     status = pjsua_call_make_call(existing_call->acc_id, &tmp, &call_opt,
-				  existing_call->user_data, &msg_data, 
+				  existing_call->user_data, &msg_data,
 				  &new_call);
     if (status != PJ_SUCCESS) {
@@ -4408,5 +4409,5 @@
 				       500, NULL, &tdata);
 	    if (status != PJ_SUCCESS) {
-		pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER", 
+		pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER",
 			      status);
 		goto on_return;
@@ -4414,5 +4415,5 @@
 	    status = pjsip_xfer_send_request(sub, tdata);
 	    if (status != PJ_SUCCESS) {
-		pjsua_perror(THIS_FILE, "Unable to send NOTIFY to REFER", 
+		pjsua_perror(THIS_FILE, "Unable to send NOTIFY to REFER",
 			      status);
 		goto on_return;
@@ -4430,5 +4431,5 @@
 
 	/* Put the invite_data in the subscription. */
-	pjsip_evsub_set_mod_data(sub, pjsua_var.mod.id, 
+	pjsip_evsub_set_mod_data(sub, pjsua_var.mod.id,
 				 &pjsua_var.calls[new_call]);
     }
@@ -4512,5 +4513,5 @@
 	    pj_list_push_back(&hdr_list, accept_hdr);
 
-	    pjsip_dlg_respond( inv->dlg, rdata, PJSIP_SC_NOT_ACCEPTABLE_HERE, 
+	    pjsip_dlg_respond( inv->dlg, rdata, PJSIP_SC_NOT_ACCEPTABLE_HERE,
 			       NULL, &hdr_list, NULL );
 	    goto on_return;
@@ -4518,5 +4519,5 @@
 
 	/* Respond with 200 first, so that remote doesn't retransmit in case
-	 * the UI takes too long to process the message. 
+	 * the UI takes too long to process the message.
 	 */
 	pjsip_dlg_respond( inv->dlg, rdata, 200, NULL, NULL, NULL);
@@ -4626,5 +4627,5 @@
 
     if (pjsua_var.ua_cfg.cb.on_call_redirected) {
-	op = (*pjsua_var.ua_cfg.cb.on_call_redirected)(call->index, 
+	op = (*pjsua_var.ua_cfg.cb.on_call_redirected)(call->index,
 							 target, e);
     } else {
Index: pjproject/trunk/pjsip/src/test/tsx_uas_test.c
===================================================================
--- pjproject/trunk/pjsip/src/test/tsx_uas_test.c	(revision 4727)
+++ pjproject/trunk/pjsip/src/test/tsx_uas_test.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -31,5 +31,5 @@
  **
  ** This file performs various tests for UAC transactions. Each test will have
- ** a different Via branch param so that message receiver module and 
+ ** a different Via branch param so that message receiver module and
  ** transaction user module can identify which test is being carried out.
  **
@@ -48,5 +48,5 @@
  **
  ** TEST4_BRANCH_ID
- **	Transaction retransmits last response (if any) without notifying 
+ **	Transaction retransmits last response (if any) without notifying
  **	transaction user upon receiving request  retransmissions on TRYING
  **	state
@@ -67,5 +67,5 @@
  ** TEST9_BRANCH_ID
  **	INVITE transaction MUST cease retransmission of final response when
- **	ACK is received. (Note: PJSIP also retransmit 2xx final response 
+ **	ACK is received. (Note: PJSIP also retransmit 2xx final response
  **	until it's terminated by user).
  **     Transaction also MUST terminate in T4 seconds.
@@ -117,5 +117,5 @@
 #define TEST4_REQUEST_COUNT	2
 #define TEST5_PROVISIONAL_CODE	100
-#define TEST5_STATUS_CODE	200	
+#define TEST5_STATUS_CODE	200
 #define TEST5_REQUEST_COUNT	2
 #define TEST5_RESPONSE_COUNT	2
@@ -147,5 +147,5 @@
 
 /* UAC transaction user module. */
-static pjsip_module tsx_user = 
+static pjsip_module tsx_user =
 {
     NULL, NULL,				/* prev and next	*/
@@ -165,5 +165,5 @@
 
 /* Module to send request. */
-static pjsip_module msg_sender = 
+static pjsip_module msg_sender =
 {
     NULL, NULL,				/* prev and next	*/
@@ -242,5 +242,5 @@
     pjsip_tx_data *tdata;
 
-    status = pjsip_endpt_create_response( endpt, rdata, status_code, NULL, 
+    status = pjsip_endpt_create_response( endpt, rdata, status_code, NULL,
 					  &tdata);
     if (status != PJ_SUCCESS) {
@@ -272,5 +272,5 @@
     pj_time_val delay;
 
-    status = pjsip_endpt_create_response( endpt, rdata, status_code, NULL, 
+    status = pjsip_endpt_create_response( endpt, rdata, status_code, NULL,
 					  &tdata);
     if (status != PJ_SUCCESS) {
@@ -354,5 +354,5 @@
 {
     if (pj_stricmp2(&tsx->branch, TEST1_BRANCH_ID)==0 ||
-	pj_stricmp2(&tsx->branch, TEST2_BRANCH_ID)==0) 
+	pj_stricmp2(&tsx->branch, TEST2_BRANCH_ID)==0)
     {
 	/*
@@ -375,5 +375,5 @@
 		test_complete = -100;
 	    }
-	    
+
 	    /* Previous state must be completed. */
 	    if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
@@ -406,5 +406,5 @@
 		test_complete = -110;
 	    }
-	    
+
 	    /* Previous state must be completed. */
 	    if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
@@ -466,5 +466,5 @@
 	    /* Check that status code is status_code. */
 	    if (tsx->status_code != TEST4_STATUS_CODE) {
-		PJ_LOG(3,(THIS_FILE, 
+		PJ_LOG(3,(THIS_FILE,
 			  "    error: incorrect status code %d "
 			  "(expecting %d)", tsx->status_code,
@@ -472,5 +472,5 @@
 		test_complete = -120;
 	    }
-	    
+
 	    /* Previous state. */
 	    if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) {
@@ -479,5 +479,5 @@
 	    }
 
-	} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED) 
+	} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED)
 	{
 	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state %s (122)",
@@ -503,5 +503,5 @@
 		test_complete = -130;
 	    }
-	    
+
 	    /* Previous state. */
 	    if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_PROCEEDING) {
@@ -538,9 +538,9 @@
 	    if (tsx->status_code != TEST6_STATUS_CODE) {
 		PJ_LOG(3,(THIS_FILE, "    error: incorrect status code %d "
-			  "(expecting %d)", tsx->status_code, 
+			  "(expecting %d)", tsx->status_code,
 			  TEST6_STATUS_CODE));
 		test_complete = -140;
 	    }
-	    
+
 	    /* Previous state. */
 	    if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
@@ -551,5 +551,5 @@
 	} else if (tsx->state != PJSIP_TSX_STATE_PROCEEDING &&
 		   tsx->state != PJSIP_TSX_STATE_COMPLETED &&
-		   tsx->state != PJSIP_TSX_STATE_DESTROYED) 
+		   tsx->state != PJSIP_TSX_STATE_DESTROYED)
 	{
 	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state %s (142)",
@@ -562,5 +562,5 @@
     } else
     if (pj_stricmp2(&tsx->branch, TEST7_BRANCH_ID)==0 ||
-	pj_stricmp2(&tsx->branch, TEST8_BRANCH_ID)==0) 
+	pj_stricmp2(&tsx->branch, TEST8_BRANCH_ID)==0)
     {
 	/*
@@ -588,5 +588,5 @@
 		test_complete = -150;
 	    }
-	    
+
 	    /* Previous state. */
 	    if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
@@ -606,5 +606,5 @@
 
 		if (tsx->retransmit_count != 10) {
-		    PJ_LOG(3,(THIS_FILE, 
+		    PJ_LOG(3,(THIS_FILE,
 			      "    error: incorrect retransmit count %d "
 			      "(expecting 10)",
@@ -622,5 +622,5 @@
 		test_complete = -152;
 	    }
-	    
+
 	    /* Previous state. */
 	    if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) {
@@ -657,5 +657,5 @@
 		test_complete = -160;
 	    }
-	    
+
 	    /* Previous state. */
 	    if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_CONFIRMED) {
@@ -671,5 +671,5 @@
 		test_complete = -162;
 	    }
-	    
+
 	    /* Previous state. */
 	    if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) {
@@ -686,5 +686,5 @@
 		test_complete = -164;
 	    }
-	    
+
 	    /* Previous state. */
 	    if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
@@ -704,8 +704,8 @@
     if (pj_stricmp2(&tsx->branch, TEST10_BRANCH_ID)==0 ||
 	pj_stricmp2(&tsx->branch, TEST11_BRANCH_ID)==0 ||
-	pj_stricmp2(&tsx->branch, TEST12_BRANCH_ID)==0)  
+	pj_stricmp2(&tsx->branch, TEST12_BRANCH_ID)==0)
     {
 	if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
-	    
+
 	    if (!test_complete)
 		test_complete = 1;
@@ -741,9 +741,9 @@
 
     if (pj_stricmp2(&branch_param, TEST1_BRANCH_ID) == 0 ||
-	pj_stricmp2(&branch_param, TEST2_BRANCH_ID) == 0) 
+	pj_stricmp2(&branch_param, TEST2_BRANCH_ID) == 0)
     {
 	/*
-	 * TEST1_BRANCH_ID tests that non-INVITE transaction transmits 2xx 
-	 * final response using correct transport and terminates transaction 
+	 * TEST1_BRANCH_ID tests that non-INVITE transaction transmits 2xx
+	 * final response using correct transport and terminates transaction
 	 * after 32 seconds.
 	 *
@@ -754,6 +754,6 @@
 
 	if (msg->type == PJSIP_REQUEST_MSG) {
-	    /* On received request, create UAS and respond with final 
-	     * response. 
+	    /* On received request, create UAS and respond with final
+	     * response.
 	     */
 	    pjsip_transaction *tsx;
@@ -811,5 +811,5 @@
 
 	    send_response(rdata, tsx, TEST3_PROVISIONAL_CODE);
-	    schedule_send_response(rdata, &tsx->transaction_key, 
+	    schedule_send_response(rdata, &tsx->transaction_key,
 				   TEST3_STATUS_CODE, 2000);
 
@@ -841,5 +841,5 @@
     } else if (pj_stricmp2(&branch_param, TEST4_BRANCH_ID) == 0 ||
 	       pj_stricmp2(&branch_param, TEST5_BRANCH_ID) == 0 ||
-	       pj_stricmp2(&branch_param, TEST6_BRANCH_ID) == 0) 
+	       pj_stricmp2(&branch_param, TEST6_BRANCH_ID) == 0)
     {
 
@@ -878,5 +878,5 @@
 	} else {
 	    /* Verify the response received. */
-	    
+
 	    PJ_LOG(4,(THIS_FILE, "    received response number %d", recv_count));
 
@@ -893,5 +893,5 @@
 		    test_complete = -133;
 
-		} 
+		}
 		if (recv_count > TEST5_RESPONSE_COUNT) {
 		    PJ_LOG(3,(THIS_FILE, "    error: not expecting response!"));
@@ -929,5 +929,5 @@
 
     } else if (pj_stricmp2(&branch_param, TEST7_BRANCH_ID) == 0 ||
-	       pj_stricmp2(&branch_param, TEST8_BRANCH_ID) == 0) 
+	       pj_stricmp2(&branch_param, TEST8_BRANCH_ID) == 0)
     {
 
@@ -972,5 +972,5 @@
 
 	    if (recv_count==1) {
-		
+
 		if (rdata->msg_info.msg->line.status.code != code) {
 		    PJ_LOG(3,(THIS_FILE,"    error: invalid status code"));
@@ -988,5 +988,5 @@
 
 		PJ_TIME_VAL_SUB(now, recv_last);
-	    
+
 		msec = now.sec*1000 + now.msec;
 		msec_expected = (1 << (recv_count-2)) * pjsip_cfg()->tsx.t1;
@@ -1017,5 +1017,5 @@
 
 	/*
-	 * TEST9_BRANCH_ID tests that the retransmission of INVITE final 
+	 * TEST9_BRANCH_ID tests that the retransmission of INVITE final
 	 * response should cease when ACK is received. Transaction also MUST
 	 * terminate in T4 seconds.
@@ -1060,5 +1060,5 @@
 
 		PJ_TIME_VAL_SUB(now, recv_last);
-	    
+
 		msec = now.sec*1000 + now.msec;
 		msec_expected = (1 << (recv_count-2)) * pjsip_cfg()->tsx.t1;
@@ -1082,9 +1082,9 @@
 
 		status = pjsip_endpt_create_request_from_hdr(
-			    endpt, &pjsip_ack_method, 
+			    endpt, &pjsip_ack_method,
 			    rdata->msg_info.to->uri,
 			    rdata->msg_info.from,
 			    rdata->msg_info.to,
-			    NULL, 
+			    NULL,
 			    rdata->msg_info.cid,
 			    rdata->msg_info.cseq->cseq,
@@ -1121,5 +1121,5 @@
     } else if (pj_stricmp2(&branch_param, TEST10_BRANCH_ID) == 0 ||
 	       pj_stricmp2(&branch_param, TEST11_BRANCH_ID) == 0 ||
-	       pj_stricmp2(&branch_param, TEST12_BRANCH_ID) == 0) 
+	       pj_stricmp2(&branch_param, TEST12_BRANCH_ID) == 0)
     {
 	int test_num, code1, code2;
@@ -1132,4 +1132,6 @@
 	    test_num=12, code1 = 200, code2 = 0;
 
+	PJ_UNUSED_ARG(test_num);
+
 	if (rdata->msg_info.msg->type == PJSIP_REQUEST_MSG) {
 
@@ -1146,5 +1148,5 @@
 	    pjsip_tsx_recv_msg(tsx, rdata);
 	    save_key(tsx);
-	    
+
 	    schedule_send_response(rdata, &tsx_key, code1, 1000);
 
@@ -1162,9 +1164,9 @@
 }
 
-/* 
- * The generic test framework, used by most of the tests. 
+/*
+ * The generic test framework, used by most of the tests.
  */
-static int perform_test( char *target_uri, char *from_uri, 
-			 char *branch_param, int test_time, 
+static int perform_test( char *target_uri, char *from_uri,
+			 char *branch_param, int test_time,
 			 const pjsip_method *method,
 			 int request_cnt, int request_interval_msec,
@@ -1178,5 +1180,5 @@
     pj_status_t status;
 
-    PJ_LOG(3,(THIS_FILE, 
+    PJ_LOG(3,(THIS_FILE,
 	      "   please standby, this will take at most %d seconds..",
 	      test_time));
@@ -1193,5 +1195,5 @@
     /* Create request. */
     status = pjsip_endpt_create_request( endpt, method, &target,
-					 &from, &target, NULL, NULL, -1, 
+					 &from, &target, NULL, NULL, -1,
 					 NULL, &tdata);
     if (status != PJ_SUCCESS) {
@@ -1369,5 +1371,5 @@
 
     status = perform_test(TARGET_URI, FROM_URI, branch_id, 5,
-			  &pjsip_options_method, 
+			  &pjsip_options_method,
 			  request_cnt, 1000, 1);
     if (status && status != TEST_TIMEOUT_ERROR)
@@ -1423,5 +1425,5 @@
 /*****************************************************************************
  **
- ** TEST9_BRANCH_ID: retransmission of non-2xx INVITE final response must 
+ ** TEST9_BRANCH_ID: retransmission of non-2xx INVITE final response must
  ** cease when ACK is received
  **
@@ -1464,5 +1466,5 @@
 	char *branch_id;
 	char *title;
-    } tests[] = 
+    } tests[] =
     {
 	{ 0,  10,   TEST10_BRANCH_ID, "test10: failed transport in TRYING state (no delay)" },
@@ -1538,11 +1540,11 @@
     tp_flag = pjsip_transport_get_flag_from_type((pjsip_transport_type_e)param->type);
 
-    pj_ansi_sprintf(TARGET_URI, "sip:bob@127.0.0.1:%d;transport=%s", 
+    pj_ansi_sprintf(TARGET_URI, "sip:bob@127.0.0.1:%d;transport=%s",
 		    param->port, param->tp_type);
-    pj_ansi_sprintf(FROM_URI, "sip:alice@127.0.0.1:%d;transport=%s", 
+    pj_ansi_sprintf(FROM_URI, "sip:alice@127.0.0.1:%d;transport=%s",
 		    param->port, param->tp_type);
 
     /* Check if loop transport is configured. */
-    status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_LOOP_DGRAM, 
+    status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_LOOP_DGRAM,
 				      &addr, sizeof(addr), NULL, &loop);
     if (status != PJ_SUCCESS) {
@@ -1562,6 +1564,6 @@
     }
 
-    /* TEST1_BRANCH_ID: Basic 2xx final response. 
-     * TEST2_BRANCH_ID: Basic non-2xx final response. 
+    /* TEST1_BRANCH_ID: Basic 2xx final response.
+     * TEST2_BRANCH_ID: Basic non-2xx final response.
      */
     status = tsx_basic_final_response_test();
@@ -1578,5 +1580,5 @@
      */
     status = tsx_retransmit_last_response_test(TEST4_TITLE,
-					       TEST4_BRANCH_ID, 
+					       TEST4_BRANCH_ID,
 					       TEST4_REQUEST_COUNT,
 					       TEST4_STATUS_CODE);
@@ -1587,5 +1589,5 @@
      */
     status = tsx_retransmit_last_response_test(TEST5_TITLE,
-					       TEST5_BRANCH_ID, 
+					       TEST5_BRANCH_ID,
 					       TEST5_REQUEST_COUNT,
 					       TEST5_STATUS_CODE);
@@ -1600,5 +1602,5 @@
     if ((tp_flag & PJSIP_TRANSPORT_RELIABLE) == 0) {
 	status = tsx_retransmit_last_response_test(TEST6_TITLE,
-						   TEST6_BRANCH_ID, 
+						   TEST6_BRANCH_ID,
 						   TEST6_REQUEST_COUNT,
 						   TEST6_STATUS_CODE);
@@ -1614,5 +1616,5 @@
 	return status;
 
-    /* TEST9_BRANCH_ID: retransmission of non-2xx INVITE final response must 
+    /* TEST9_BRANCH_ID: retransmission of non-2xx INVITE final response must
      * cease when ACK is received
      * Only applicable for non-reliable transports.
Index: pjproject/trunk/pjsip/src/test/uri_test.c
===================================================================
--- pjproject/trunk/pjsip/src/test/uri_test.c	(revision 4727)
+++ pjproject/trunk/pjsip/src/test/uri_test.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "test.h"
@@ -68,5 +68,4 @@
 static pjsip_uri *create_uri16( pj_pool_t *pool );
 static pjsip_uri *create_uri17( pj_pool_t *pool );
-static pjsip_uri *create_uri18( pj_pool_t *pool );
 static pjsip_uri *create_uri25( pj_pool_t *pool );
 static pjsip_uri *create_uri26( pj_pool_t *pool );
@@ -97,5 +96,5 @@
     const char	    *printed;
     pj_size_t	     len;
-} uri_test_array[] = 
+} uri_test_array[] =
 {
     {
@@ -184,5 +183,5 @@
     {
 	/* Excercise strange character sets allowed in display, user, password,
-	 * host, and port. 
+	 * host, and port.
 	 */
 	PJ_SUCCESS,
@@ -198,5 +197,5 @@
     },
     {
-	/* Another excercise to the allowed character sets to the username 
+	/* Another excercise to the allowed character sets to the username
 	 * and password.
 	 */
@@ -439,5 +438,5 @@
 {
     /* "sip:localhost;pickup=hurry;user=phone;message=I%20am%20sorry"
-       "?Subject=Hello%20There&Server=SIP%20Server" 
+       "?Subject=Hello%20There&Server=SIP%20Server"
      */
     pjsip_sip_uri *url = pjsip_sip_uri_create(pool, 0);
@@ -659,5 +658,5 @@
 
     uri->number = pj_str("(44).1234-*#+Deaf");
-    return (pjsip_uri*)uri;    
+    return (pjsip_uri*)uri;
 }
 
@@ -669,5 +668,5 @@
     uri->number = pj_str("+1");
     uri->isub_param = pj_str("/:@&$,-_.!~*'()[]/:&$aA1!+=");
-    return (pjsip_uri*)uri;    
+    return (pjsip_uri*)uri;
 }
 
@@ -679,5 +678,5 @@
     uri->number = pj_str("+1");
     uri->ext_param = pj_str("+123");
-    return (pjsip_uri*)uri;    
+    return (pjsip_uri*)uri;
 }
 
@@ -689,5 +688,5 @@
     uri->number = pj_str("911");
     uri->context = pj_str("+1-911");
-    return (pjsip_uri*)uri;    
+    return (pjsip_uri*)uri;
 }
 
@@ -699,5 +698,5 @@
     uri->number = pj_str("911");
     uri->context = pj_str("EMERGENCY.EXAMPLE.COM");
-    return (pjsip_uri*)uri;    
+    return (pjsip_uri*)uri;
 }
 
@@ -709,10 +708,10 @@
 
     uri->number = pj_str("911");
-    
+
     p = PJ_POOL_ALLOC_T(pool, pjsip_param);
     p->name = p->value = pj_str("p1");
     pj_list_insert_before(&uri->other_param, p);
 
-    return (pjsip_uri*)uri;    
+    return (pjsip_uri*)uri;
 }
 
@@ -750,5 +749,5 @@
     url = pjsip_sip_uri_create(pool, 0);
     url->host = pj_str("localhost");
-    
+
     name->uri = (pjsip_uri*)url;
 
@@ -768,5 +767,5 @@
     url = pjsip_sip_uri_create(pool, 0);
     url->host = pj_str("localhost");
-    
+
     name->uri = (pjsip_uri*)url;
 
@@ -1000,6 +999,6 @@
     avg_parse = 1000000 / avg_parse;
 
-    PJ_LOG(3,(THIS_FILE, 
-	      "    %u.%u MB of urls parsed in %d.%03ds (avg=%d urls/sec)", 
+    PJ_LOG(3,(THIS_FILE,
+	      "    %u.%u MB of urls parsed in %d.%03ds (avg=%d urls/sec)",
 	      (unsigned)(var.parse_len/1000000), (unsigned)kbytes,
 	      elapsed.sec, elapsed.msec,
@@ -1019,6 +1018,6 @@
     avg_print = 1000000 / avg_print;
 
-    PJ_LOG(3,(THIS_FILE, 
-	      "    %u.%u MB of urls printed in %d.%03ds (avg=%d urls/sec)", 
+    PJ_LOG(3,(THIS_FILE,
+	      "    %u.%u MB of urls printed in %d.%03ds (avg=%d urls/sec)",
 	      (unsigned)(var.print_len/1000000), (unsigned)kbytes,
 	      elapsed.sec, elapsed.msec,
@@ -1038,6 +1037,6 @@
     avg_cmp = 1000000 / avg_cmp;
 
-    PJ_LOG(3,(THIS_FILE, 
-	      "    %u.%u MB of urls compared in %d.%03ds (avg=%d urls/sec)", 
+    PJ_LOG(3,(THIS_FILE,
+	      "    %u.%u MB of urls compared in %d.%03ds (avg=%d urls/sec)",
 	      (unsigned)(var.cmp_len/1000000), (unsigned)kbytes,
 	      elapsed.sec, elapsed.msec,
@@ -1085,6 +1084,6 @@
 
 
-    /* 
-     * Print maximum parse/sec 
+    /*
+     * Print maximum parse/sec
      */
     for (i=0, max=0; i<COUNT; ++i)
Index: pjproject/trunk/third_party/ilbc/LPCencode.c
===================================================================
--- pjproject/trunk/third_party/ilbc/LPCencode.c	(revision 4727)
+++ pjproject/trunk/third_party/ilbc/LPCencode.c	(revision 4728)
@@ -225,5 +225,4 @@
        float lsf[LPC_FILTERORDER * LPC_N_MAX];
        float lsfdeq[LPC_FILTERORDER * LPC_N_MAX];
-       int change=0;
 
        SimpleAnalysis(lsf, data, iLBCenc_inst);
@@ -234,5 +233,5 @@
 
 
-       change=LSF_check(lsfdeq, LPC_FILTERORDER, iLBCenc_inst->lpc_n);
+       LSF_check(lsfdeq, LPC_FILTERORDER, iLBCenc_inst->lpc_n);
        SimpleInterpolateLSF(syntdenum, weightdenum,
            lsf, lsfdeq, iLBCenc_inst->lsfold,
Index: pjproject/trunk/third_party/ilbc/helpfun.c
===================================================================
--- pjproject/trunk/third_party/ilbc/helpfun.c	(revision 4727)
+++ pjproject/trunk/third_party/ilbc/helpfun.c	(revision 4728)
@@ -278,5 +278,5 @@
    ){
        int k,n,m, Nit=2, change=0,pos;
-       float tmp;
+       //float tmp;
        static float eps=(float)0.039; /* 50 Hz */
        static float eps2=(float)0.0195;
@@ -294,5 +294,5 @@
 
                        if (lsf[pos+1]<lsf[pos]) {
-                           tmp=lsf[pos+1];
+                           //tmp=lsf[pos+1];
                            lsf[pos+1]= lsf[pos]+eps2;
                            lsf[pos]= lsf[pos+1]-eps2;
Index: pjproject/trunk/third_party/ilbc/iLBC_decode.c
===================================================================
--- pjproject/trunk/third_party/ilbc/iLBC_decode.c	(revision 4727)
+++ pjproject/trunk/third_party/ilbc/iLBC_decode.c	(revision 4728)
@@ -340,5 +340,4 @@
        float cc, maxcc;
        int idxVec[STATE_LEN];
-       int check;
        int gain_index[NASUB_MAX*CB_NSTAGES],
            extra_gain_index[CB_NSTAGES];
@@ -501,5 +500,5 @@
 
                SimplelsfDEQ(lsfdeq, lsf_i, iLBCdec_inst->lpc_n);
-               check=LSF_check(lsfdeq, LPC_FILTERORDER,
+               LSF_check(lsfdeq, LPC_FILTERORDER,
                    iLBCdec_inst->lpc_n);
                DecoderInterpolateLSF(syntdenum, weightdenum,
Index: pjproject/trunk/third_party/resample/src/resamplesubs.c
===================================================================
--- pjproject/trunk/third_party/resample/src/resamplesubs.c	(revision 4727)
+++ pjproject/trunk/third_party/resample/src/resamplesubs.c	(revision 4728)
@@ -7,5 +7,5 @@
  *
  * Snippet from the resample.1 man page:
- * 
+ *
  * HISTORY
  *
@@ -14,19 +14,19 @@
  * 1981.  It was called SRCONV and was written in SAIL for PDP-10
  * compatible machines.  The algorithm was first published in
- * 
+ *
  * Smith, Julius O. and Phil Gossett. ``A Flexible Sampling-Rate
  * Conversion Method,'' Proceedings (2): 19.4.1-19.4.4, IEEE Conference
  * on Acoustics, Speech, and Signal Processing, San Diego, March 1984.
- * 
+ *
  * An expanded tutorial based on this paper is available at the Digital
  * Audio Resampling Home Page given above.
- * 
+ *
  * Circa 1988, the SRCONV program was translated from SAIL to C by
  * Christopher Lee Fraley working with Roger Dannenberg at CMU.
- * 
+ *
  * Since then, the C version has been maintained by jos.
- * 
+ *
  * Sndlib support was added 6/99 by John Gibson <jgg9c@virginia.edu>.
- * 
+ *
  * The resample program is free software distributed in accordance
  * with the Lesser GNU Public License (LGPL).  There is NO warranty; not
@@ -78,5 +78,5 @@
 #undef INLINE
 #define INLINE
-#define HAVE_FILTER 0    
+#define HAVE_FILTER 0
 
 #ifndef NULL
@@ -95,5 +95,5 @@
     } else if (v < MIN_HWORD) {
 	v = MIN_HWORD;
-    }	
+    }
     out = (RES_HWORD) v;
     return out;
@@ -102,5 +102,5 @@
 /* Sampling rate conversion using linear interpolation for maximum speed.
  */
-static int 
+static int
   SrcLinear(const RES_HWORD X[], RES_HWORD Y[], double pFactor, RES_UHWORD nx)
 {
@@ -110,17 +110,17 @@
     RES_HWORD *Ystart, *Yend;
     RES_WORD v,x1,x2;
-    
-    double dt;                  /* Step through input signal */ 
+
+    double dt;                  /* Step through input signal */
     RES_UWORD dtb;                  /* Fixed-point version of Dt */
-    RES_UWORD endTime;              /* When time reaches EndTime, return to user */
-    
+    //RES_UWORD endTime;              /* When time reaches EndTime, return to user */
+
     dt = 1.0/pFactor;            /* Output sampling period */
     dtb = dt*(1<<Np) + 0.5;     /* Fixed-point representation */
-    
+
     Ystart = Y;
     Yend = Ystart + (unsigned)(nx * pFactor + 0.5);
-    endTime = time + (1<<Np)*(RES_WORD)nx;
-    
-    // Integer round down in dtb calculation may cause (endTime % dtb > 0), 
+    //endTime = time + (1<<Np)*(RES_WORD)nx;
+
+    // Integer round down in dtb calculation may cause (endTime % dtb > 0),
     // so it may cause resample write pass the output buffer (Y >= Yend).
     // while (time < endTime)
@@ -140,5 +140,5 @@
 }
 
-static RES_WORD FilterUp(const RES_HWORD Imp[], const RES_HWORD ImpD[], 
+static RES_WORD FilterUp(const RES_HWORD Imp[], const RES_HWORD ImpD[],
 		     RES_UHWORD Nwing, RES_BOOL Interp,
 		     const RES_HWORD *Xp, RES_HWORD Ph, RES_HWORD Inc)
@@ -149,5 +149,5 @@
     RES_HWORD a = 0;
     RES_WORD v, t;
-    
+
     v=0;
     Hp = &Imp[Ph>>Na];
@@ -179,6 +179,6 @@
 
 	  Xp += Inc;		/* Input signal step. NO CHECK ON BOUNDS */
-      } 
-    else 
+      }
+    else
       while (Hp < End) {
 	  t = *Hp;		/* Get filter coeff */
@@ -203,5 +203,5 @@
     RES_WORD v, t;
     RES_UWORD Ho;
-    
+
     v=0;
     Ho = (Ph*(RES_UWORD)dhb)>>Np;
@@ -228,5 +228,5 @@
 	  Xp += Inc;		/* Input signal step. NO CHECK ON BOUNDS */
       }
-    else 
+    else
       while ((Hp = &Imp[Ho>>Na]) < End) {
 	  t = *Hp;		/* Get IR sample */
@@ -245,5 +245,5 @@
  * Slightly faster than down-conversion;
  */
-static int SrcUp(const RES_HWORD X[], RES_HWORD Y[], double pFactor, 
+static int SrcUp(const RES_HWORD X[], RES_HWORD Y[], double pFactor,
 		 RES_UHWORD nx, RES_UHWORD pNwing, RES_UHWORD pLpScl,
 		 const RES_HWORD pImp[], const RES_HWORD pImpD[], RES_BOOL Interp)
@@ -252,18 +252,18 @@
     RES_HWORD *Ystart, *Yend;
     RES_WORD v;
-    
-    double dt;                  /* Step through input signal */ 
+
+    double dt;                  /* Step through input signal */
     RES_UWORD dtb;                  /* Fixed-point version of Dt */
     RES_UWORD time = 0;
-    RES_UWORD endTime;              /* When time reaches EndTime, return to user */
-    
+    //RES_UWORD endTime;              /* When time reaches EndTime, return to user */
+
     dt = 1.0/pFactor;            /* Output sampling period */
     dtb = dt*(1<<Np) + 0.5;     /* Fixed-point representation */
-    
+
     Ystart = Y;
     Yend = Ystart + (unsigned)(nx * pFactor + 0.5);
-    endTime = time + (1<<Np)*(RES_WORD)nx;
-
-    // Integer round down in dtb calculation may cause (endTime % dtb > 0), 
+    //endTime = time + (1<<Np)*(RES_WORD)nx;
+
+    // Integer round down in dtb calculation may cause (endTime % dtb > 0),
     // so it may cause resample write pass the output buffer (Y >= Yend).
     // while (time < endTime)
@@ -289,5 +289,5 @@
 /* Sampling rate conversion subroutine */
 
-static int SrcUD(const RES_HWORD X[], RES_HWORD Y[], double pFactor, 
+static int SrcUD(const RES_HWORD X[], RES_HWORD Y[], double pFactor,
 		 RES_UHWORD nx, RES_UHWORD pNwing, RES_UHWORD pLpScl,
 		 const RES_HWORD pImp[], const RES_HWORD pImpD[], RES_BOOL Interp)
@@ -296,22 +296,22 @@
     RES_HWORD *Ystart, *Yend;
     RES_WORD v;
-    
+
     double dh;                  /* Step through filter impulse response */
     double dt;                  /* Step through input signal */
     RES_UWORD time = 0;
-    RES_UWORD endTime;          /* When time reaches EndTime, return to user */
+    //RES_UWORD endTime;          /* When time reaches EndTime, return to user */
     RES_UWORD dhb, dtb;         /* Fixed-point versions of Dh,Dt */
-    
+
     dt = 1.0/pFactor;            /* Output sampling period */
     dtb = dt*(1<<Np) + 0.5;     /* Fixed-point representation */
-    
+
     dh = MIN(Npc, pFactor*Npc);  /* Filter sampling period */
     dhb = dh*(1<<Na) + 0.5;     /* Fixed-point representation */
-    
+
     Ystart = Y;
     Yend = Ystart + (unsigned)(nx * pFactor + 0.5);
-    endTime = time + (1<<Np)*(RES_WORD)nx;
-
-    // Integer round down in dtb calculation may cause (endTime % dtb > 0), 
+    //endTime = time + (1<<Np)*(RES_WORD)nx;
+
+    // Integer round down in dtb calculation may cause (endTime % dtb > 0),
     // so it may cause resample write pass the output buffer (Y >= Yend).
     // while (time < endTime)
@@ -332,5 +332,5 @@
 
 
-DECL(int) res_SrcLinear(const RES_HWORD X[], RES_HWORD Y[], 
+DECL(int) res_SrcLinear(const RES_HWORD X[], RES_HWORD Y[],
 		        double pFactor, RES_UHWORD nx)
 {
@@ -338,5 +338,5 @@
 }
 
-DECL(int) res_Resample(const RES_HWORD X[], RES_HWORD Y[], double pFactor, 
+DECL(int) res_Resample(const RES_HWORD X[], RES_HWORD Y[], double pFactor,
 		       RES_UHWORD nx, RES_BOOL LargeF, RES_BOOL Interp)
 {
@@ -355,9 +355,9 @@
 
 	if (LargeF)
-	    return SrcUD(X, Y, pFactor, nx, 
+	    return SrcUD(X, Y, pFactor, nx,
 			 LARGE_FILTER_NWING, LARGE_FILTER_SCALE * pFactor + 0.5,
 			 LARGE_FILTER_IMP, LARGE_FILTER_IMPD, Interp);
 	else
-	    return SrcUD(X, Y, pFactor, nx, 
+	    return SrcUD(X, Y, pFactor, nx,
 			 SMALL_FILTER_NWING, SMALL_FILTER_SCALE * pFactor + 0.5,
 			 SMALL_FILTER_IMP, SMALL_FILTER_IMPD, Interp);
@@ -369,8 +369,8 @@
 {
     if (LargeF)
-	return (LARGE_FILTER_NMULT + 1) / 2.0  *  
+	return (LARGE_FILTER_NMULT + 1) / 2.0  *
 	        MAX(1.0, 1.0/pFactor);
     else
-	return (SMALL_FILTER_NMULT + 1) / 2.0  *  
+	return (SMALL_FILTER_NMULT + 1) / 2.0  *
 		MAX(1.0, 1.0/pFactor);
 }
