浏览代码

mi_rpc: fixed warning of dereferencing type-punned pointer

Daniel-Constantin Mierla 13 年之前
父节点
当前提交
78a8bcd603
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. 6 6
      modules/mi_rpc/mi_rpc_mod.c

+ 6 - 6
modules/mi_rpc/mi_rpc_mod.c

@@ -513,7 +513,7 @@ static struct mi_root* mi_run_rpc(struct mi_root* cmd_tree, void* param)
 	/* response will be malloced by binrpc_response_to_text. 
 	   We do not free it. It must remain after this call.
 	   It will be reused by subsequent calls */
-	static char *response = NULL;
+	static unsigned char *response = NULL;
 	static int resp_len = 0;
 	
 	if (binrpc_open_connection_url(&rpc_handle, rpc_url) != 0) 
@@ -577,9 +577,9 @@ static struct mi_root* mi_run_rpc(struct mi_root* cmd_tree, void* param)
 	{
 		case 0:
 			/* Success */
-			binrpc_response_to_text(&resp_handle, (unsigned char **)&response, &resp_len, '\n');
-			if (strlen(response) > 0)
-				result = init_mi_tree( 200, response, strlen(response) );
+			binrpc_response_to_text(&resp_handle, &response, &resp_len, '\n');
+			if (strlen((char*)response) > 0)
+				result = init_mi_tree( 200, (char*)response, strlen((char*)response) );
 			else
 				/* Some functions don't give a text answer; use a default */
 				result = init_mi_tree( 200, MI_OK_S, MI_OK_LEN );
@@ -597,8 +597,8 @@ static struct mi_root* mi_run_rpc(struct mi_root* cmd_tree, void* param)
 			}
 			memcpy(response, resp, strlen(resp));
 			response[strlen(resp)]='\0';
-			if (strlen(response) > 0)
-				result = init_mi_tree( resp_code, response, strlen(response) );
+			if (strlen((char*)response) > 0)
+				result = init_mi_tree( resp_code, (char*)response, strlen((char*)response) );
 			else
 				/* Some functions don't give a text answer; use a default */
 				result = init_mi_tree( resp_code, (char *)FAILED, strlen(FAILED) );