mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
RTLA fixes for v7.1
- Fix multi-character short option parsing Fix regression in parsing of multiple-character short options (e.g. -p100 /= -p 100/, -un /= -u -n/) caused by getopt_long() internal state corruption after a refactoring. -----BEGIN PGP SIGNATURE----- iIoEABYKADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCaiiILRQccm9zdGVkdEBn b29kbWlzLm9yZwAKCRAp5XQQmuv6qvKKAP9peFJI0pJhGz3xkBdtDjNeTw8k93QT aTutUb4tJUD92wD/QJ0FwiOyzOCqkBHAO2x2R4elTlGm4Wgz9cZXjzHWaw8= =0CcC -----END PGP SIGNATURE----- Merge tag 'trace-tools-v7.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace Pull RTLA fix from Steven Rostedt: - Fix multi-character short option parsing Fix regression in parsing of multiple-character short options (eg -p100 /= -p 100/, -un /= -u -n/) caused by getopt_long() internal state corruption after a refactoring. * tag 'trace-tools-v7.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: rtla: Fix parsing of multi-character short options
This commit is contained in:
commit
06f4462d05
|
|
@ -84,37 +84,20 @@ int getopt_auto(int argc, char **argv, const struct option *long_opts)
|
|||
}
|
||||
|
||||
/*
|
||||
* common_parse_options - parse common command line options
|
||||
* set_common_option - set common options
|
||||
*
|
||||
* @c: option character
|
||||
* @argc: argument count
|
||||
* @argv: argument vector
|
||||
* @common: common parameters structure
|
||||
*
|
||||
* Parse command line options that are common to all rtla tools.
|
||||
*
|
||||
* Returns: non zero if a common option was parsed, or 0
|
||||
* if the option should be handled by tool-specific parsing.
|
||||
* Returns: 1 if the option was set, 0 otherwise.
|
||||
*/
|
||||
int common_parse_options(int argc, char **argv, struct common_params *common)
|
||||
int set_common_option(int c, int argc, char **argv, struct common_params *common)
|
||||
{
|
||||
struct trace_events *tevent;
|
||||
int saved_state = optind;
|
||||
int c;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"cpus", required_argument, 0, 'c'},
|
||||
{"cgroup", optional_argument, 0, 'C'},
|
||||
{"debug", no_argument, 0, 'D'},
|
||||
{"duration", required_argument, 0, 'd'},
|
||||
{"event", required_argument, 0, 'e'},
|
||||
{"house-keeping", required_argument, 0, 'H'},
|
||||
{"priority", required_argument, 0, 'P'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
opterr = 0;
|
||||
c = getopt_auto(argc, argv, long_options);
|
||||
opterr = 1;
|
||||
|
||||
switch (c) {
|
||||
case 'c':
|
||||
|
|
@ -154,11 +137,10 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
|
|||
common->set_sched = 1;
|
||||
break;
|
||||
default:
|
||||
optind = saved_state;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return c;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -178,7 +178,17 @@ int osnoise_set_stop_total_us(struct osnoise_context *context,
|
|||
long long stop_total_us);
|
||||
|
||||
int getopt_auto(int argc, char **argv, const struct option *long_opts);
|
||||
int common_parse_options(int argc, char **argv, struct common_params *common);
|
||||
|
||||
#define COMMON_OPTIONS \
|
||||
{"cpus", required_argument, 0, 'c'},\
|
||||
{"cgroup", optional_argument, 0, 'C'},\
|
||||
{"debug", no_argument, 0, 'D'},\
|
||||
{"duration", required_argument, 0, 'd'},\
|
||||
{"event", required_argument, 0, 'e'},\
|
||||
{"house-keeping", required_argument, 0, 'H'},\
|
||||
{"priority", required_argument, 0, 'P'}
|
||||
int set_common_option(int c, int argc, char **argv, struct common_params *common);
|
||||
|
||||
int common_apply_config(struct osnoise_tool *tool, struct common_params *params);
|
||||
int top_main_loop(struct osnoise_tool *tool);
|
||||
int hist_main_loop(struct osnoise_tool *tool);
|
||||
|
|
|
|||
|
|
@ -475,6 +475,7 @@ static struct common_params
|
|||
|
||||
while (1) {
|
||||
static struct option long_options[] = {
|
||||
COMMON_OPTIONS,
|
||||
{"auto", required_argument, 0, 'a'},
|
||||
{"bucket-size", required_argument, 0, 'b'},
|
||||
{"entries", required_argument, 0, 'E'},
|
||||
|
|
@ -498,15 +499,15 @@ static struct common_params
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
if (common_parse_options(argc, argv, ¶ms->common))
|
||||
continue;
|
||||
|
||||
c = getopt_auto(argc, argv, long_options);
|
||||
|
||||
/* detect the end of the options. */
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
if (set_common_option(c, argc, argv, ¶ms->common))
|
||||
continue;
|
||||
|
||||
switch (c) {
|
||||
case 'a':
|
||||
/* set sample stop to auto_thresh */
|
||||
|
|
|
|||
|
|
@ -328,6 +328,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
|
|||
|
||||
while (1) {
|
||||
static struct option long_options[] = {
|
||||
COMMON_OPTIONS,
|
||||
{"auto", required_argument, 0, 'a'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"period", required_argument, 0, 'p'},
|
||||
|
|
@ -346,15 +347,15 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
if (common_parse_options(argc, argv, ¶ms->common))
|
||||
continue;
|
||||
|
||||
c = getopt_auto(argc, argv, long_options);
|
||||
|
||||
/* Detect the end of the options. */
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
if (set_common_option(c, argc, argv, ¶ms->common))
|
||||
continue;
|
||||
|
||||
switch (c) {
|
||||
case 'a':
|
||||
/* set sample stop to auto_thresh */
|
||||
|
|
|
|||
|
|
@ -785,6 +785,7 @@ static struct common_params
|
|||
|
||||
while (1) {
|
||||
static struct option long_options[] = {
|
||||
COMMON_OPTIONS,
|
||||
{"auto", required_argument, 0, 'a'},
|
||||
{"bucket-size", required_argument, 0, 'b'},
|
||||
{"entries", required_argument, 0, 'E'},
|
||||
|
|
@ -819,11 +820,11 @@ static struct common_params
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
if (common_parse_options(argc, argv, ¶ms->common))
|
||||
continue;
|
||||
|
||||
c = getopt_auto(argc, argv, long_options);
|
||||
|
||||
if (set_common_option(c, argc, argv, ¶ms->common))
|
||||
continue;
|
||||
|
||||
/* detect the end of the options. */
|
||||
if (c == -1)
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -549,6 +549,7 @@ static struct common_params
|
|||
|
||||
while (1) {
|
||||
static struct option long_options[] = {
|
||||
COMMON_OPTIONS,
|
||||
{"auto", required_argument, 0, 'a'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"irq", required_argument, 0, 'i'},
|
||||
|
|
@ -577,11 +578,11 @@ static struct common_params
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
if (common_parse_options(argc, argv, ¶ms->common))
|
||||
continue;
|
||||
|
||||
c = getopt_auto(argc, argv, long_options);
|
||||
|
||||
if (set_common_option(c, argc, argv, ¶ms->common))
|
||||
continue;
|
||||
|
||||
/* detect the end of the options. */
|
||||
if (c == -1)
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user