[v5,1/4] eal: explain argv behaviour during init

Message ID 20210405193954.1115838-2-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series improve options help |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon April 5, 2021, 7:39 p.m. UTC
  After argument parsing done by rte_eal_init(),
the remaining arguments are to be parsed by the application
by progressing in the argv array.
In this context, the first string represented by argv[0] is still
the same program name as the original argv[0],
while the next strings are the application arguments.
This is because rte_eal_init() manipulates the argv array
after EAL parsing, before returning to the application.

This note was missing in the doxygen comment of the API.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 lib/librte_eal/include/rte_eal.h | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Stephen Hemminger July 5, 2023, 4:51 p.m. UTC | #1
On Mon,  5 Apr 2021 21:39:51 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:

> After argument parsing done by rte_eal_init(),
> the remaining arguments are to be parsed by the application
> by progressing in the argv array.
> In this context, the first string represented by argv[0] is still
> the same program name as the original argv[0],
> while the next strings are the application arguments.
> This is because rte_eal_init() manipulates the argv array
> after EAL parsing, before returning to the application.
> 
> This note was missing in the doxygen comment of the API.
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

This old patch is still worth applying

Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  

Patch

diff --git a/lib/librte_eal/include/rte_eal.h b/lib/librte_eal/include/rte_eal.h
index eaf6469e50..0cbeedb594 100644
--- a/lib/librte_eal/include/rte_eal.h
+++ b/lib/librte_eal/include/rte_eal.h
@@ -76,6 +76,8 @@  int rte_eal_iopl_init(void);
  * @param argv
  *   An array of strings.  The contents of the array, as well as the strings
  *   which are pointed to by the array, may be modified by this function.
+ *   The program name pointer argv[0] is copied into the last parsed argv
+ *   so that argv[0] is still the same after deducing the parsed arguments.
  * @return
  *   - On success, the number of parsed arguments, which is greater or
  *     equal to zero. After the call to rte_eal_init(),