All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Shivani Nittor" <shivani@linux.ibm.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf scripts: Add configurable sorting option to powerpc-hcalls
Date: Fri, 05 Jun 2026 06:31:49 +0000	[thread overview]
Message-ID: <20260605063149.6E2541F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260605062717.24982-1-shivani@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The argument parsing loop in `trace_begin()` will crash with an `IndexError` if `-s` or `--sort` is the last argument provided.
--

commit e3cf27646cdda0e6126f0f6cde0a6fdbb2db8e8c
Author: Shivani Nittor <shivani@linux.ibm.com>

perf scripts: Add configurable sorting option to powerpc-hcalls

This commit adds a runtime-configurable sorting option to the powerpc-hcalls.py
script. It parses sys.argv to allow users to order hypercall statistics by
count or various latency metrics.

> diff --git a/tools/perf/scripts/python/powerpc-hcalls.py b/tools/perf/scripts/python/powerpc-hcalls.py
> index 8b78dc790adb1..df7b83ab0b6e0 100644
> --- a/tools/perf/scripts/python/powerpc-hcalls.py
> +++ b/tools/perf/scripts/python/powerpc-hcalls.py

[ ... ]

> @@ -158,10 +159,42 @@ def hcall_table_lookup(opcode):
>  
>  print_ptrn = '%-28s%10s%10s%10s%10s'
>  

[ ... ]

> +def trace_begin():
> +    global sort_key
> +
> +    i = 1
> +    while i < len(sys.argv):
> +        arg = sys.argv[i]
> +
> +        if arg == '-s' or arg == '--sort':
> +            sort_key = sys.argv[i + 1]

[Severity: Medium]
Does this code risk an IndexError if the script is invoked with -s or --sort
as the very last argument?

If a user fails to provide the actual sort key value at the end of the argument
list, accessing sys.argv[i + 1] will be out of bounds and crash the script.

> +            i += 2
> +            continue
> +
> +        if arg.startswith('--sort='):
> +            sort_key = arg.split('=', 1)[1]
> +
> +        i += 1
> +
> +    print("SORT KEY =", sort_key)

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260605062717.24982-1-shivani@linux.ibm.com?part=1

      reply	other threads:[~2026-06-05  6:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05  6:27 [PATCH] perf scripts: Add configurable sorting option to powerpc-hcalls Shivani Nittor
2026-06-05  6:31 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260605063149.6E2541F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shivani@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.