[v2] usertools/hugepages: show usage if no action specified

Message ID 20221122153238.2373095-1-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Headers
Series [v2] usertools/hugepages: show usage if no action specified |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-testing warning apply patch failure
ci/Intel-compilation warning apply issues

Commit Message

Thomas Monjalon Nov. 22, 2022, 3:32 p.m. UTC
  Previously, the script was doing nothing if no argument was provided.

If neither show, mount/unmount, clear/reserve are specified,
it is assumed that the user does not know how to use the script.
So the usage and an error message are printed.
The exit code will be non-zero.
The user will understand something is wrong,
and can recall the script with the option -h to get more information.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
v2: replace parser.print_usage() and sys.exit(1) with parser.error()
---
 usertools/dpdk-hugepages.py | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

David Marchand Nov. 22, 2022, 3:38 p.m. UTC | #1
On Tue, Nov 22, 2022 at 4:33 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> Previously, the script was doing nothing if no argument was provided.
>
> If neither show, mount/unmount, clear/reserve are specified,
> it is assumed that the user does not know how to use the script.
> So the usage and an error message are printed.
> The exit code will be non-zero.
> The user will understand something is wrong,
> and can recall the script with the option -h to get more information.
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

Acked-by: David Marchand <david.marchand@redhat.com>
  
Thomas Monjalon Nov. 22, 2022, 3:42 p.m. UTC | #2
22/11/2022 16:38, David Marchand:
> On Tue, Nov 22, 2022 at 4:33 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> >
> > Previously, the script was doing nothing if no argument was provided.
> >
> > If neither show, mount/unmount, clear/reserve are specified,
> > it is assumed that the user does not know how to use the script.
> > So the usage and an error message are printed.
> > The exit code will be non-zero.
> > The user will understand something is wrong,
> > and can recall the script with the option -h to get more information.
> >
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> 
> Acked-by: David Marchand <david.marchand@redhat.com>

Applied
  

Patch

diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py
index a22d504d3a..bf2575ba36 100755
--- a/usertools/dpdk-hugepages.py
+++ b/usertools/dpdk-hugepages.py
@@ -272,6 +272,9 @@  def main():
         args.reserve = args.setup
         args.mount = True
 
+    if not (args.show or args.mount or args.unmount or args.clear or args.reserve):
+        parser.error("no action specified")
+
     if args.pagesize:
         pagesize_kb = get_memsize(args.pagesize)
     else: