system/trace: correct arg index if command is alreay set

An error occurs when the same command is executed twice

$ trace switch +
$ trace switch +
Usage: trace <subcommand>...
Subcommand:
  start [-c][<duration>]          : Start task tracing
  stop                            : Stop task tracing
  dump [-a][-c][<filename>]           : Output the trace result
 [-a] <Android SysTrace>
  mode [{+|-}{o|w|s|a|i|d}...]        : Set task trace options
  switch [+|-] : Configure switch trace filter
  syscall [{+|-}<syscallname>...] : Configure syscall trace filter
  irq [{+|-}<irqnum>...]          : Configure IRQ trace filter
  print [+|-] : Configure dump tnsh>

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2022-05-09 12:11:13 +08:00 committed by Xiang Xiao
parent 8ce86fe572
commit 089c05cbd8

View File

@ -501,13 +501,13 @@ static int trace_cmd_switch(int index, int argc, FAR char **argv,
{
if (argv[index][0] == '-' || argv[index][0] == '+')
{
enable = (argv[index][0] == '+');
enable = (argv[index++][0] == '+');
if (enable ==
((mode.flag & NOTE_FILTER_MODE_FLAG_SWITCH) != 0))
{
/* Already set */
return false;
return index;
}
if (enable)
@ -520,8 +520,6 @@ static int trace_cmd_switch(int index, int argc, FAR char **argv,
}
ioctl(notectlfd, NOTECTL_SETMODE, (unsigned long)&mode);
index++;
}
}
@ -754,13 +752,13 @@ static int trace_cmd_print(int index, int argc, FAR char **argv,
{
if (argv[index][0] == '-' || argv[index][0] == '+')
{
enable = (argv[index][0] == '+');
enable = (argv[index++][0] == '+');
if (enable ==
((mode.flag & NOTE_FILTER_MODE_FLAG_DUMP) != 0))
{
/* Already set */
return false;
return index;
}
if (enable)
@ -773,8 +771,6 @@ static int trace_cmd_print(int index, int argc, FAR char **argv,
}
ioctl(notectlfd, NOTECTL_SETMODE, (unsigned long)&mode);
index++;
}
}