aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <dbphillipsnz@gmail.com>2015-09-01 17:31:09 +1200
committerDavid Phillips <dbphillipsnz@gmail.com>2015-09-01 17:31:09 +1200
commitb6338e7753d0862276d7ed38eab2a19d8b6544b6 (patch)
tree15ff198faf468bab10e351cd7c59d7bb3f06c8a4
parent956a6261ebfdf8fb3346b8935d0ec59c1c26df7c (diff)
downloadparamano-b6338e7753d0862276d7ed38eab2a19d8b6544b6.tar.xz
Removed old debug swarf
-rw-r--r--bat_tray.c27
-rw-r--r--common.c1
-rw-r--r--common.h11
-rw-r--r--config_file.c6
-rw-r--r--getcore.c3
-rw-r--r--getfreq.c12
-rw-r--r--getgov.c2
-rw-r--r--paramano.c16
-rw-r--r--paramano_set.c23
-rw-r--r--reload.c3
-rw-r--r--tray.c33
11 files changed, 2 insertions, 135 deletions
diff --git a/bat_tray.c b/bat_tray.c
index 36b08ae..3480a75 100644
--- a/bat_tray.c
+++ b/bat_tray.c
@@ -70,11 +70,9 @@ long get_bat_seconds_left()
/* Energy units or charge units */
if (now >= 0)
{
- debug("Energy units");
full = get_int_value_from_filef(POWERDIR"BAT%d/energy_full", bat_num);
rate = get_int_value_from_filef(POWERDIR"BAT%d/power_now", bat_num);
} else {
- debug("Charge units");
full = get_int_value_from_filef(POWERDIR"BAT%d/charge_full", bat_num);
now = get_int_value_from_filef(POWERDIR"BAT%d/charge_now", bat_num);
rate = get_int_value_from_filef(POWERDIR"BAT%d/current_now", bat_num);
@@ -131,26 +129,21 @@ static void update_tooltip_cache()
switch(get_battery_state())
{
case STATE_DISCHARGING:
- debug("Discharging\n");
asprintf(&msg, _("Discharging (%d%%)\n%s"), get_bat_percent(), time_left);
break;
case STATE_CHARGING:
- debug("Charging\n");
asprintf(&msg, _("Charging (%d%%)\n%s"), get_bat_percent(), time_left);
break;
case STATE_CHARGED:
- debug("Charged\n");
asprintf(&msg, _("Fully charged") );
break;
default:
- debug("Unknown\n");
asprintf(&msg, _("Unknown status") );
break;
}
- debug("Setting cached tooltip text to '%s'\n",msg);
strncpy(tooltip_text, msg, sizeof(tooltip_text));
free(time_left);
@@ -169,8 +162,6 @@ static gboolean update()
rounded = 20* (int)((get_bat_percent()+10)/20); // Round percentage to 0, 20, 40, 60, 80 or 100
- debug("Rounded/adjusted percentage: %d\n",rounded);
-
switch ( get_battery_state() )
{
case STATE_DISCHARGING:
@@ -188,7 +179,6 @@ static gboolean update()
update_tooltip_cache();
- debug("Setting tray icon to '%s'\n",icon_file);
gtk_status_icon_set_from_file(tray, icon_file);
free(icon_file);
@@ -211,7 +201,6 @@ void bat_tray_init()
asprintf(&CHARGE_VALUE_PATH, "/sys/class/power_supply/BAT%d/capacity", bat_num);
asprintf(&CHARGE_STATE_PATH, "/sys/class/power_supply/BAT%d/status", bat_num);
- debug("Spawning new status icon\n");
tray = gtk_status_icon_new();
asprintf(&icon_file,"%s/bat-charged.png",DEFAULT_THEME);
gtk_status_icon_set_from_file(tray, icon_file);
@@ -241,7 +230,6 @@ void bat_tray_end()
**********************************************************************/
void bat_tray_show()
{
- debug("Showing tray\n");
gtk_status_icon_set_visible(tray, TRUE);
}
@@ -251,7 +239,6 @@ void bat_tray_show()
**********************************************************************/
void bat_tray_hide()
{
- debug("Hiding tray\n");
gtk_status_icon_set_visible(tray, FALSE);
}
@@ -273,23 +260,14 @@ int get_battery_state()
chomp(state);
if (strcmp(state, "Discharging") == 0)
- {
- debug("Battery discharging\n");
return STATE_DISCHARGING;
- }
if (strcmp(state, "Full") == 0)
- {
- debug("Battery full\n");
return STATE_CHARGED;
- }
if (strcmp(state, "Charging") == 0)
- {
- debug("Battery charging\n");
return STATE_CHARGING;
- }
- debug("Fallthrough: unknown status\n");
+
return STATE_UNKNOWN;
}
@@ -308,10 +286,8 @@ int get_bat_num()
asprintf(&file, "/sys/class/power_supply/BAT%d/present", i);
if( (fd = fopen(file, "r")) )
{
- debug("Found battery %d\n",i);
if (fgetc(fd) == '1')
{
- debug("Battery %d is present\n",i);
fclose(fd);
free(file);
return i;
@@ -319,7 +295,6 @@ int get_bat_num()
fclose(fd);
}
}
- debug("Fallthrough: couldn't find battery\n");
free(file);
return -1;
}
diff --git a/common.c b/common.c
index ecff03c..b7e661f 100644
--- a/common.c
+++ b/common.c
@@ -88,7 +88,6 @@ int get_int(const char* string)
char* first_num;
first_num = strpbrk(string, "0123456789");
- debug("first_num: '%s'\n",first_num);
return atoi(first_num);
}
diff --git a/common.h b/common.h
index 10deb14..24f9dd6 100644
--- a/common.h
+++ b/common.h
@@ -33,17 +33,6 @@ int get_int(const char* string);
#define STR_LINE STRING(__LINE__)
// </ew>
-
-#ifdef DEBUG
-/*
- Make debug macros into empty space if debug mode's not enabled.
- Otherwise, make debug macro calls into appropriate printf()s
-*/
- #define debug(...) printf("DEBUG: "__FILE__":"STR_LINE" --- "__VA_ARGS__)
-#else
- #define debug(...);
-#endif
-
#define info(...) printf("INFO: "__FILE__":"STR_LINE" --- "__VA_ARGS__)
#define FILE_PATH_SIZE 2048
#endif
diff --git a/config_file.c b/config_file.c
index b085c4c..2faeaa3 100644
--- a/config_file.c
+++ b/config_file.c
@@ -21,25 +21,19 @@
gboolean config_open(struct config_file* config_file)
{
if(config_file->key_file)
- {
- debug("Freeing config_file->keyfile\n");
g_key_file_free(config_file->key_file);
- }
- debug("Creating new config_file->key_file\n");
config_file->key_file = g_key_file_new();
gboolean success = g_key_file_load_from_file(
config_file->key_file,
config_file->file_name,
G_KEY_FILE_NONE,
NULL);
- debug("Returning %s\n",success? "TRUE" : "FALSE");
return success;
}
void config_close(struct config_file* config_file)
{
- debug("Freeing key_file with %s value\n",config_file->key_file == NULL? "NULL":"non-NULL");
g_key_file_free(config_file->key_file);
}
diff --git a/getcore.c b/getcore.c
index 9fb9600..2624c34 100644
--- a/getcore.c
+++ b/getcore.c
@@ -29,7 +29,6 @@ bool core_exists(unsigned int core)
char* path;
int result;
asprintf(&path, "/sys/devices/system/cpu/cpu%d/cpufreq", core);
- debug("Checking if core %d exists by opening '%s'\n",core,path);
result = access(path, F_OK);
free (path);
return (result != -1);
@@ -44,8 +43,6 @@ void gc_init()
cores = 0;
while(core_exists(cores))
cores++;
-
- debug("Found %d cores\n",cores);
}
diff --git a/getfreq.c b/getfreq.c
index f5f9652..c5a92bc 100644
--- a/getfreq.c
+++ b/getfreq.c
@@ -44,10 +44,7 @@ void gf_init()
// Get available governor freqs. If no governor, try next cpu
if (gf_available(i, freq_string, sizeof(freq_string) ) == -1)
- {
- debug("Couldn't find freq scaling on core %d\n",i);
continue;
- }
*strchrnul(freq_string, '\n') = '\0';
@@ -57,8 +54,6 @@ void gf_init()
total_freqs = 0;
do
{
- //chomp(next_token);
- debug("Found frequency #%d (%s KHz)\n",total_freqs,next_token);
strncpy(freqs[i][total_freqs], next_token, FREQ_LENGTH);
total_freqs++;
} while((next_token = strtok(NULL, " ")) != NULL);
@@ -67,8 +62,6 @@ void gf_init()
// Hit the limit of storage of cores' frequencies
if (i == MAX_CORES)
info("Unable to add more than %d cores\n", MAX_CORES);
-
- debug("Found %d frequencies\n",total_freqs);
}
/***********************************************************************
@@ -85,7 +78,6 @@ int gf_current(int core)
if(!(fd = fopen(path, "r")))
{
- debug("Couldn't open '%s'\n",path);
free(path);
return -1;
}
@@ -94,7 +86,6 @@ int gf_current(int core)
freq = atoi(buff);
fclose(fd);
- debug("Found freq %d on core %d\n",freq,core);
free(path);
return freq;
@@ -113,7 +104,6 @@ int gf_available(int core, char* out, int size)
if(!(fd = fopen(path, "r")))
{
- debug("Couldn't open '%s'\n",path);
free(path);
return -1;
}
@@ -140,8 +130,6 @@ char* gf_get_frequency_label(int freq)
else // < 1000 KHz (1 MHz)
asprintf(&string, "%.2f KHz", (double)freq);
- debug("Prepared freq label '%s' for freq %d\n",string,freq);
-
return string;
}
diff --git a/getgov.c b/getgov.c
index df648a4..68732a8 100644
--- a/getgov.c
+++ b/getgov.c
@@ -72,8 +72,6 @@ bool gg_current(int core, char* out, int size)
gchar* newline = g_strrstr(out, "\n");
*newline = '\0';
- debug("Current gov for core %d is '%s'\n",core,out);
-
fclose(fd);
free(path);
return true;
diff --git a/paramano.c b/paramano.c
index 19a4e14..e965e68 100644
--- a/paramano.c
+++ b/paramano.c
@@ -27,11 +27,9 @@ int main(int argc, char** argv)
setlocale(LC_ALL, "");
bindtextdomain("paramano",LOCALEDIR);
textdomain("paramano");
- debug("Set gettext up\n");
if(!gtk_init_check(&argc, &argv))
{
- debug("Couldn't start gtk\n");
g_error( _("GTK Error: gtk_init_check returned FALSE.\nBailing.") );
return 1;
}
@@ -41,10 +39,7 @@ int main(int argc, char** argv)
sig_act.sa_flags = 0;
sigemptyset(&sig_act.sa_mask);
- if (sigaction(SIGUSR1, &sig_act, NULL) == -1)
- {
- debug("Couldn't set sigaction for SIGUSR1\n");
- }
+ sigaction(SIGUSR1, &sig_act, NULL);
config_init();
gc_init();
gg_init();
@@ -55,15 +50,11 @@ int main(int argc, char** argv)
// Show battery tray only if we're supposed to
if(DEFAULT_SHOW_BATTERY)
{
- debug("Showing battery info this time around\n");
bat_tray_init();
bat_tray_show();
}
- debug("Passing control to Gtk\n");
-
gtk_main();
- debug("Exiting main()\n");
return 0;
}
@@ -85,12 +76,10 @@ void config_init()
if( (fd = fopen(config.file_name, "r")) )
{
// If file exists, close it, set param to TRUE
- debug("Found '%s'\n",config.file_name);
fclose(fd);
home_config_exists = TRUE;
} else {
// If file didn't exist, it's not open (don't close it), free filename var, set param to FALSE
- debug("Didn't find '%s'\n",config.file_name);
g_free(config.file_name);
home_config_exists = FALSE;
}
@@ -101,7 +90,6 @@ void config_init()
gboolean success = config_open(&config);
if(!success)
{
- debug("Couldn't open '%s' for reading\n",config.file_name);
g_warning(_("Failed to open config files!\n"));
return;
}
@@ -123,8 +111,6 @@ void config_init()
if ((temp = config_get_key(&config, "extra", "theme")))
asprintf(&DEFAULT_THEME, "%s", temp);
- debug("Using theme %s\n",DEFAULT_THEME);
-
g_free(config.file_name);
config_close(&config);
}
diff --git a/paramano_set.c b/paramano_set.c
index 3bfbbbc..9bcbbff 100644
--- a/paramano_set.c
+++ b/paramano_set.c
@@ -43,7 +43,6 @@ char write_str_to_file(const char *file, const char *data, const char *core)
// Try to open file and write data to it
if ( (fd = fopen(file_path, "w")) != NULL )
{
- debug("Writing '%s' to '%s'\n",data,file_path);
fputs(data, fd);
fclose(fd);
return 1;
@@ -73,7 +72,6 @@ void get_argument_summary(int argc, char **argv, argument_summary *argsum)
if ( strcmp(argv[arg], "-c") == 0 )
{
// Found -c with an arg
- debug("Found -c with arg '%s'\n",argv[arg+1]);
argsum->present |= ARG_CORE;
argsum->core = (char*)(argv[arg+1]);
continue;
@@ -82,7 +80,6 @@ void get_argument_summary(int argc, char **argv, argument_summary *argsum)
if ( strcmp(argv[arg], "-f") == 0 )
{
// Found -f with an arg
- debug("Found -f with arg '%s'\n",argv[arg+1]);
argsum->present |= ARG_FREQ;
argsum->frequency = (char*)(argv[arg+1]);
continue;
@@ -91,7 +88,6 @@ void get_argument_summary(int argc, char **argv, argument_summary *argsum)
if ( strcmp(argv[arg], "-g") == 0 )
{
// Found -g with an arg
- debug("Found -g with arg '%s'\n",argv[arg+1]);
argsum->present |= ARG_GOV;
argsum->governor = (char*)(argv[arg+1]);
//continue;
@@ -106,43 +102,24 @@ int main(int argc, char *argv[])
bindtextdomain("paramano",LOCALEDIR);
textdomain("paramano");
- debug("Set gettext up\n");
-
argument_summary args;
memset(&args, 0, sizeof(args));
// If unusual number of args, give up now
if (argc == 5)
{
-
- debug ("Checking UID\n");
if (getuid() != 0)
fprintf(stderr,"Warning: running as UID %d, not 0\n",getuid() );
get_argument_summary(argc, argv, &args);
- debug("Correct number of command line arguments\n");
- debug("-c: %s -g: %s -f: %s\n", (args.present & ARG_CORE )? "Yes":"No",
- (args.present & ARG_GOV )? "Yes":"No",
- (args.present & ARG_FREQ )? "Yes":"No" );
- debug("Core: %s\n",args.core);
- debug("Gov : %s\n",args.governor);
- debug("Freq: %s\n",args.frequency);
-
if ( args.present == ( ARG_CORE | ARG_GOV ) )
- {
- debug("Changing governor\n");
return set_gov(args.governor , args.core);
- }
if ( args.present == ( ARG_CORE | ARG_FREQ ) )
- {
- debug("Changing frequency\n");
return set_gov("userspace", args.core) | set_speed(args.frequency, args.core);
- }
}
// Fall through to here if no valid argument combination
- debug("Fell through, showing command usage\n");
fprintf(stderr, _("%s {-f frequency|-g governor} -c core\n"), argv[0] );
return 1;
}
diff --git a/reload.c b/reload.c
index 83a99cc..07daf33 100644
--- a/reload.c
+++ b/reload.c
@@ -25,8 +25,6 @@
************************************************************************/
void reload_config()
{
- debug("Reloading config\n");
-
// Reload config
config_init();
@@ -34,6 +32,5 @@ void reload_config()
DEFAULT_SHOW_BATTERY? bat_tray_show() : bat_tray_hide();
// Update governor and frequency defaults
- debug("Re-init freq tray\n");
tray_set_defaults();
}
diff --git a/tray.c b/tray.c
index 1e58812..899069f 100644
--- a/tray.c
+++ b/tray.c
@@ -31,7 +31,6 @@ static GtkWidget* checked_menu_item;
**********************************************************************/
static void freq_menu_item_toggled(GtkCheckMenuItem* item, gpointer data)
{
- debug("[checking in]\n");
if(gtk_check_menu_item_get_active(item))
{
checked_menu_item = GTK_WIDGET(item);
@@ -48,7 +47,6 @@ static void freq_menu_item_toggled(GtkCheckMenuItem* item, gpointer data)
**********************************************************************/
static void gov_menu_item_toggled(GtkCheckMenuItem* item, gpointer data)
{
- debug("[checking in]\n");
if(gtk_check_menu_item_get_active(item))
{
checked_menu_item = GTK_WIDGET(item);
@@ -64,7 +62,6 @@ static void gov_menu_item_toggled(GtkCheckMenuItem* item, gpointer data)
**********************************************************************/
static void remove_menu_item(GtkWidget* menu_item, gpointer data)
{
- debug("Destroying menu_item\n");
gtk_widget_destroy(menu_item);
}
@@ -74,7 +71,6 @@ static void remove_menu_item(GtkWidget* menu_item, gpointer data)
**********************************************************************/
static void tray_clear_menu()
{
- debug("Clearing the menu\n");
GtkContainer* cont = GTK_CONTAINER(menu);
gtk_container_foreach(cont, remove_menu_item, NULL);
menu_items = NULL;
@@ -86,7 +82,6 @@ static void tray_clear_menu()
**********************************************************************/
static void tray_init_menu()
{
- debug("Spawning new menu");
menu = gtk_menu_new();
}
@@ -111,7 +106,6 @@ static void tray_generate_menu()
for(i = 0; i < gf_number(); i++)
{
label = gf_get_frequency_label(gf_freqi(0, i));
- debug("Got freq label '%s', i=%d\n",label,i);
GtkWidget* item = gtk_radio_menu_item_new_with_label(menu_items, label);
@@ -120,20 +114,14 @@ static void tray_generate_menu()
menu_items = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM (item));
if(g_strcmp0(current_governor, "userspace") == 0 && gf_freqi(0, i) == current_frequency)
- {
- debug("This freq is current freq, ticking radio button\n");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
- }
- debug("Setting connection/callback\n");
g_signal_connect(G_OBJECT(item), "toggled", GTK_SIGNAL_FUNC(freq_menu_item_toggled), GINT_TO_POINTER(gf_freqi(0, i)));
- debug("Adding item to menu\n");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
}
// Add a seperator
- debug("Adding separator\n");
GtkWidget* seperator = gtk_separator_menu_item_new();
gtk_menu_append(menu, seperator);
@@ -141,27 +129,18 @@ static void tray_generate_menu()
for(i = 0; i < gg_number(); i++)
{
if(g_strcmp0(gg_gov(0, i), "userspace") == 0)
- {
- debug("Gov is userspace, not adding\n");
continue;
- }
GtkWidget* item = gtk_radio_menu_item_new_with_label(menu_items, gg_gov(0, i));
menu_items = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM (item));
if(g_strcmp0(gg_gov(0, i), current_governor) == 0)
- {
- debug("Governor is current one, ticking radio button\n");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
- }
- debug("Adding callback");
g_signal_connect(G_OBJECT(item), "toggled", GTK_SIGNAL_FUNC(gov_menu_item_toggled), gg_gov(0, i));
- debug("Adding item to menu\n");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
}
- debug("Showing menu\n");
gtk_widget_show_all(menu);
}
@@ -192,7 +171,6 @@ static void update_tooltip_cache()
for(i = 0; i < gc_number(); i++)
{
- debug("Adding CPU%d's frequency\n",i);
label = gf_get_frequency_label(gf_current(i));
asprintf(&msg, _("%sCPU%d: %s%s"), msg, i, label, i == gc_number()-1 ? "" : "\n");
free(label);
@@ -210,7 +188,6 @@ static void update_tooltip_cache()
**********************************************************************/
static void popup_menu(GtkStatusIcon* statuc_icon,guint button,guint activate_time,gpointer data)
{
- debug("Spawning popup menu\n");
tray_generate_menu();
gtk_menu_popup(GTK_MENU(menu),NULL,NULL,gtk_status_icon_position_menu,tray,button,activate_time);
}
@@ -247,9 +224,7 @@ static void update_icon()
}
}
- debug("Rounded/adjusted CPU percentage: %d / %d = %d\n",gf_current(0), max_frequency, adjusted_percent);
asprintf(&file, "%s/cpu-%d.png", DEFAULT_THEME,adjusted_percent);
- debug("Setting tray icon to '%s'\n",file);
gtk_status_icon_set_from_file(tray, file);
free(file);
@@ -266,7 +241,6 @@ static gboolean update()
switch ( get_battery_state() )
{
case STATE_DISCHARGING:
- debug("Discharging\n");
if(DEFAULT_BAT_GOV)
{
for(i = 0; i < gc_number(); i++)
@@ -276,7 +250,6 @@ static gboolean update()
case STATE_CHARGING:
case STATE_FULL:
- debug("Charging/Full\n");
if(DEFAULT_AC_GOV)
{
for(i = 0; i < gc_number(); i++)
@@ -286,7 +259,6 @@ static gboolean update()
break;
}
- debug("Updating icon\n");
update_tooltip_cache();
update_icon();
return true;
@@ -331,15 +303,12 @@ void tray_init()
/* Force something useful to be in the cached tooltip text */
update_tooltip_cache();
- debug("Setting icon to '%s'\n",icon_file);
gtk_status_icon_set_from_file(tray, icon_file);
gtk_status_icon_set_has_tooltip(tray, TRUE);
- debug("Setting up callbacks\n");
g_signal_connect(G_OBJECT(tray), "query-tooltip", GTK_SIGNAL_FUNC(show_tooltip), NULL);
g_signal_connect(G_OBJECT(tray), "popup-menu", GTK_SIGNAL_FUNC(popup_menu), NULL);
- debug("Adding timeout\n");
g_timeout_add(1000, update, NULL);
/* Force meaningful tooltip cached text and force meaningful icon */
@@ -354,7 +323,6 @@ void tray_init()
**********************************************************************/
void tray_show()
{
- debug("Showing tray\n");
gtk_status_icon_set_visible(tray, TRUE);
}
@@ -363,7 +331,6 @@ void tray_show()
**********************************************************************/
void tray_hide()
{
- debug("Hiding tray");
gtk_status_icon_set_visible(tray, FALSE);
}