diff options
author | David Phillips <dbphillipsnz@gmail.com> | 2015-11-09 23:08:57 +1300 |
---|---|---|
committer | David Phillips <dbphillipsnz@gmail.com> | 2015-11-09 23:08:57 +1300 |
commit | 322feca9dbf0170df6dc197c5e1e1b7211f2bb62 (patch) | |
tree | 4cb98e3b6192f1ac063891ebbc5462adf7ecac46 | |
parent | 319f5675e7337505aafd6ef937d9bb73b9e14831 (diff) | |
download | paramano-322feca9dbf0170df6dc197c5e1e1b7211f2bb62.tar.xz |
Misc style alignment
-rw-r--r-- | common.c | 2 | ||||
-rw-r--r-- | config_file.c | 4 | ||||
-rw-r--r-- | getcore.c | 2 | ||||
-rw-r--r-- | getfreq.c | 12 | ||||
-rw-r--r-- | tray.c | 46 |
5 files changed, 33 insertions, 33 deletions
@@ -58,7 +58,7 @@ int get_int_value_from_file(const char* filename) char buffer[512]; int value = 0; - if(!(fd = fopen(filename, "r"))) + if (!(fd = fopen(filename, "r"))) return -1; if (fgets(buffer, sizeof(buffer), fd)) diff --git a/config_file.c b/config_file.c index d5a3336..9e0b4ae 100644 --- a/config_file.c +++ b/config_file.c @@ -51,7 +51,7 @@ void config_init() if (access(config.file_name, R_OK) == -1) strncpy(config.file_name, PARAMANO_CONF, sizeof(config.file_name)); /* fallback to system-wide */ - if(!config_open(&config)) + if (!config_open(&config)) { g_warning(_("Failed to open config files!\n")); return; @@ -77,7 +77,7 @@ void config_init() gboolean config_open(struct config_file* config_file) { - if(config_file->key_file) + if (config_file->key_file) g_key_file_free(config_file->key_file); config_file->key_file = g_key_file_new(); @@ -43,7 +43,7 @@ bool core_exists(unsigned int core) void gc_init() { cores = 0; - while(core_exists(cores)) + while (core_exists(cores)) cores++; } @@ -44,7 +44,7 @@ void gf_init() memset(freqs, '\0', sizeof(freqs)); - for(i = 0; i < gc_number() && i < MAX_CORES; i++) + for (i = 0; i < gc_number() && i < MAX_CORES; i++) { memset(freq_string, '\0', sizeof(freq_string) ); @@ -62,7 +62,7 @@ void gf_init() { strncpy(freqs[i][total_freqs], next_token, FREQ_LENGTH); total_freqs++; - } while((next_token = strtok(NULL, " ")) != NULL); + } while ((next_token = strtok(NULL, " ")) != NULL); } /* Hit the limit of storage of cores' frequencies */ @@ -82,7 +82,7 @@ int gf_current(int core) snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", core); - if(!(fd = fopen(path, "r"))) + if (!(fd = fopen(path, "r"))) return -1; fgets(buff, 13, fd); /* FIXME magic */ @@ -103,7 +103,7 @@ int gf_available(int core, char* out, int size) snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_available_frequencies", core); - if(!(fd = fopen(path, "r"))) + if (!(fd = fopen(path, "r"))) return -1; fgets(out, size, fd); @@ -116,9 +116,9 @@ int gf_available(int core, char* out, int size) **********************************************************************/ void gf_get_frequency_label(char *buffer, size_t max_size, int freq) { - if(freq >= 1000000000) /* This, ladies and gentlement, is future-proofing */ + if (freq >= 1000000000) /* This, ladies and gentlement, is future-proofing */ snprintf(buffer, max_size, "%.2f THz", (double)freq/1000000000 ); - else if(freq >= 1000000) + else if (freq >= 1000000) snprintf(buffer, max_size, "%.2f GHz", (double)freq/1000000 ); else if (freq >= 1000) snprintf(buffer, max_size, "%.2f MHz", (double)freq/1000 ); @@ -42,12 +42,12 @@ static GtkWidget* checked_menu_item; **********************************************************************/ static void freq_menu_item_toggled(GtkCheckMenuItem* item, gpointer data) { - if(gtk_check_menu_item_get_active(item)) + if (gtk_check_menu_item_get_active(item)) { checked_menu_item = GTK_WIDGET(item); gint freq = GPOINTER_TO_INT(data); unsigned int i = 0; - for(i = 0; i < gc_number(); i++) + for (i = 0; i < gc_number(); i++) si_freq(freq, i); } } @@ -58,12 +58,12 @@ static void freq_menu_item_toggled(GtkCheckMenuItem* item, gpointer data) **********************************************************************/ static void gov_menu_item_toggled(GtkCheckMenuItem* item, gpointer data) { - if(gtk_check_menu_item_get_active(item)) + if (gtk_check_menu_item_get_active(item)) { checked_menu_item = GTK_WIDGET(item); char* gov = (char*)data; unsigned int i = 0; - for(i = 0; i < gc_number(); i++) + for (i = 0; i < gc_number(); i++) si_gov(gov, i); } } @@ -114,7 +114,7 @@ static void tray_generate_menu() gint current_frequency = gf_current(0); /* Add available frequencies */ - for(i = 0; i < gf_number(); i++) + for (i = 0; i < gf_number(); i++) { gf_get_frequency_label(label, sizeof(label), gf_freqi(0, i)); @@ -122,7 +122,7 @@ 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) + if (g_strcmp0(current_governor, "userspace") == 0 && gf_freqi(0, i) == current_frequency) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); g_signal_connect(G_OBJECT(item), "toggled", GTK_SIGNAL_FUNC(freq_menu_item_toggled), GINT_TO_POINTER(gf_freqi(0, i))); @@ -135,15 +135,15 @@ static void tray_generate_menu() gtk_menu_append(menu, seperator); /* Add available governors */ - for(i = 0; i < gg_number(); i++) + for (i = 0; i < gg_number(); i++) { - if(g_strcmp0(gg_gov(0, i), "userspace") == 0) + if (g_strcmp0(gg_gov(0, i), "userspace") == 0) 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) + if (g_strcmp0(gg_gov(0, i), current_governor) == 0) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); g_signal_connect(G_OBJECT(item), "toggled", GTK_SIGNAL_FUNC(gov_menu_item_toggled), gg_gov(0, i)); @@ -179,7 +179,7 @@ static void update_tooltip_cache() offset = snprintf(msg, sizeof(msg), _("Governor: %s\n"), current_governor); - for(i = 0; i < gc_number(); i++) + for (i = 0; i < gc_number(); i++) { gf_get_frequency_label(label, sizeof(label), gf_current(i)); offset += snprintf(msg+offset, sizeof(msg)-offset, _("CPU%d: %s%s"), i, label, i == gc_number()-1 ? "" : "\n"); @@ -218,13 +218,13 @@ static void update_icon() /* Percentages need to be {25,50,75,100}. Round to one of these numbers. * TO DO: round/truncate instead of lots of ifs */ percent = (gf_current(0) * 100)/max_frequency; - if(percent == 100) { + if (percent == 100) { adjusted_percent = 100; - } else if(percent >= 65.5) { + } else if (percent >= 65.5) { adjusted_percent = 75; - } else if(percent >= 37.5) { + } else if (percent >= 37.5) { adjusted_percent = 50; - } else if(percent >= 12.5) { + } else if (percent >= 12.5) { adjusted_percent = 25; } else { adjusted_percent = 0; @@ -246,18 +246,18 @@ static gboolean update() switch ( get_battery_state() ) { case STATE_DISCHARGING: - if(DEFAULT_BAT_GOV) + if (DEFAULT_BAT_GOV) { - for(i = 0; i < gc_number(); i++) + for (i = 0; i < gc_number(); i++) si_gov(DEFAULT_BAT_GOV, i); } break; case STATE_CHARGING: case STATE_FULL: - if(DEFAULT_AC_GOV) + if (DEFAULT_AC_GOV) { - for(i = 0; i < gc_number(); i++) + for (i = 0; i < gc_number(); i++) si_gov(DEFAULT_AC_GOV, i); } @@ -276,19 +276,19 @@ static gboolean update() void tray_set_defaults() { unsigned int i = 0; - if(DEFAULT_GOV) + if (DEFAULT_GOV) { - for(i = 0; i < gc_number(); i++) + for (i = 0; i < gc_number(); i++) si_gov(DEFAULT_GOV, i); } else { - for(i = 0; i < gc_number(); i++) + for (i = 0; i < gc_number(); i++) si_gov("ondemand", i); } - if(DEFAULT_FREQ) + if (DEFAULT_FREQ) { - for(i = 0; i < gc_number(); i++) + for (i = 0; i < gc_number(); i++) si_freq(atoi(DEFAULT_FREQ), i); } |