Fixes to manpage and command line handling
Joerg Mayer
PATCH 1/1 Fixes to manpage and command line handling
Hello,
I just decided to play with powertop again. So git pull, find out the repo has moved etcetc.
I found a few cosmetic things within the first 5 minutes of use which I decided to provide a fix for.
Please apply if it is acceptable, otherwise let me know how to improve it.
Thanks
Jörg
--
Joerg Mayer <jmayer(a)loplof.de>
We are stuck with technology when what we really want is just stuff that works. Some say that should read Microsoft instead of technology.
Make usage and program behaviour a bit more consistent. Also fix some tpyos, one of them comman line relevant:
- alphabetically sort entries in powertop.8 (manpage)
- add help for --quiet (see below)
- change the default file names to match those in the manpage
- fix a typo
- print runtime help with one more tab for quiet (see below)
- rename command line option quite to quiet
- remove trailing whitespace in main.cpp
doc/powertop.8 +9 -6
@@ -14,19 +14,19 @@ experiment with various power management settings. When invoking powertop without arguments powertop starts in interactive mode. .SH OPTIONS .TP -\fB\-\-csv[\fR=\fIFILENAME\fR] -generate a CSV report. If a filename is not specified then the -default name "powertop.csv" is used. The CSV report can be -used for reporting and data analysis. -.TP \fB\-\-calibrate runs powertop in calibration mode. When running on battery, powertop can track power consumption as well as system activity. When there are enough measurements, powertop can start to report power estimates. One can get more accurate estimates by using this option to enable a -calibration cycle. This will cycle through various display levesl and USB +calibration cycle. This will cycle through various display levels and USB device activities and workloads. .TP +\fB\-\-csv[\fR=\fIFILENAME\fR] +generate a CSV report. If a filename is not specified then the +default name "powertop.csv" is used. The CSV report can be +used for reporting and data analysis. +.TP \fB\-\-debug run in "debug" mode. .TP
@@ -46,6 +46,9 @@ sent to others to help diagnose power issues. \fB\-\-iteration[\fR=\fIiterations\fR] number of times to run each test. .TP +\fB\-\-quiet + supress stderr output. +.TP \fB\-\-time[\fR=\fIseconds\fR] generate a report for a specified number of seconds. .TP
src/main.cpp +11 -11
@@ -77,7 +77,7 @@ static const struct option long_options[] = {"time", optional_argument, NULL, 't'}, {"iteration", optional_argument, NULL, 'i'}, {"workload", optional_argument, NULL, 'w'}, - {"quite", optional_argument, NULL, 'q'}, + {"quiet", optional_argument, NULL, 'q'}, {NULL, 0, NULL, 0} };
@@ -112,7 +112,7 @@ static void print_usage() printf("--time%s \t %s\n",_("[=seconds]"), _("generate a report for 'x' seconds")); printf("--iteration%s\n", _("[=iterations] number of times to run each test")); printf("--workload%s \t %s\n", _("[=workload]"), _("file to execute for workload")); - printf("--quite \t %s\n", _("supress stderr output")); + printf("--quiet \t\t %s\n", _("supress stderr output")); printf("--help \t\t\t %s\n",_("print this help menu")); printf("\n"); printf("%s\n\n",_("For more help please refer to the README"));
@@ -237,7 +237,7 @@ void report(int time, char *workload, int iterations, char *file) fprintf(stderr, _("Preparing to take measurements\n")); utf_ok = 0; one_measurement(1, NULL); - + if (!workload[0]) fprintf(stderr, _("Taking %d measurement(s) for a duration of %d second(s) each.\n"),iterations,time); else
@@ -260,7 +260,7 @@ void report(int time, char *workload, int iterations, char *file) } static void checkroot() { - int uid; + int uid; uid = getuid(); if (uid != 0) {
@@ -268,7 +268,7 @@ static void checkroot() { printf(_("exiting...\n")); exit(EXIT_FAILURE); } - + } static void powertop_init(void)
@@ -280,7 +280,7 @@ static void powertop_init(void) if (initialized) return; - checkroot(); + checkroot(); ret = system("/sbin/modprobe cpufreq_stats > /dev/null 2>&1"); ret = system("/sbin/modprobe msr > /dev/null 2>&1"); statfs("/sys/kernel/debug", &st_fs);
@@ -343,7 +343,7 @@ int main(int argc, char **argv) textdomain (PACKAGE); while (1) { /* parse commandline options */ - c = getopt_long (argc, argv, "ch:C:i:t:uV:w:q", long_options, &option_index); + c = getopt_long (argc, argv, "ch:C:i:t:uVw:q", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break;
@@ -355,7 +355,7 @@ int main(int argc, char **argv) break; case 'e': /* Extech power analyzer support */ - checkroot(); + checkroot(); extech_power_meter(optarg ? optarg : "/dev/ttyUSB0"); break; case 'u':
@@ -371,7 +371,7 @@ int main(int argc, char **argv) case 'h': /* html report */ wantreport = true; reporttype = 1; - sprintf(filename, "%s", optarg ? optarg : "PowerTOP.html" ); + sprintf(filename, "%s", optarg ? optarg : "powertop.html" ); break; case 't':
@@ -388,11 +388,11 @@ int main(int argc, char **argv) case 'q': freopen("/dev/null", "a", stderr); break; - + case 'C': /* csv report*/ wantreport = true; reporttype = 0; - sprintf(filename, "%s", optarg ? optarg : "PowerTOP.csv"); + sprintf(filename, "%s", optarg ? optarg : "powertop.csv"); break; case '?': /* Unknown option */ /* getopt_long already printed an error message. */
Kok
Quoted 9 lines · Joerg Mayer
Hello,
I just decided to play with powertop again. So git pull, find out the repo has moved etcetc.
I found a few cosmetic things within the first 5 minutes of use which I decided to provide a fix for.
Please apply if it is acceptable, otherwise let me know how to improve it.
could you split these up into functionally different patches? e.g. one for whitespace, one for man page changes, and one for the getopt() fixes?
Auke