All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] lib/tst_test: Warn on repeated options
@ 2019-11-05 12:00 Cyril Hrubis
  2019-11-05 13:05 ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2019-11-05 12:00 UTC (permalink / raw)
  To: ltp

The library is not designed in a way that would allow us to pass an
option mutiple times, if such case the last option occurence replaces
all previous ones.

This patch adds a warning in a case that the option pointer is non-NULL,
which means that it has been set at least once already.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
CC: Jan Stancek <jstancek@redhat.com>
---
 lib/tst_test.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/tst_test.c b/lib/tst_test.c
index c7b46d0d5..f41baf3cf 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -468,6 +468,9 @@ static void parse_topt(unsigned int topts_len, int opt, char *optarg)
 	if (i >= topts_len)
 		tst_brk(TBROK, "Invalid option '%c' (should not happen)", opt);
 
+	if (*toptions[i].arg)
+		tst_res(TWARN, "Option passed -%c multiple times", opt);
+
 	*(toptions[i].arg) = optarg ? optarg : "";
 }
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH] lib/tst_test: Warn on repeated options
  2019-11-05 12:00 [LTP] [PATCH] lib/tst_test: Warn on repeated options Cyril Hrubis
@ 2019-11-05 13:05 ` Cyril Hrubis
  2019-11-05 13:32   ` Jan Stancek
  0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2019-11-05 13:05 UTC (permalink / raw)
  To: ltp

Hi!
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> CC: Jan Stancek <jstancek@redhat.com>
> ---
>  lib/tst_test.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index c7b46d0d5..f41baf3cf 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -468,6 +468,9 @@ static void parse_topt(unsigned int topts_len, int opt, char *optarg)
>  	if (i >= topts_len)
>  		tst_brk(TBROK, "Invalid option '%c' (should not happen)", opt);
>  
> +	if (*toptions[i].arg)
> +		tst_res(TWARN, "Option passed -%c multiple times", opt);

Obviously the -%c and passed should be swapped, I can do that before
pushing if the patch gets ack.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH] lib/tst_test: Warn on repeated options
  2019-11-05 13:05 ` Cyril Hrubis
@ 2019-11-05 13:32   ` Jan Stancek
  2019-11-05 15:25     ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Stancek @ 2019-11-05 13:32 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> Hi!
> > Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> > CC: Jan Stancek <jstancek@redhat.com>
> > ---
> >  lib/tst_test.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/lib/tst_test.c b/lib/tst_test.c
> > index c7b46d0d5..f41baf3cf 100644
> > --- a/lib/tst_test.c
> > +++ b/lib/tst_test.c
> > @@ -468,6 +468,9 @@ static void parse_topt(unsigned int topts_len, int opt,
> > char *optarg)
> >  	if (i >= topts_len)
> >  		tst_brk(TBROK, "Invalid option '%c' (should not happen)", opt);
> >  
> > +	if (*toptions[i].arg)
> > +		tst_res(TWARN, "Option passed -%c multiple times", opt);
> 
> Obviously the -%c and passed should be swapped, I can do that before
> pushing if the patch gets ack.

Acked-by: Jan Stancek <jstancek@redhat.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH] lib/tst_test: Warn on repeated options
  2019-11-05 13:32   ` Jan Stancek
@ 2019-11-05 15:25     ` Cyril Hrubis
  0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2019-11-05 15:25 UTC (permalink / raw)
  To: ltp

Hi!
Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-05 15:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05 12:00 [LTP] [PATCH] lib/tst_test: Warn on repeated options Cyril Hrubis
2019-11-05 13:05 ` Cyril Hrubis
2019-11-05 13:32   ` Jan Stancek
2019-11-05 15:25     ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.