From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: Bruce Richardson <bruce.richardson@intel.com>, <dev@dpdk.org>
Subject: Re: [PATCH 2/2] app/pdump: improve cmdline argument handling
Date: Fri, 7 Nov 2025 17:14:18 +0100 [thread overview]
Message-ID: <aa8f56a4-010c-4ef2-9d97-5e61dc892173@intel.com> (raw)
In-Reply-To: <20251017110638.1094371-2-bruce.richardson@intel.com>
On 10/17/2025 1:06 PM, Bruce Richardson wrote:
> Rework the argc/argv handling in pdump a little to improve things.
> Issues with the original implementation:
> * assumed user would never pass proc-type parameter on the commandline
> * did not null-terminate the argv array (generally harmless but not in
> spec)
> * did not handle case where arg processing in eal_init would reorder
> non-flag args to the end to be handled by the app.
>
> Fix these - all-be-it minor issues, by having a separate count value for
> the number of arguments we put in the argp array, rather than assuming
> that its argc + 1 (for proc-type flag). Properly set the last argv entry
> to NULL, and when processing app args, reuse the argp array passed to
> eal_init rather than reverting back to the original argv array.
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
<snip>
>
> - argp[0] = argv[0];
> - argp[1] = mp_flag;
> + argp[n_argp++] = argv[0];
> + argp[n_argp++] = mp_flag;
>
> - for (i = 1; i < argc; i++)
> - argp[i + 1] = argv[i];
> -
> - argc += 1;
> + for (i = 1; i < argc; i++) {
> + argp[n_argp] = argv[i];
> + /* drop any user-provided proc-type to avoid dup flags */
> + if (strncmp(argv[i], mp_flag, strlen("--proc-type")) != 0)
> + n_argp++;
Feels a little odd to assign the value and then overwrite it in next
iteration, but same end result so no biggie
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
--
Thanks,
Anatoly
next prev parent reply other threads:[~2025-11-07 16:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 11:06 [PATCH 1/2] app/pdump: remove hard-coded memory channels EAL arg Bruce Richardson
2025-10-17 11:06 ` [PATCH 2/2] app/pdump: improve cmdline argument handling Bruce Richardson
2025-11-07 16:14 ` Burakov, Anatoly [this message]
2025-11-07 16:10 ` [PATCH 1/2] app/pdump: remove hard-coded memory channels EAL arg Burakov, Anatoly
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=aa8f56a4-010c-4ef2-9d97-5e61dc892173@intel.com \
--to=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).