aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajagopal Venkat <rajagopal.venkat@linaro.org>2012-09-14 16:57:41 +0530
committerRajagopal Venkat <rajagopal.venkat@linaro.org>2012-12-07 20:02:25 +0530
commit49ada948defeeb33d035e343377ed5447e87ee3e (patch)
treebfef43dc9aaaa9f05354fad3362b8da5d4acae61
parent134a67c1051e9c640ccbc396665a9a875f93defd (diff)
downloadpowertop-2.0-v2-49ada948defeeb33d035e343377ed5447e87ee3e.tar.gz
Updates to support Android platform
This patch adds following minor changes to prepare powertop to support Android platform. - Add missing HAVE_CONFIG_H conditional check. - remove un-used ethtool_cmd_speed_set and ethtool_cmd_speed functions. - Minimize dependency on exception handling in catch blocks. These changes will not affect powertop functionality. Signed-off-by: Rajagopal Venkat <rajagopal.venkat@linaro.org>
-rw-r--r--src/devices/ahci.cpp4
-rw-r--r--src/devices/alsa.cpp4
-rw-r--r--src/devices/network.cpp16
-rw-r--r--src/lib.cpp2
-rw-r--r--src/main.cpp2
-rw-r--r--src/process/do_process.cpp4
6 files changed, 9 insertions, 23 deletions
diff --git a/src/devices/ahci.cpp b/src/devices/ahci.cpp
index 1fe39c7..67ce06e 100644
--- a/src/devices/ahci.cpp
+++ b/src/devices/ahci.cpp
@@ -170,7 +170,7 @@ void ahci::start_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to start measurement for ahci device\n");
}
}
@@ -203,7 +203,7 @@ void ahci::end_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to end measurement for ahci device\n");
}
if (end_active < start_active)
end_active = start_active;
diff --git a/src/devices/alsa.cpp b/src/devices/alsa.cpp
index 4f5d3f9..a67780c 100644
--- a/src/devices/alsa.cpp
+++ b/src/devices/alsa.cpp
@@ -104,7 +104,7 @@ void alsa::start_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to start measurement for alsa device\n");
}
}
@@ -130,7 +130,7 @@ void alsa::end_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to end measurement for alsa device\n");
}
p = (end_active - start_active) / (0.001 + end_active + end_inactive - start_active - start_inactive) * 100.0;
diff --git a/src/devices/network.cpp b/src/devices/network.cpp
index 3b67610..9d20c5c 100644
--- a/src/devices/network.cpp
+++ b/src/devices/network.cpp
@@ -55,22 +55,6 @@ extern "C" {
static map<string, class network *> nics;
-#ifdef DISABLE_TRYCATCH
-
-static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
- __u32 speed)
-{
-
- ep->speed = (__u16)speed;
- ep->speed_hi = (__u16)(speed >> 16);
-}
-
-static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
-{
- return (ep->speed_hi << 16) | ep->speed;
-}
-
-#endif
static void do_proc_net_dev(void)
{
diff --git a/src/lib.cpp b/src/lib.cpp
index 9838c0b..776a67b 100644
--- a/src/lib.cpp
+++ b/src/lib.cpp
@@ -259,7 +259,7 @@ void format_watts(double W, char *buffer, unsigned int len)
if (W < 0.0001)
sprintf(buffer, _(" 0 mW"));
- while (mbstowcs(NULL,buffer,0) < len)
+ while (mbstowcs(NULL,buffer,len) < len)
strcat(buffer, " ");
}
diff --git a/src/main.cpp b/src/main.cpp
index e6036ae..02ffb99 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -42,7 +42,9 @@
#include "perf/perf.h"
#include "perf/perf_bundle.h"
#include "lib.h"
+#ifdef HAVE_CONFIG_H
#include "../config.h"
+#endif
#include "devices/device.h"
diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
index 8f73083..c81b0f6 100644
--- a/src/process/do_process.cpp
+++ b/src/process/do_process.cpp
@@ -870,7 +870,7 @@ void process_update_display(void)
if (!show_power)
strcpy(power, " ");
sprintf(name, "%s", all_power[i]->type());
- while (mbstowcs(NULL,name,0) < 14) strcat(name, " ");
+ while (mbstowcs(NULL,name,20) < 14) strcat(name, " ");
if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0)
@@ -883,7 +883,7 @@ void process_update_display(void)
else
sprintf(usage, "%5i%s", (int)all_power[i]->usage(), all_power[i]->usage_units());
}
- while (mbstowcs(NULL,usage,0) < 14) strcat(usage, " ");
+ while (mbstowcs(NULL,usage,20) < 14) strcat(usage, " ");
sprintf(events, "%5.1f", all_power[i]->events());
if (!all_power[i]->show_events())
events[0] = 0;