Skip to content

Commit 9af95e9

Browse files
authored
Merge pull request #65 from normanmaurer/clang_fixes
Fix compile warnings when compiling on latest OSX with clang
2 parents 2f96b1c + f413f85 commit 9af95e9

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/c/perf-map-agent.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,9 @@ static void sig_string(jvmtiEnv *jvmti, jmethodID method, char *output, size_t n
8080
char *method_name = NULL;
8181
char *msig = NULL;
8282
char *csig = NULL;
83-
char *empty = "";
8483
jvmtiLineNumberEntry *lines = NULL;
8584

8685
jclass class;
87-
jvmtiError error = 0;
8886
jint entrycount = 0;
8987

9088
strncpy(output, "<error writing signature>", noutput);
@@ -105,7 +103,7 @@ static void sig_string(jvmtiEnv *jvmti, jmethodID method, char *output, size_t n
105103

106104
if (lines != NULL) (*jvmti)->Deallocate(jvmti, (unsigned char *) lines);
107105
}
108-
if (sourcefile != NULL) (*jvmti)->Deallocate(jvmti, sourcefile);
106+
if (sourcefile != NULL) (*jvmti)->Deallocate(jvmti, (unsigned char *) sourcefile);
109107
}
110108
}
111109

@@ -116,17 +114,17 @@ static void sig_string(jvmtiEnv *jvmti, jmethodID method, char *output, size_t n
116114
class_name_from_sig(class_name, sizeof(class_name), csig);
117115
snprintf(output, noutput, "%s::%s%s%s", class_name, method_name, method_signature, source_info);
118116

119-
if (csig != NULL) (*jvmti)->Deallocate(jvmti, csig);
117+
if (csig != NULL) (*jvmti)->Deallocate(jvmti, (unsigned char *) csig);
120118
}
121-
if (method_name != NULL) (*jvmti)->Deallocate(jvmti, method_name);
122-
if (msig != NULL) (*jvmti)->Deallocate(jvmti, msig);
119+
if (method_name != NULL) (*jvmti)->Deallocate(jvmti, (unsigned char *) method_name);
120+
if (msig != NULL) (*jvmti)->Deallocate(jvmti, (unsigned char *) msig);
123121
}
124122
}
125123

126124
void generate_single_entry(jvmtiEnv *jvmti, jmethodID method, const void *code_addr, jint code_size) {
127125
char entry[STRING_BUFFER_SIZE];
128126
sig_string(jvmti, method, entry, sizeof(entry));
129-
perf_map_write_entry(method_file, code_addr, code_size, entry);
127+
perf_map_write_entry(method_file, code_addr, (unsigned int) code_size, entry);
130128
}
131129

132130
/* Generates either a simple or a complex unfolded entry. */
@@ -160,7 +158,7 @@ void write_unfolded_entry(
160158
//printf("At %d method is %d len %d remaining %d\n", i, info->methods[i], strlen(full_name), sizeof(full_name) - 1 - strlen(full_name));
161159
sig_string(jvmti, info->methods[i], inlined_name, sizeof(inlined_name));
162160
strncat(full_name, inlined_name, sizeof(full_name) - 1 - strlen(full_name)); // TODO optimize
163-
if (i != 0) strncat(full_name, "->", sizeof(full_name));
161+
if (i != 0) strncat(full_name, "->", sizeof(full_name) -1 - strlen(full_name));
164162
}
165163
entry_p = full_name;
166164
} else {
@@ -172,7 +170,7 @@ void write_unfolded_entry(
172170
entry_p = root_name;
173171
}
174172

175-
perf_map_write_entry(method_file, start_addr, end_addr - start_addr, entry_p);
173+
perf_map_write_entry(method_file, start_addr, (unsigned int) (end_addr - start_addr), entry_p);
176174
}
177175

178176
void dump_entries(
@@ -243,7 +241,7 @@ void generate_unfolded_entries(
243241
if (i > 0)
244242
write_unfolded_entry(jvmti, &record->pcinfo[i - 1], root_method, root_name, start_addr, end_addr);
245243
else
246-
generate_single_entry(jvmti, root_method, start_addr, end_addr - start_addr);
244+
generate_single_entry(jvmti, root_method, start_addr, (unsigned int) (end_addr - start_addr));
247245

248246
start_addr = info->pc;
249247
cur_method = top_method;
@@ -258,7 +256,7 @@ void generate_unfolded_entries(
258256
if (i > 0)
259257
write_unfolded_entry(jvmti, &record->pcinfo[i - 1], root_method, root_name, start_addr, end_addr);
260258
else
261-
generate_single_entry(jvmti, root_method, start_addr, end_addr - start_addr);
259+
generate_single_entry(jvmti, root_method, start_addr, (unsigned int) (end_addr - start_addr));
262260
}
263261
} else
264262
generate_single_entry(jvmti, root_method, code_addr, code_size);
@@ -284,7 +282,7 @@ cbDynamicCodeGenerated(jvmtiEnv *jvmti,
284282
const char* name,
285283
const void* address,
286284
jint length) {
287-
perf_map_write_entry(method_file, address, length, name);
285+
perf_map_write_entry(method_file, address, (unsigned int) length, name);
288286
}
289287

290288
void set_notification_mode(jvmtiEnv *jvmti, jvmtiEventMode mode) {

0 commit comments

Comments
 (0)