Commit a1ce5ba2 authored by Dominik Brodowski's avatar Dominik Brodowski

cpupowerutils: utils - ConfigStyle bugfixes

Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 2cd005ca
This diff is collapsed.
......@@ -43,12 +43,12 @@ void freq_set_help(void)
}
static struct option set_opts[] = {
{ .name="min", .has_arg=required_argument, .flag=NULL, .val='d'},
{ .name="max", .has_arg=required_argument, .flag=NULL, .val='u'},
{ .name="governor", .has_arg=required_argument, .flag=NULL, .val='g'},
{ .name="freq", .has_arg=required_argument, .flag=NULL, .val='f'},
{ .name="help", .has_arg=no_argument, .flag=NULL, .val='h'},
{ .name="related", .has_arg=no_argument, .flag=NULL, .val='r'},
{ .name = "min", .has_arg = required_argument, .flag = NULL, .val = 'd'},
{ .name = "max", .has_arg = required_argument, .flag = NULL, .val = 'u'},
{ .name = "governor", .has_arg = required_argument, .flag = NULL, .val = 'g'},
{ .name = "freq", .has_arg = required_argument, .flag = NULL, .val = 'f'},
{ .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},
{ .name = "related", .has_arg = no_argument, .flag = NULL, .val='r'},
{ },
};
......@@ -64,7 +64,7 @@ static void print_error(void)
};
struct freq_units {
char* str_unit;
char *str_unit;
int power_of_ten;
};
......@@ -204,7 +204,8 @@ static int do_one_cpu(unsigned int cpu, struct cpufreq_policy *new_pol,
else if (new_pol->max)
return cpufreq_modify_policy_max(cpu, new_pol->max);
else if (new_pol->governor)
return cpufreq_modify_policy_governor(cpu, new_pol->governor);
return cpufreq_modify_policy_governor(cpu,
new_pol->governor);
default:
/* slow path */
......@@ -282,15 +283,15 @@ int cmd_freq_set(int argc, char **argv)
if ((strlen(optarg) < 3) || (strlen(optarg) > 18)) {
print_unknown_arg();
return -EINVAL;
}
}
if ((sscanf(optarg, "%s", gov)) != 1) {
print_unknown_arg();
return -EINVAL;
}
}
new_pol.governor = gov;
break;
}
} while(cont);
} while (cont);
/* parameter checking */
if (double_parm) {
......@@ -339,7 +340,7 @@ int cmd_freq_set(int argc, char **argv)
/* loop over CPUs */
for (cpu = bitmask_first(cpus_chosen);
cpu <= bitmask_last(cpus_chosen); cpu++) {
if (!bitmask_isbitset(cpus_chosen, cpu) ||
cpufreq_cpu_exists(cpu))
continue;
......
......@@ -31,8 +31,7 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose)
if (idlestates == 0) {
printf(_("CPU %u: No idle states\n"), cpu);
return;
}
else if (idlestates <= 0) {
} else if (idlestates <= 0) {
printf(_("CPU %u: Can't read idle state info\n"), cpu);
return;
}
......@@ -92,7 +91,7 @@ static void cpuidle_general_output(void)
}
printf(_("CPUidle driver: %s\n"), tmp);
free (tmp);
free(tmp);
tmp = sysfs_get_cpuidle_governor();
if (!tmp) {
......@@ -101,7 +100,7 @@ static void cpuidle_general_output(void)
}
printf(_("CPUidle governor: %s\n"), tmp);
free (tmp);
free(tmp);
}
static void proc_cpuidle_cpu_output(unsigned int cpu)
......@@ -117,8 +116,7 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
* printf(_("CPU %u: No C-states available\n"), cpu);
* return;
*/
}
else if (cstates <= 0) {
} else if (cstates <= 0) {
printf(_("CPU %u: Can't read C-state info\n"), cpu);
return;
}
......@@ -143,7 +141,8 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
/* --freq / -f */
void idle_info_help(void) {
void idle_info_help(void)
{
printf(_ ("Usage: cpupower idleinfo [options]\n"));
printf(_ ("Options:\n"));
printf(_ (" -s, --silent Only show general C-state information\n"));
......@@ -155,9 +154,9 @@ void idle_info_help(void) {
}
static struct option info_opts[] = {
{ .name="silent", .has_arg=no_argument, .flag=NULL, .val='s'},
{ .name="proc", .has_arg=no_argument, .flag=NULL, .val='o'},
{ .name="help", .has_arg=no_argument, .flag=NULL, .val='h'},
{ .name = "silent", .has_arg = no_argument, .flag = NULL, .val = 's'},
{ .name = "proc", .has_arg = no_argument, .flag = NULL, .val = 'o'},
{ .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},
{ },
};
......@@ -202,7 +201,7 @@ int cmd_idle_info(int argc, char **argv)
output_param = ret;
break;
}
} while(cont);
} while (cont);
switch (output_param) {
case -1:
......@@ -219,10 +218,10 @@ int cmd_idle_info(int argc, char **argv)
/* Default is: show output of CPU 0 only */
if (bitmask_isallclear(cpus_chosen))
bitmask_setbit(cpus_chosen, 0);
if (output_param == 0)
cpuidle_general_output();
for (cpu = bitmask_first(cpus_chosen);
cpu <= bitmask_last(cpus_chosen); cpu++) {
......@@ -241,5 +240,5 @@ int cmd_idle_info(int argc, char **argv)
break;
}
}
return (EXIT_SUCCESS);
return EXIT_SUCCESS;
}
......@@ -30,10 +30,10 @@ void info_help(void)
}
static struct option set_opts[] = {
{ .name="perf-bias", .has_arg=optional_argument, .flag=NULL, .val='b'},
{ .name="sched-mc", .has_arg=optional_argument, .flag=NULL, .val='m'},
{ .name="sched-smt", .has_arg=optional_argument, .flag=NULL, .val='s'},
{ .name="help", .has_arg=no_argument, .flag=NULL, .val='h'},
{ .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'},
{ .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'},
{ .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'},
{ .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},
{ },
};
......@@ -57,12 +57,11 @@ int cmd_info(int argc, char **argv)
int perf_bias:1;
};
int params;
} params = {};
int ret = 0;
setlocale(LC_ALL, "");
textdomain (PACKAGE);
textdomain(PACKAGE);
/* parameter parsing */
while ((ret = getopt_long(argc, argv, "msbh", set_opts, NULL)) != -1) {
......@@ -105,7 +104,7 @@ int cmd_info(int argc, char **argv)
printf(_("not supported\n"));
else
printf("%d\n", ret);
}
}
if (params.sched_smt) {
ret = sysfs_get_sched("smt");
printf(_("System's thread sibling scheduler setting: "));
......@@ -123,7 +122,7 @@ int cmd_info(int argc, char **argv)
if (params.perf_bias) {
if (!run_as_root) {
params.perf_bias = 0;
printf (_("Intel's performance bias setting needs root privileges\n"));
printf(_("Intel's performance bias setting needs root privileges\n"));
} else if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_PERF_BIAS)) {
printf(_("System does not support Intel's performance"
" bias setting\n"));
......@@ -134,7 +133,7 @@ int cmd_info(int argc, char **argv)
/* loop over CPUs */
for (cpu = bitmask_first(cpus_chosen);
cpu <= bitmask_last(cpus_chosen); cpu++) {
if (!bitmask_isbitset(cpus_chosen, cpu) ||
cpufreq_cpu_exists(cpu))
continue;
......
......@@ -30,10 +30,10 @@ void set_help(void)
}
static struct option set_opts[] = {
{ .name="perf-bias", .has_arg=optional_argument, .flag=NULL, .val='b'},
{ .name="sched-mc", .has_arg=optional_argument, .flag=NULL, .val='m'},
{ .name="sched-smt", .has_arg=optional_argument, .flag=NULL, .val='s'},
{ .name="help", .has_arg=no_argument, .flag=NULL, .val='h'},
{ .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'},
{ .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'},
{ .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'},
{ .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h'},
{ },
};
......@@ -57,17 +57,17 @@ int cmd_set(int argc, char **argv)
int perf_bias:1;
};
int params;
} params;
int sched_mc = 0, sched_smt = 0, perf_bias = 0;
int ret = 0;
setlocale(LC_ALL, "");
textdomain (PACKAGE);
textdomain(PACKAGE);
params.params = 0;
/* parameter parsing */
while ((ret = getopt_long(argc, argv, "m:s:b:h", set_opts, NULL)) != -1) {
while ((ret = getopt_long(argc, argv, "m:s:b:h",
set_opts, NULL)) != -1) {
switch (ret) {
case 'h':
set_help();
......@@ -135,7 +135,7 @@ int cmd_set(int argc, char **argv)
/* loop over CPUs */
for (cpu = bitmask_first(cpus_chosen);
cpu <= bitmask_last(cpus_chosen); cpu++) {
if (!bitmask_isbitset(cpus_chosen, cpu) ||
cpufreq_cpu_exists(cpu))
continue;
......
......@@ -50,8 +50,8 @@ static struct cmd_struct commands[] = {
{ "set", cmd_set, set_help, 1 },
{ "info", cmd_info, info_help, 0 },
{ "monitor", cmd_monitor, monitor_help, 0 },
{ "help", cmd_help, print_help, 0 },
// { "bench", cmd_bench, NULL, 1 },
{ "help", cmd_help, print_help, 0 },
/* { "bench", cmd_bench, NULL, 1 }, */
};
int cmd_help(int argc, const char **argv)
......@@ -95,8 +95,9 @@ static void print_help(void)
printf(_("\nUse cpupower help subcommand for getting help for above subcommands.\n"));
}
static void print_version(void) {
printf(PACKAGE " " VERSION "\n");
static void print_version(void)
{
printf(PACKAGE " " VERSION "\n");
printf(_("Report errors and bugs to %s, please.\n"), PACKAGE_BUGREPORT);
}
......@@ -109,10 +110,10 @@ static void handle_options(int *argc, const char ***argv)
for (x = 0; x < *argc && ((*argv)[x])[0] == '-'; x++) {
const char *param = (*argv)[x];
if (!strcmp(param, "-h") || !strcmp(param, "--help")){
if (!strcmp(param, "-h") || !strcmp(param, "--help")) {
print_help();
exit(EXIT_SUCCESS);
} else if (!strcmp(param, "-c") || !strcmp(param, "--cpu")){
} else if (!strcmp(param, "-c") || !strcmp(param, "--cpu")) {
if (*argc < 2) {
print_help();
exit(EXIT_FAILURE);
......@@ -132,13 +133,14 @@ static void handle_options(int *argc, const char ***argv)
/* Cut out param: cpupower -c 1 info -> cpupower info */
new_argc += 2;
continue;
} else if (!strcmp(param, "-v") || !strcmp(param, "--version")){
} else if (!strcmp(param, "-v") ||
!strcmp(param, "--version")) {
print_version();
exit(EXIT_SUCCESS);
#ifdef DEBUG
} else if (!strcmp(param, "-d") || !strcmp(param, "--debug")){
} else if (!strcmp(param, "-d") || !strcmp(param, "--debug")) {
be_verbose = 1;
new_argc ++;
new_argc++;
continue;
#endif
} else {
......@@ -171,7 +173,7 @@ int main(int argc, const char *argv[])
}
setlocale(LC_ALL, "");
textdomain (PACKAGE);
textdomain(PACKAGE);
/* Turn "perf cmd --help" into "perf help cmd" */
if (argc > 1 && !strcmp(argv[1], "--help")) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment