The changes to opd_ibs_trans.c looks fine.

 

Thanks,

 

Suravee

 

From: Maynard Johnson [mailto:maynardj@us.ibm.com]
Sent: Friday, October 21, 2011 1:55 PM
To: oprofile-list; Suthikulpanit, Suravee; Andi Kleen
Subject: [PATCH] oprofile build has many warning messages with gcc 4.6.1

 

While looking into a different problem on Fedora 16 (recently reported by Will Cohen), I found that oprofile does not build cleanly with gcc 4.6.1. Building a checkout from our git repo causes warnings to be turned into errors, so the build actually fails. All of the warning messages were of the type:
       "variable <xyz> set but not used"

Patch is attached below.

*Suravee*, please review the changes to your "ibs"-related files.

*Andi*, please review the changes to libop/op_events.c

Thanks.
-Maynard

diff -paurX ../diff_fileExclusionFilter oprofile/daemon/opd_ibs_trans.c op-F16-build-fixes/daemon/opd_ibs_trans.c
--- oprofile/daemon/opd_ibs_trans.c   2011-06-20 10:08:47.000000000 -0500
+++ op-F16-build-fixes/daemon/opd_ibs_trans.c 2011-10-21 12:43:11.000000000 -0500
@@ -565,9 +565,6 @@ void trans_ibs_op_bta(struct transient *
 {
        static cookie_t old_cookie     = NO_COOKIE;
        static cookie_t old_app_cookie = NO_COOKIE;
-       static char const * mod        = NULL;
-       static char const * app        = NULL;
-       const char vmlinux[10]         = "vmlinux";
        struct ibs_op_sample * trans_op = ((struct ibs_sample*)(trans->ext))->op;
 
        if (!bta_log)
@@ -579,18 +576,15 @@ void trans_ibs_op_bta(struct transient *
        if( old_app_cookie == INVALID_COOKIE 
        ||  old_app_cookie == NO_COOKIE 
        ||  old_app_cookie != trans->app_cookie) {
-              app = find_cookie(trans->app_cookie);
               old_app_cookie = trans->cookie;
        }
 
        if (trans->in_kernel == 1) {
-              mod = vmlinux;
               old_cookie = NO_COOKIE;
        } else {
               if( old_cookie == INVALID_COOKIE 
               ||  old_cookie == NO_COOKIE 
               ||  old_cookie != trans->cookie) {
-                      mod = find_cookie(trans->cookie);
                       old_cookie = trans->cookie;
               }
        }
@@ -605,9 +599,6 @@ void trans_ibs_op_ls_memaccess(struct tr
 {
        static cookie_t old_cookie     = NO_COOKIE;
        static cookie_t old_app_cookie = NO_COOKIE;
-       static char const * mod        = NULL;
-       static char const * app        = NULL;
-       const char vmlinux[10]         = "vmlinux";
        struct ibs_op_sample * trans_op = ((struct ibs_sample*)(trans->ext))->op;
 
        if (!memaccess_log)
@@ -616,18 +607,15 @@ void trans_ibs_op_ls_memaccess(struct tr
        if( old_app_cookie == INVALID_COOKIE 
        ||  old_app_cookie == NO_COOKIE 
        ||  old_app_cookie != trans->app_cookie) {
-              app = find_cookie(trans->app_cookie);
               old_app_cookie = trans->cookie;
        }
 
        if (trans->in_kernel == 1) {
-              mod = vmlinux;
               old_cookie = NO_COOKIE;
        } else {
               if( old_cookie == INVALID_COOKIE 
               ||  old_cookie == NO_COOKIE 
               ||  old_cookie != trans->cookie) {
-                      mod = find_cookie(trans->cookie);
                       old_cookie = trans->cookie;
               }
        }
diff -paurX ../diff_fileExclusionFilter oprofile/libop/op_events.c op-F16-build-fixes/libop/op_events.c
--- oprofile/libop/op_events.c 2011-10-19 11:00:59.000000000 -0500
+++ op-F16-build-fixes/libop/op_events.c      2011-10-21 12:43:10.000000000 -0500
@@ -1193,17 +1193,10 @@ static void do_resolve_unit_mask(struct 
 
        for (;;) {
               if (pe->unit_mask_name == NULL) {
-                      int fi = 0;
-                      unsigned um = pe->unit_mask;
                       int had_unit_mask = pe->unit_mask_valid;
 
                       found = 0;
                       for (i = 0; i < e->unit->num; i++) {
-                              if (pe->unit_mask_valid &&
-                                  e->unit->um[i].value == um) {
-                                     if (found++ == 0)
-                                             fi = i;
-                              }
                               if (!pe->unit_mask_valid &&
                               e->unit->um[i].value == e->unit->default_mask) {
                                      pe->unit_mask_valid = 1;
diff -paurX ../diff_fileExclusionFilter oprofile/libop/op_xml_events.c op-F16-build-fixes/libop/op_xml_events.c
--- oprofile/libop/op_xml_events.c    2011-06-20 10:08:47.000000000 -0500
+++ op-F16-build-fixes/libop/op_xml_events.c  2011-10-21 12:43:10.000000000 -0500
@@ -59,7 +59,6 @@ static void xml_do_arch_specific_event_h
 void xml_help_for_event(struct op_event const * event)
 {
        uint i;
-       int nr_counters;
        int has_nested = strcmp(event->unit->name, "zero");
 
        buffer[0] = '\0';
@@ -68,7 +67,6 @@ void xml_help_for_event(struct op_event 
        xml_do_arch_specific_event_help(event, buffer, MAX_BUFFER);
        init_xml_str_attr(HELP_EVENT_DESC, event->desc, buffer, MAX_BUFFER);
 
-       nr_counters = op_get_nr_counters(cpu_type);
        init_xml_int_attr(HELP_COUNTER_MASK, event->counter_mask, buffer,
                         MAX_BUFFER);
        if (event->ext)
diff -paurX ../diff_fileExclusionFilter oprofile/libutil++/child_reader.cpp op-F16-build-fixes/libutil++/child_reader.cpp
--- oprofile/libutil++/child_reader.cpp       2011-06-20 10:08:47.000000000 -0500
+++ op-F16-build-fixes/libutil++/child_reader.cpp    2011-10-21 12:43:10.000000000 -0500
@@ -165,13 +165,11 @@ bool child_reader::getline(string & resu
        result.erase(result.begin(), result.end());
 
        bool ok = true;
-       bool ret = true;
        bool can_stop = false;
        do {
               int temp = end2;
               if (pos1 >= end1) {
                       pos1 = 0;
-                      ret = block_read();
               }
 
               // for efficiency try to copy as much as we can of data
diff -paurX ../diff_fileExclusionFilter oprofile/libutil++/file_manip.cpp op-F16-build-fixes/libutil++/file_manip.cpp
--- oprofile/libutil++/file_manip.cpp 2011-06-20 10:08:47.000000000 -0500
+++ op-F16-build-fixes/libutil++/file_manip.cpp      2011-10-21 12:43:10.000000000 -0500
@@ -32,7 +32,6 @@ using namespace std;
 
 bool copy_file(string const & source, string const & destination)
 {
-       int retval;
        struct stat buf;
        if (stat(source.c_str(), &buf))
                return false;
@@ -56,7 +55,6 @@ bool copy_file(string const & source, st
 
        // ignore error here: a simple user can copy a root.root 744 file
        // but can't chown the copied file to root.
-       retval = chown(destination.c_str(), buf.st_uid, buf.st_gid);
 
        // a scope to ensure out is closed before changing is mtime/atime
        {