@@ -31,8 +31,15 @@ get_func_size(const AOTModule *module, struct func_info *sorted_func_ptrs,
31
31
static int
32
32
compare_func_ptrs (const void * f1 , const void * f2 )
33
33
{
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 ;
36
43
}
37
44
38
45
static struct func_info *
@@ -45,8 +52,8 @@ sort_func_ptrs(const AOTModule *module, char *error_buf, uint32 error_buf_size)
45
52
content_len = (uint64 )sizeof (struct func_info ) * module -> func_count ;
46
53
sorted_func_ptrs = wasm_runtime_malloc (content_len );
47
54
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" );
50
57
return NULL ;
51
58
}
52
59
@@ -77,7 +84,8 @@ aot_create_perf_map(const AOTModule *module, char *error_buf,
77
84
if (!sorted_func_ptrs )
78
85
goto quit ;
79
86
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 );
81
89
perf_map = fopen (perf_map_path , "a" );
82
90
if (!perf_map ) {
83
91
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,
88
96
const char * module_name = aot_get_module_name ((AOTModule * )module );
89
97
for (i = 0 ; i < module -> func_count ; i ++ ) {
90
98
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
+ }
101
113
102
114
/* 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 );
104
116
}
105
117
106
118
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,
112
124
wasm_runtime_free (sorted_func_ptrs );
113
125
114
126
if (perf_map )
115
- fclose (perf_map );
127
+ ( void ) fclose (perf_map );
116
128
117
129
return ret ;
118
130
}
0 commit comments