|
|
6c26c2 |
diff --git a/src/tuning/bluetooth.cpp b/src/tuning/bluetooth.cpp
|
|
|
6c26c2 |
index e0bdf12..01c673d 100644
|
|
|
6c26c2 |
--- a/src/tuning/bluetooth.cpp
|
|
|
6c26c2 |
+++ b/src/tuning/bluetooth.cpp
|
|
|
6c26c2 |
@@ -46,8 +46,8 @@
|
|
|
6c26c2 |
bt_tunable::bt_tunable(void) : tunable("", 1.0, "Good", "Bad", "Unknown")
|
|
|
6c26c2 |
{
|
|
|
6c26c2 |
sprintf(desc, _("Bluetooth device interface status"));
|
|
|
6c26c2 |
- strcpy(toggle_bad, "/usr/sbin/hciconfig hci0 up &> /dev/null &";;
|
|
|
6c26c2 |
- strcpy(toggle_good, "/usr/sbin/hciconfig hci0 down &> /dev/null");
|
|
|
6c26c2 |
+ toggle_bad = "/usr/sbin/hciconfig hci0 up &> /dev/null &";
|
|
|
6c26c2 |
+ toggle_good = "/usr/sbin/hciconfig hci0 down &> /dev/null";
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
|
|
|
6c26c2 |
@@ -188,9 +188,9 @@ const char *bt_tunable::toggle_script(void)
|
|
|
6c26c2 |
good = good_bad();
|
|
|
6c26c2 |
|
|
|
6c26c2 |
if (good == TUNE_GOOD) {
|
|
|
6c26c2 |
- return toggle_bad;
|
|
|
6c26c2 |
+ return toggle_bad.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
- return toggle_good;
|
|
|
6c26c2 |
+ return toggle_good.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
|
|
|
6c26c2 |
diff --git a/src/tuning/cpufreq.cpp b/src/tuning/cpufreq.cpp
|
|
|
6c26c2 |
index c169e6e..f696c89 100644
|
|
|
6c26c2 |
--- a/src/tuning/cpufreq.cpp
|
|
|
6c26c2 |
+++ b/src/tuning/cpufreq.cpp
|
|
|
6c26c2 |
@@ -189,7 +189,7 @@ const char *cpufreq_tunable::toggle_script(void) {
|
|
|
6c26c2 |
int good;
|
|
|
6c26c2 |
good = good_bad();
|
|
|
6c26c2 |
|
|
|
6c26c2 |
- strcpy(toggle_good, "/sbin/modprobe cpufreq_ondemand > /dev/null 2>&1\n");
|
|
|
6c26c2 |
+ toggle_good = "/sbin/modprobe cpufreq_ondemand > /dev/null 2>&1\n";
|
|
|
6c26c2 |
|
|
|
6c26c2 |
if (good == TUNE_GOOD) {
|
|
|
6c26c2 |
dir = opendir("/sys/devices/system/cpu");
|
|
|
6c26c2 |
@@ -202,12 +202,12 @@ const char *cpufreq_tunable::toggle_script(void) {
|
|
|
6c26c2 |
sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_governor", dirent->d_name);
|
|
|
6c26c2 |
if (stat(filename, &statbuf) == -1)
|
|
|
6c26c2 |
continue;
|
|
|
6c26c2 |
- sprintf(tmp, "echo '%s' > '%s';\n", original, filename);
|
|
|
6c26c2 |
- strcat(toggle_good, tmp);
|
|
|
6c26c2 |
+ snprintf(tmp, 4096, "echo '%s' > '%s';\n", original, filename);
|
|
|
6c26c2 |
+ toggle_good += tmp;
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
closedir(dir);
|
|
|
6c26c2 |
- return toggle_good;
|
|
|
6c26c2 |
+ return toggle_good.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
dir = opendir("/sys/devices/system/cpu");
|
|
|
6c26c2 |
@@ -220,12 +220,12 @@ const char *cpufreq_tunable::toggle_script(void) {
|
|
|
6c26c2 |
sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_governor", dirent->d_name);
|
|
|
6c26c2 |
if (stat(filename, &statbuf) == -1)
|
|
|
6c26c2 |
continue;
|
|
|
6c26c2 |
- sprintf(tmp, "echo 'ondemand' > '%s';\n", filename);
|
|
|
6c26c2 |
- strcat(toggle_good, tmp);
|
|
|
6c26c2 |
+ snprintf(tmp, 4096, "echo 'ondemand' > '%s';\n", filename);
|
|
|
6c26c2 |
+ toggle_good += tmp;
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
closedir(dir);
|
|
|
6c26c2 |
- return toggle_good;
|
|
|
6c26c2 |
+ return toggle_good.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
|
|
|
6c26c2 |
diff --git a/src/tuning/ethernet.cpp b/src/tuning/ethernet.cpp
|
|
|
6c26c2 |
index 3164b31..d5ad8ed 100644
|
|
|
6c26c2 |
--- a/src/tuning/ethernet.cpp
|
|
|
6c26c2 |
+++ b/src/tuning/ethernet.cpp
|
|
|
6c26c2 |
@@ -52,11 +52,13 @@ extern void create_all_nics(callback fn);
|
|
|
6c26c2 |
|
|
|
6c26c2 |
ethernet_tunable::ethernet_tunable(const char *iface) : tunable("", 0.3, _("Good"), _("Bad"), _("Unknown"))
|
|
|
6c26c2 |
{
|
|
|
6c26c2 |
+ char tmp[4096];
|
|
|
6c26c2 |
+
|
|
|
6c26c2 |
memset(interf, 0, sizeof(interf));
|
|
|
6c26c2 |
strncpy(interf, iface, sizeof(interf));
|
|
|
6c26c2 |
sprintf(desc, _("Wake-on-lan status for device %s"), iface);
|
|
|
6c26c2 |
- sprintf(toggle_good, "ethtool -s %s wol d;", iface);
|
|
|
6c26c2 |
-
|
|
|
6c26c2 |
+ snprintf(tmp, 4096, "ethtool -s %s wol d;", iface);
|
|
|
6c26c2 |
+ toggle_good = tmp;
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
|
|
|
6c26c2 |
@@ -137,7 +139,7 @@ const char *ethernet_tunable::toggle_script(void)
|
|
|
6c26c2 |
good = good_bad();
|
|
|
6c26c2 |
|
|
|
6c26c2 |
if (good != TUNE_GOOD) {
|
|
|
6c26c2 |
- return toggle_good;
|
|
|
6c26c2 |
+ return toggle_good.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
return NULL;
|
|
|
6c26c2 |
diff --git a/src/tuning/runtime.cpp b/src/tuning/runtime.cpp
|
|
|
6c26c2 |
index b57d53e..3369976 100644
|
|
|
6c26c2 |
--- a/src/tuning/runtime.cpp
|
|
|
6c26c2 |
+++ b/src/tuning/runtime.cpp
|
|
|
6c26c2 |
@@ -42,6 +42,7 @@ runtime_tunable::runtime_tunable(const char *path, const char *bus, const char *
|
|
|
6c26c2 |
{
|
|
|
6c26c2 |
ifstream file;
|
|
|
6c26c2 |
sprintf(runtime_path, "%s/power/control", path);
|
|
|
6c26c2 |
+ char tmp[4096];
|
|
|
6c26c2 |
|
|
|
6c26c2 |
|
|
|
6c26c2 |
sprintf(desc, _("Runtime PM for %s device %s"), bus, dev);
|
|
|
6c26c2 |
@@ -77,8 +78,10 @@ runtime_tunable::runtime_tunable(const char *path, const char *bus, const char *
|
|
|
6c26c2 |
|
|
|
6c26c2 |
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
- sprintf(toggle_good, "echo 'auto' > '%s';", runtime_path);
|
|
|
6c26c2 |
- sprintf(toggle_bad, "echo 'on' > '%s';", runtime_path);
|
|
|
6c26c2 |
+ snprintf(tmp, 4096, "echo 'auto' > '%s';", runtime_path);
|
|
|
6c26c2 |
+ toggle_good = tmp;
|
|
|
6c26c2 |
+ snprintf(tmp, 4096, "echo 'on' > '%s';", runtime_path);
|
|
|
6c26c2 |
+ toggle_bad = tmp;
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
int runtime_tunable::good_bad(void)
|
|
|
6c26c2 |
@@ -112,10 +115,10 @@ const char *runtime_tunable::toggle_script(void)
|
|
|
6c26c2 |
good = good_bad();
|
|
|
6c26c2 |
|
|
|
6c26c2 |
if (good == TUNE_GOOD) {
|
|
|
6c26c2 |
- return toggle_bad;
|
|
|
6c26c2 |
+ return toggle_bad.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
- return toggle_good;
|
|
|
6c26c2 |
+ return toggle_good.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
|
|
|
6c26c2 |
diff --git a/src/tuning/tunable.h b/src/tuning/tunable.h
|
|
|
6c26c2 |
index 3372378..8f90ee2 100644
|
|
|
6c26c2 |
--- a/src/tuning/tunable.h
|
|
|
6c26c2 |
+++ b/src/tuning/tunable.h
|
|
|
6c26c2 |
@@ -26,6 +26,7 @@
|
|
|
6c26c2 |
#define _INCLUDE_GUARD_TUNABLE_H
|
|
|
6c26c2 |
|
|
|
6c26c2 |
#include <vector>
|
|
|
6c26c2 |
+#include <string>
|
|
|
6c26c2 |
|
|
|
6c26c2 |
#include "../lib.h"
|
|
|
6c26c2 |
|
|
|
6c26c2 |
@@ -43,8 +44,8 @@ class tunable {
|
|
|
6c26c2 |
char bad_string[128];
|
|
|
6c26c2 |
char neutral_string[128];
|
|
|
6c26c2 |
protected:
|
|
|
6c26c2 |
- char toggle_good[4096];
|
|
|
6c26c2 |
- char toggle_bad[4096];
|
|
|
6c26c2 |
+ string toggle_good;
|
|
|
6c26c2 |
+ string toggle_bad;
|
|
|
6c26c2 |
public:
|
|
|
6c26c2 |
char desc[4096];
|
|
|
6c26c2 |
double score;
|
|
|
6c26c2 |
diff --git a/src/tuning/tuningsysfs.cpp b/src/tuning/tuningsysfs.cpp
|
|
|
6c26c2 |
index ec1ca6b..aa4ebd5 100644
|
|
|
6c26c2 |
--- a/src/tuning/tuningsysfs.cpp
|
|
|
6c26c2 |
+++ b/src/tuning/tuningsysfs.cpp
|
|
|
6c26c2 |
@@ -43,11 +43,15 @@
|
|
|
6c26c2 |
|
|
|
6c26c2 |
sysfs_tunable::sysfs_tunable(const char *str, const char *_sysfs_path, const char *_target_content) : tunable(str, 1.0, _("Good"), _("Bad"), _("Unknown"))
|
|
|
6c26c2 |
{
|
|
|
6c26c2 |
+ char tmp[4096];
|
|
|
6c26c2 |
+
|
|
|
6c26c2 |
strcpy(sysfs_path, _sysfs_path);
|
|
|
6c26c2 |
strcpy(target_value, _target_content);
|
|
|
6c26c2 |
bad_value[0] = 0;
|
|
|
6c26c2 |
- sprintf(toggle_good, "echo '%s' > '%s';", target_value, sysfs_path);
|
|
|
6c26c2 |
- sprintf(toggle_bad, "echo '%s' > '%s';", bad_value, sysfs_path);
|
|
|
6c26c2 |
+ snprintf(tmp, 4096, "echo '%s' > '%s';", target_value, sysfs_path);
|
|
|
6c26c2 |
+ toggle_good = tmp;
|
|
|
6c26c2 |
+ snprintf(tmp, 4096, "echo '%s' > '%s';", bad_value, sysfs_path);
|
|
|
6c26c2 |
+ toggle_bad = tmp;
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
int sysfs_tunable::good_bad(void)
|
|
|
6c26c2 |
@@ -92,11 +96,11 @@ const char *sysfs_tunable::toggle_script(void) {
|
|
|
6c26c2 |
|
|
|
6c26c2 |
if (good == TUNE_GOOD) {
|
|
|
6c26c2 |
if (strlen(bad_value) > 0)
|
|
|
6c26c2 |
- return toggle_bad;
|
|
|
6c26c2 |
+ return toggle_bad.c_str();
|
|
|
6c26c2 |
return NULL;
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
- return toggle_good;
|
|
|
6c26c2 |
+ return toggle_good.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
|
|
|
6c26c2 |
diff --git a/src/tuning/tuningusb.cpp b/src/tuning/tuningusb.cpp
|
|
|
6c26c2 |
index 74bbacf..2cd7efe 100644
|
|
|
6c26c2 |
--- a/src/tuning/tuningusb.cpp
|
|
|
6c26c2 |
+++ b/src/tuning/tuningusb.cpp
|
|
|
6c26c2 |
@@ -43,6 +43,7 @@ usb_tunable::usb_tunable(const char *path, const char *name) : tunable("", 0.9,
|
|
|
6c26c2 |
char filename[4096];
|
|
|
6c26c2 |
char vendor[2048];
|
|
|
6c26c2 |
char product[2048];
|
|
|
6c26c2 |
+ char tmp[4096];
|
|
|
6c26c2 |
string str1, str2;
|
|
|
6c26c2 |
sprintf(usb_path, "%s/power/control", path);
|
|
|
6c26c2 |
|
|
|
6c26c2 |
@@ -75,8 +76,10 @@ usb_tunable::usb_tunable(const char *path, const char *name) : tunable("", 0.9,
|
|
|
6c26c2 |
else if (strlen(vendor))
|
|
|
6c26c2 |
sprintf(desc, _("Autosuspend for USB device %s [%s]"), vendor, name);
|
|
|
6c26c2 |
|
|
|
6c26c2 |
- sprintf(toggle_good, "echo 'auto' > '%s';", usb_path);
|
|
|
6c26c2 |
- sprintf(toggle_bad, "echo 'on' > '%s';", usb_path);
|
|
|
6c26c2 |
+ snprintf(tmp, 4096, "echo 'auto' > '%s';", usb_path);
|
|
|
6c26c2 |
+ toggle_good = tmp;
|
|
|
6c26c2 |
+ snprintf(tmp, 4096, "echo 'on' > '%s';", usb_path);
|
|
|
6c26c2 |
+ toggle_bad = tmp;
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
int usb_tunable::good_bad(void)
|
|
|
6c26c2 |
@@ -110,10 +113,10 @@ const char *usb_tunable::toggle_script(void)
|
|
|
6c26c2 |
good = good_bad();
|
|
|
6c26c2 |
|
|
|
6c26c2 |
if (good == TUNE_GOOD) {
|
|
|
6c26c2 |
- return toggle_bad;
|
|
|
6c26c2 |
+ return toggle_bad.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
- return toggle_good;
|
|
|
6c26c2 |
+ return toggle_good.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
void add_usb_tunables(void)
|
|
|
6c26c2 |
diff --git a/src/tuning/wifi.cpp b/src/tuning/wifi.cpp
|
|
|
6c26c2 |
index 77cdfcc..2cc01b8 100644
|
|
|
6c26c2 |
--- a/src/tuning/wifi.cpp
|
|
|
6c26c2 |
+++ b/src/tuning/wifi.cpp
|
|
|
6c26c2 |
@@ -44,11 +44,15 @@ extern "C" {
|
|
|
6c26c2 |
|
|
|
6c26c2 |
wifi_tunable::wifi_tunable(const char *_iface) : tunable("", 1.5, _("Good"), _("Bad"), _("Unknown"))
|
|
|
6c26c2 |
{
|
|
|
6c26c2 |
+ char tmp[4096];
|
|
|
6c26c2 |
+
|
|
|
6c26c2 |
strcpy(iface, _iface);
|
|
|
6c26c2 |
sprintf(desc, _("Wireless Power Saving for interface %s"), iface);
|
|
|
6c26c2 |
|
|
|
6c26c2 |
- sprintf(toggle_good, "iw dev %s set power_save on", iface);
|
|
|
6c26c2 |
- sprintf(toggle_bad, "iw dev %s set power_save off", iface);
|
|
|
6c26c2 |
+ snprintf(tmp, 4096, "iw dev %s set power_save on", iface);
|
|
|
6c26c2 |
+ toggle_good = tmp;
|
|
|
6c26c2 |
+ snprintf(tmp, 4096, "iw dev %s set power_save off", iface);
|
|
|
6c26c2 |
+ toggle_bad = tmp;
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
int wifi_tunable::good_bad(void)
|
|
|
6c26c2 |
@@ -78,10 +82,10 @@ const char *wifi_tunable::toggle_script(void)
|
|
|
6c26c2 |
good = good_bad();
|
|
|
6c26c2 |
|
|
|
6c26c2 |
if (good == TUNE_GOOD) {
|
|
|
6c26c2 |
- return toggle_bad;
|
|
|
6c26c2 |
+ return toggle_bad.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
- return toggle_good;
|
|
|
6c26c2 |
+ return toggle_good.c_str();
|
|
|
6c26c2 |
}
|
|
|
6c26c2 |
|
|
|
6c26c2 |
void add_wifi_tunables(void)
|