Skip to content

Commit baed6c8

Browse files
committed
Removing unused code.
1 parent 58829c1 commit baed6c8

File tree

2 files changed

+28
-56
lines changed

2 files changed

+28
-56
lines changed

picoquic/config.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,15 @@ int picoquic_config_command_line(int opt, int * p_optind, int argc, char const *
595595
else {
596596
if (option_table[option_index].nb_params_required > 0) {
597597
params[0].param = optarg;
598-
if (optarg == NULL) {
598+
if (optarg == NULL || option_table[option_index].nb_params_required > 1) {
599599
fprintf(stderr, "option -%c requires %d arguments\n", opt, option_table[option_index].nb_params_required);
600600
ret = -1;
601601
}
602602
else {
603603
params[0].length = strlen(optarg);
604604
nb_params++;
605+
#if 0
606+
/* Removing this code as no options have more than one parameter */
605607
while (nb_params < option_table[option_index].nb_params_required) {
606608
if (*p_optind + 1 > argc) {
607609
fprintf(stderr, "option -%c requires %d arguments\n", opt, option_table[option_index].nb_params_required);
@@ -615,6 +617,7 @@ int picoquic_config_command_line(int opt, int * p_optind, int argc, char const *
615617
*p_optind += 1;
616618
}
617619
}
620+
#endif
618621
}
619622
}
620623
}

picoquictest/config_test.c

Lines changed: 24 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ int config_option_letters_test()
4545
return ret;
4646
}
4747

48+
const uint8_t null_key[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
49+
4850
static picoquic_quic_config_t param1 = {
4951
1024, /*uint32_t nb_connections; */
5052
"/data/github/picoquic", /* char const* solution_dir; */
@@ -78,7 +80,7 @@ static picoquic_quic_config_t param1 = {
7880
"/data/www/", /* char const* www_dir; */
7981
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
8082
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, /* uint8_t reset_seed[16]; */
81-
{ 0 }, /* const uint8_t* ticket_encryption_key; */
83+
null_key, /* const uint8_t* ticket_encryption_key; */
8284
0, /* size_t ticket_encryption_key_length; */
8385
/* Server flags */
8486
1, /* unsigned int do_retry : 1; */
@@ -210,33 +212,34 @@ static config_error_test_t config_errors[] = {
210212
{ 1, { "-c"}},
211213
{ 1, { "-k"}},
212214
{ 1, { "-x"}},
213-
{ 2, { "-x", "-1024"}},
215+
{ 2, { "-x", "nb_cnx"}},
214216
{ 1, { "-l"}},
215217
{ 1, { "-b"}},
216218
{ 1, { "-q"}},
217-
{ 2, { "-p", "-443"}},
219+
{ 2, { "-p", "port"}},
218220
{ 1, { "-p" }},
219221
{ 1, { "-e", }},
220222
{ 2, { "-e", "a" }},
221223
{ 1, { "-m" }},
222224
{ 1, { "-m", "-1"}},
223225
{ 2, { "-m", "15360"}},
224-
{ 2, { "-P", "-3"}},
225-
{ 2, { "-O", "-2"}},
226+
{ 2, { "-P", "33"}},
227+
{ 2, { "-O", "22"}},
226228
{ 2, { "-M", "5"}},
227229
{ 2, { "-R", "17"}},
228230
{ 1, { "-w" }},
229231
{ 2, { "-s", "0123456789abcdexyedcba9876543210"}},
230232
{ 2, { "-s", "0123456789abcdeffedcba987654321"}},
231233
{ 2, { "-s", "0123456789abcdeffedcba98765432"}},
232-
{ 2, { "-B", "-1"}},
234+
{ 2, { "-B", "buffer"}},
233235
{ 1, { "-F" }},
234236
{ 2, { "-j", "3" }},
235237
{ 1, { "-i" }},
236238
{ 2, { "-I", "-1" }},
237239
{ 2, { "-I", "255" }},
238240
{ 2, { "-U", "XY000002" }},
239-
{ 2, { "-W", "-1" }}
241+
{ 2, { "-W", "cwin" }},
242+
{ 2, { "-d", "idle" }}
240243
};
241244

242245
static size_t nb_config_errors = sizeof(config_errors) / sizeof(config_error_test_t);
@@ -368,17 +371,23 @@ static int config_parse_command_line(picoquic_quic_config_t* actual, const char*
368371
ret = -1;
369372
break;
370373
}
371-
opt = x[1];
372-
opt_ind++;
373374
if (opt_ind < argc) {
374-
optval = argv[opt_ind];
375-
if (optval[0] == '-') {
376-
optval = NULL;
377-
}
378-
else {
379-
opt_ind++;
375+
opt = x[1];
376+
opt_ind++;
377+
if (opt_ind < argc) {
378+
optval = argv[opt_ind];
379+
if (optval[0] == '-') {
380+
optval = NULL;
381+
}
382+
else {
383+
opt_ind++;
384+
}
380385
}
381386
}
387+
else {
388+
optval = NULL;
389+
}
390+
382391
ret = picoquic_config_command_line(opt, &opt_ind, argc, argv, optval, actual);
383392
if (ret != 0) {
384393
if (!expect_error) {
@@ -394,49 +403,9 @@ static int config_parse_command_line(picoquic_quic_config_t* actual, const char*
394403
static int config_parse_command_line_test(const picoquic_quic_config_t* expected, const char** argv, int argc)
395404
{
396405
int ret = 0;
397-
int opt_ind = 0;
398406
picoquic_quic_config_t actual;
399407

400-
#if 1
401408
ret = config_parse_command_line(&actual, argv, argc, 0);
402-
#else
403-
404-
405-
picoquic_config_init(&actual);
406-
407-
while (opt_ind < argc && ret == 0) {
408-
const char* x = argv[opt_ind];
409-
const char* optval = NULL;
410-
int opt;
411-
if (x == NULL) {
412-
/* could not parse to the end! */
413-
DBG_PRINTF("Unexpected stop after %d arguments, expected %d", opt_ind, argc);
414-
ret = -1;
415-
break;
416-
}
417-
else if (x[0] != '-' || x[1] == 0 || x[2] != 0) {
418-
/* could not parse to the end! */
419-
DBG_PRINTF("Unexpected argument: %s", x);
420-
ret = -1;
421-
break;
422-
}
423-
opt = x[1];
424-
opt_ind++;
425-
if (opt_ind < argc) {
426-
optval = argv[opt_ind];
427-
if (optval[0] == '-') {
428-
optval = NULL;
429-
}
430-
else {
431-
opt_ind++;
432-
}
433-
}
434-
ret = picoquic_config_command_line(opt, &opt_ind, argc, argv, optval, &actual);
435-
if (ret != 0) {
436-
DBG_PRINTF("Could not parse opt -%c", opt);
437-
}
438-
}
439-
#endif
440409

441410
if (ret == 0) {
442411
ret = config_test_compare(expected, &actual);

0 commit comments

Comments
 (0)