getopt_long() in glibc allows shortened long option names, e.g. ptp4l --domain works as --domainNumber. When the match is ambiguous, e.g. --fault matches --fault_badpeernet_interval and --fault_reset_interval, it is supposed to return an error, but that works only if their struct option have different flags or vals.
https://sourceware.org/bugzilla/show_bug.cgi?id=28081 Set the flag to point to the val itself for a no-op to work around this issue and make it less likely a misremembered option name will silently match one of multiple possible candidates. Signed-off-by: Miroslav Lichvar <mlich...@redhat.com> --- config.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.c b/config.c index d77664c..79149aa 100644 --- a/config.c +++ b/config.c @@ -741,6 +741,8 @@ static struct option *config_alloc_longopts(void) ci = &config_tab[i]; opts[i].name = ci->label; opts[i].has_arg = required_argument; + /* Avoid bug in detection of ambiguous options in glibc */ + opts[i].flag = &opts[i].val; } return opts; -- 2.26.3 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel