[PATCH v4 06/15] tools/gputop: find program name from command line
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Wed May 14 12:50:30 UTC 2025
On Wed, May 07, 2025 at 04:01:39PM +0000, Jeevaka Prabu Badrappan wrote:
> program_invocation_short_name is global variable provided by glibc.
>
> Inorder to get the igt built for Android(without glibc), find the
> program from command line without using program_invocation_short_name.
>
> Signed-off-by: Jeevaka Prabu Badrappan <jeevaka.badrappan at intel.com>
> ---
> tools/gputop.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/tools/gputop.c b/tools/gputop.c
> index 43b01f566..457a31969 100644
> --- a/tools/gputop.c
> +++ b/tools/gputop.c
> @@ -335,15 +335,22 @@ struct gputop_args {
> unsigned long delay_usec;
> };
>
> -static void help(void)
> +static void help(char* full_path)
Minor nit 'char* full_path' -> 'char *full_path'.
With that:
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
--
Zbigniew
> {
> + const char *short_program_name = strrchr(full_path, '/');
> + if (short_program_name) {
> + short_program_name++;
> + } else {
> + short_program_name = full_path;
> + }
> +
> printf("Usage:\n"
> "\t%s [options]\n\n"
> "Options:\n"
> "\t-h, --help show this help\n"
> "\t-d, --delay =SEC[.TENTHS] iterative delay as SECS [.TENTHS]\n"
> "\t-n, --iterations =NUMBER number of executions\n"
> - , program_invocation_short_name);
> + , short_program_name);
> }
>
> static int parse_args(int argc, char * const argv[], struct gputop_args *args)
> @@ -384,7 +391,7 @@ static int parse_args(int argc, char * const argv[], struct gputop_args *args)
> }
> break;
> case 'h':
> - help();
> + help(argv[0]);
> return 0;
> default:
> fprintf(stderr, "Unkonwn option '%c'.\n", c);
> --
> 2.34.1
>
More information about the igt-dev
mailing list