From: Maynard J. <may...@us...> - 2013-12-19 19:17:55
|
This patch has been pushed upstream already. ------------------------------------------------------------------ Fix two makefiles to use -Werror, and fix resulting compiler errors I discovered that the Makefile.am files in libperf_events and libpe_utils did not set AM_CXXFLAGS = @OP_CXXFLAGS@, and thus, the extra -W flags that are added to OP_CXXFLAGS (in configure.ac) were not being used when building these two directories. Once I corrected this problem with the makefiles and rebuilt the source tree, the g++ compiler found a number of minor issues and ended in error due to the -Werror flag. This patch contains fixes for the two Makefile.am files, as well as fixes for the compiler's warnings-turned-to-errors. These were all minor issues that I'm fairly confident should not have caused any functional problems. Both manual testing and oprofile testsuite pass with this patch applied. Signed-off-by: Maynard Johnson <may...@us...> --- libpe_utils/Makefile.am | 2 ++ libperf_events/Makefile.am | 2 ++ libperf_events/operf_counter.cpp | 18 ++++++++---------- libperf_events/operf_process_info.cpp | 6 +++--- libperf_events/operf_utils.cpp | 25 +++++++++---------------- 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/libpe_utils/Makefile.am b/libpe_utils/Makefile.am index 0ed4114..5dbf3d7 100644 --- a/libpe_utils/Makefile.am +++ b/libpe_utils/Makefile.am @@ -9,6 +9,8 @@ AM_CPPFLAGS = \ @PERF_EVENT_FLAGS@ \ @OP_CPPFLAGS@ +AM_CXXFLAGS = @OP_CXXFLAGS@ + noinst_LIBRARIES = libpe_utils.a libpe_utils_a_SOURCES = \ op_pe_utils.h \ diff --git a/libperf_events/Makefile.am b/libperf_events/Makefile.am index cf5f434..2ec09f1 100644 --- a/libperf_events/Makefile.am +++ b/libperf_events/Makefile.am @@ -11,6 +11,8 @@ AM_CPPFLAGS = \ @PERF_EVENT_FLAGS@ \ @OP_CPPFLAGS@ +AM_CXXFLAGS = @OP_CXXFLAGS@ + noinst_LIBRARIES = libperf_events.a libperf_events_a_SOURCES = \ operf_utils.h \ diff --git a/libperf_events/operf_counter.cpp b/libperf_events/operf_counter.cpp index 1f0b648..52c4460 100644 --- a/libperf_events/operf_counter.cpp +++ b/libperf_events/operf_counter.cpp @@ -97,7 +97,7 @@ again: // Implies pipe has been closed on the write end, so return -1 to quit reading rc = OP_PIPE_CLOSED; goto out; - } else if (num_read != read_size) { + } else if (num_read != (ssize_t)read_size) { header += num_read; read_size -= num_read; goto again; @@ -137,7 +137,7 @@ again2: // Implies pipe has been closed on the write end, so return -1 to quit reading rc = OP_PIPE_CLOSED; goto out; - } else if (num_read != read_size) { + } else if (num_read != (ssize_t)read_size) { evt += num_read; read_size -= num_read; goto again; @@ -283,7 +283,7 @@ operf_record::~operf_record() if (poll_data) delete[] poll_data; - for (int i = 0; i < samples_array.size(); i++) { + for (size_t i = 0; i < samples_array.size(); i++) { struct mmap_data *md = &samples_array[i]; munmap(md->base, (num_mmap_pages + 1) * pagesize); } @@ -301,7 +301,6 @@ operf_record::operf_record(int out_fd, bool sys_wide, pid_t the_pid, bool pid_ru vector<operf_event_t> & events, vmlinux_info_t vi, bool do_cg, bool separate_by_cpu, bool out_fd_is_file) { - int flags = O_CREAT|O_RDWR|O_TRUNC; struct sigaction sa; sigset_t ss; vmlinux_file = vi.image_name; @@ -540,7 +539,7 @@ int operf_record::prepareToRecord(void) << num_cpus << " x " << evts.size() << ")." << endl; return -1; } - for (unsigned int cpu = 0; cpu < num_cpus; cpu++) { + for (int cpu = 0; cpu < num_cpus; cpu++) { int fd_for_set_output = perfCounters[op_ctr_idx].get_fd(); for (unsigned event = 0; event < evts.size(); event++) { int fd = perfCounters[op_ctr_idx].get_fd(); @@ -640,7 +639,6 @@ void operf_record::setup() for (int cpu = 0; cpu < num_cpus; cpu++) { int real_cpu; - int mmap_fd; if (use_cpu_minus_one) { real_cpu = -1; } else if (all_cpus_avail) { @@ -703,7 +701,7 @@ void operf_record::setup() error: delete[] poll_data; poll_data = NULL; - for (int i = 0; i < samples_array.size(); i++) { + for (size_t i = 0; i < samples_array.size(); i++) { struct mmap_data *md = &samples_array[i]; munmap(md->base, (num_mmap_pages + 1) * pagesize); } @@ -727,7 +725,7 @@ void operf_record::record_process_info(void) if (cverb << vrecord) cout << "Created COMM event for " << procs[proc_idx].comm << endl; - if ((procs[proc_idx].pid == last_tgid) || + if (((pid_t)(procs[proc_idx].pid) == last_tgid) || (pids_mapped.find(procs[proc_idx].pid) != pids_mapped.end())) continue; OP_perf_utils::op_record_process_exec_mmaps(procs[proc_idx].tid, @@ -748,7 +746,7 @@ void operf_record::recordPerfData(void) while (1) { int prev = sample_reads; - for (int i = 0; i < samples_array.size(); i++) { + for (size_t i = 0; i < samples_array.size(); i++) { if (samples_array[i].base) op_get_kernel_event_data(&samples_array[i], this); } @@ -973,7 +971,7 @@ unsigned int operf_read::convertPerfData(void) unsigned int num_bytes = 0; struct mmap_info info; bool error = false; - event_t * event; + event_t * event = NULL; if (!inputFname.empty()) { info.file_data_offset = opHeader.data_offset; diff --git a/libperf_events/operf_process_info.cpp b/libperf_events/operf_process_info.cpp index 1a861f7..65936da 100644 --- a/libperf_events/operf_process_info.cpp +++ b/libperf_events/operf_process_info.cpp @@ -31,8 +31,8 @@ using namespace OP_perf_utils; operf_process_info::operf_process_info(pid_t tgid, const char * appname, bool app_arg_is_fullname, bool is_valid) -: pid(tgid), valid(is_valid), appname_valid(false), forked(false), look_for_appname_match(false), - appname_is_fullname(NOT_FULLNAME), num_app_chars_matched(-1) +: pid(tgid), valid(is_valid), appname_valid(false), look_for_appname_match(false), + forked(false), appname_is_fullname(NOT_FULLNAME), num_app_chars_matched(-1) { _appname = ""; set_appname(appname, app_arg_is_fullname); @@ -186,7 +186,7 @@ void operf_process_info::check_mapping_for_appname(struct operf_mmap * mapping) string basename; int num_matched_chars = get_num_matching_chars(mapping->filename, basename); if (num_matched_chars > num_app_chars_matched) { - if (num_matched_chars == app_basename.length()) { + if (num_matched_chars == (int)app_basename.length()) { appname_is_fullname = YES_FULLNAME; look_for_appname_match = false; appname_valid = true; diff --git a/libperf_events/operf_utils.cpp b/libperf_events/operf_utils.cpp index 66a6c0e..ab1a66e 100644 --- a/libperf_events/operf_utils.cpp +++ b/libperf_events/operf_utils.cpp @@ -39,7 +39,6 @@ #include "utility.h" -extern verbose vmisc; extern volatile bool quit; extern operf_read operfRead; extern int sample_reads; @@ -170,7 +169,7 @@ static void __handle_comm_event(event_t * event) */ const char * appname_arg; bool is_complete_appname; - if (app_name && (app_PID == event->comm.pid)) { + if (app_name && (app_PID == (pid_t) event->comm.pid)) { appname_arg = app_name; is_complete_appname = true; } else { @@ -320,7 +319,7 @@ static void __handle_mmap_event(event_t * event) */ const char * appname_arg; bool is_complete_appname; - if (app_name && (app_PID == event->mmap.pid)) { + if (app_name && (app_PID == (pid_t)event->mmap.pid)) { appname_arg = app_name; is_complete_appname = true; } else { @@ -456,7 +455,7 @@ static void __handle_callchain(u64 * array, struct sample_data * data) if (data->callchain->nr) { if (cverb << vconvert) cout << "Processing callchain" << endl; - for (int i = 0; i < data->callchain->nr; i++) { + for (u64 i = 0; i < data->callchain->nr; i++) { data->ip = data->callchain->ips[i]; if (data->ip >= PERF_CONTEXT_MAX) { switch (data->ip) { @@ -488,6 +487,7 @@ static void __handle_callchain(u64 * array, struct sample_data * data) } } +#if PPC64_ARCH static void __map_hypervisor_sample(u64 ip, u32 pid) { operf_process_info * proc; @@ -504,7 +504,7 @@ static void __map_hypervisor_sample(u64 ip, u32 pid) */ const char * appname_arg; bool is_complete_appname; - if (app_name && (app_PID == pid)) { + if (app_name && (app_PID == (pid_t)pid)) { appname_arg = app_name; is_complete_appname = true; } else { @@ -524,8 +524,9 @@ static void __map_hypervisor_sample(u64 ip, u32 pid) } proc->process_hypervisor_mapping(ip); } +#endif -static int __handle_throttle_event(event_t * event, u64 sample_type) +static int __handle_throttle_event(event_t * event) { int rc = 0; trans.event = operfRead.get_eventnum_by_perf_event_id(event->throttle.id); @@ -542,7 +543,6 @@ static int __handle_sample_event(event_t * event, u64 sample_type) bool found_trans = false; bool in_kernel; int rc = 0; - const struct operf_mmap * op_mmap = NULL; bool hypervisor = (event->header.misc == PERF_RECORD_MISC_HYPERVISOR); u64 *array = event->sample.array; @@ -785,7 +785,7 @@ int OP_perf_utils::op_write_event(event_t * event, u64 sample_type) __handle_fork_event(event); return 0; case PERF_RECORD_THROTTLE: - return __handle_throttle_event(event, sample_type); + return __handle_throttle_event(event); case PERF_RECORD_LOST: operf_stats[OPERF_RECORD_LOST_SAMPLE] += event->lost.lost; return 0; @@ -1130,9 +1130,6 @@ int OP_perf_utils::op_get_process_info(bool system_wide, pid_t pid, operf_record if (!system_wide) { ret = _get_one_process_info(system_wide, pid, pr); } else { - char buff[BUFSIZ]; - pid_t tgid = 0; - size_t size = 0; DIR *pids; struct dirent dirent, *next; @@ -1145,11 +1142,8 @@ int OP_perf_utils::op_get_process_info(bool system_wide, pid_t pid, operf_record while (!readdir_r(pids, &dirent, &next) && next) { char *end; pid = strtol(dirent.d_name, &end, 10); - if (((errno == ERANGE && (pid == LONG_MAX || pid == LONG_MIN)) - || (errno != 0 && pid == 0)) || (end == dirent.d_name)) { - cverb << vmisc << "/proc entry " << dirent.d_name << " is not a PID" << endl; + if (*end) continue; - } if ((ret = _get_one_process_info(system_wide, pid, pr)) < 0) break; } @@ -1171,7 +1165,6 @@ static void _record_module_info(int output_fd, operf_record * pr) const char * fname = "/proc/modules"; FILE *fp; char * line; - struct operf_kernel_image * image; int module_size; char ref_count[32+1]; int ret; -- 1.7.1 |