@@ -31,8 +31,15 @@ get_func_size(const AOTModule *module, struct func_info *sorted_func_ptrs,
3131static int
3232compare_func_ptrs (const void * f1 , const void * f2 )
3333{
34- return (intptr_t )((struct func_info * )f1 )-> ptr
35- - (intptr_t )((struct func_info * )f2 )-> ptr ;
34+ uintptr_t ptr1 = (uintptr_t )((struct func_info * )f1 )-> ptr ;
35+ uintptr_t ptr2 = (uintptr_t )((struct func_info * )f2 )-> ptr ;
36+
37+ if (ptr1 < ptr2 )
38+ return -1 ;
39+ else if (ptr1 > ptr2 )
40+ return 1 ;
41+ else
42+ return 0 ;
3643}
3744
3845static struct func_info *
@@ -45,8 +52,8 @@ sort_func_ptrs(const AOTModule *module, char *error_buf, uint32 error_buf_size)
4552 content_len = (uint64 )sizeof (struct func_info ) * module -> func_count ;
4653 sorted_func_ptrs = wasm_runtime_malloc (content_len );
4754 if (!sorted_func_ptrs ) {
48- snprintf (error_buf , error_buf_size ,
49- "allocate memory failed when creating perf map" );
55+ ( void ) snprintf (error_buf , error_buf_size ,
56+ "allocate memory failed when creating perf map" );
5057 return NULL ;
5158 }
5259
@@ -77,7 +84,8 @@ aot_create_perf_map(const AOTModule *module, char *error_buf,
7784 if (!sorted_func_ptrs )
7885 goto quit ;
7986
80- snprintf (perf_map_path , sizeof (perf_map_path ) - 1 , "/tmp/perf-%d.map" , pid );
87+ (void )snprintf (perf_map_path , sizeof (perf_map_path ) - 1 , "/tmp/perf-%d.map" ,
88+ pid );
8189 perf_map = fopen (perf_map_path , "a" );
8290 if (!perf_map ) {
8391 LOG_WARNING ("warning: can't create /tmp/perf-%d.map, because %s" , pid ,
@@ -88,19 +96,23 @@ aot_create_perf_map(const AOTModule *module, char *error_buf,
8896 const char * module_name = aot_get_module_name ((AOTModule * )module );
8997 for (i = 0 ; i < module -> func_count ; i ++ ) {
9098 memset (perf_map_info , 0 , 128 );
91- if (strlen (module_name ) > 0 )
92- snprintf (perf_map_info , 128 , PRIxPTR " %x [%s]#aot_func#%u\n" ,
93- (uintptr_t )sorted_func_ptrs [i ].ptr ,
94- get_func_size (module , sorted_func_ptrs , i ), module_name ,
95- sorted_func_ptrs [i ].idx );
96- else
97- snprintf (perf_map_info , 128 , PRIxPTR " %x aot_func#%u\n" ,
98- (uintptr_t )sorted_func_ptrs [i ].ptr ,
99- get_func_size (module , sorted_func_ptrs , i ),
100- sorted_func_ptrs [i ].idx );
99+ if (strlen (module_name ) > 0 ) {
100+ (void )snprintf (perf_map_info , 128 ,
101+ "%" PRIxPTR " %x [%s]#aot_func#%u\n" ,
102+ (uintptr_t )sorted_func_ptrs [i ].ptr ,
103+ get_func_size (module , sorted_func_ptrs , i ),
104+ module_name , sorted_func_ptrs [i ].idx );
105+ }
106+ else {
107+ (void )snprintf (perf_map_info , 128 ,
108+ "%" PRIxPTR " %x aot_func#%u\n" ,
109+ (uintptr_t )sorted_func_ptrs [i ].ptr ,
110+ get_func_size (module , sorted_func_ptrs , i ),
111+ sorted_func_ptrs [i ].idx );
112+ }
101113
102114 /* fwrite() is thread safe */
103- fwrite (perf_map_info , 1 , strlen (perf_map_info ), perf_map );
115+ ( void ) fwrite (perf_map_info , 1 , strlen (perf_map_info ), perf_map );
104116 }
105117
106118 LOG_VERBOSE ("write map information from %s into /tmp/perf-%d.map" ,
@@ -112,7 +124,7 @@ aot_create_perf_map(const AOTModule *module, char *error_buf,
112124 wasm_runtime_free (sorted_func_ptrs );
113125
114126 if (perf_map )
115- fclose (perf_map );
127+ ( void ) fclose (perf_map );
116128
117129 return ret ;
118130}
0 commit comments