lib/tst_test: Warn on repeated options
PATCH 1/1 lib/tst_test: Warn on repeated options
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.
--- lib/tst_test.c | 3 +++ 1 file changed, 3 insertions(+)
lib/tst_test.c +3 -0
@@ -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 :"" ; }
Signature · 1 line
2.21.0
PATCH 1/1 lib/tst_test: Warn on repeated options
Hi!
Quoted 11 lines
Signed-off-by Cyril Hrubis <[email protected]>CC Jan Stancek <[email protected]>--- lib/tst_test.c | 3 +++ 1 file changed, 3 insertions(+)lib/tst_test.c +0
-0
lib/tst_test.c static void parse_topt(unsigned int topts_len, int opt, char *optarg) · line 472
Quoted 5 lines
lib/tst_test.c +2
-0@@ -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.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 lib/tst_test: Warn on repeated options
----- Original Message -----
Quoted 16 lines
Hi!
Quoted 15 lines
Signed-off-by Cyril Hrubis <[email protected]>CC Jan Stancek <[email protected]>--- lib/tst_test.c | 3 +++ 1 file changed, 3 insertions(+)lib/tst_test.c +0
-0@@ -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);
Quoted 5 lines
lib/tst_test.c static void parse_topt(unsigned int topts_len, int opt, char *optarg) · line 472
Quoted 2 lines
lib/tst_test.c +2
-0+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.
PATCH 1/1 lib/tst_test: Warn on repeated options
Hi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]