• Eugeniu Rosca's avatar
    selftests: watchdog: use getopt_long() · 749fb263
    Eugeniu Rosca authored
    Switch from manual argv[] parsing to getopt_long() argument processing.
    This creates more readable code and allows easier feature addition.
    This also fixes some segmentation faults introduced by
    commit 1dbdcc81 ("selftests: watchdog: accept multiple params on
    command line"), when options -t or -p are not given the required value:
    
    ./watchdog-test -p 1 -t
    ./watchdog-test -t 1 -p
    
    No changes are intended in the way watchdog-test interacts with the
    kernel. The only noticible changes, tightly related to the addition
    of getopt (and done for easier maintenance),  are:
    - help message has been reworked and migrated to a dedicated function.
    - all short/long options and the help message are sorted alphabetically.
    - all case statements inside the getopt loop are sorted alphabetically.
    
    Fixes: 1dbdcc81 ("selftests: watchdog: accept multiple params on command line")
    Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
    Signed-off-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
    749fb263
watchdog-test.c 2.96 KB