tidy-up: miscellaneous

- whitespace, indent, comments, clang-format.
- openssl: move feature guards within function blocks.
- tunit: drop redundant blocks.

Closes #20361
This commit is contained in:
Viktor Szakats 2026-01-16 18:13:44 +01:00
parent 2c6f13093e
commit 814b54d83e
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
45 changed files with 1521 additions and 1527 deletions

View file

@ -50,7 +50,7 @@ lib%TESTNUMBER
CURLOPT_PROXYHEADER is ignored CURLHEADER_UNIFIED
</name>
<command>
http://the.old.moo.%TESTNUMBER:%HTTPPORT/%TESTNUMBER %HOSTIP:%PROXYPORT
http://the.old.moo.%TESTNUMBER:%HTTPPORT/%TESTNUMBER %HOSTIP:%PROXYPORT
</command>
<features>
proxy

View file

@ -52,7 +52,7 @@ lib%TESTNUMBER
CURLOPT_PROXYHEADER: separate host/proxy headers
</name>
<command>
http://the.old.moo.%TESTNUMBER:%HTTPPORT/%TESTNUMBER %HOSTIP:%PROXYPORT
http://the.old.moo.%TESTNUMBER:%HTTPPORT/%TESTNUMBER %HOSTIP:%PROXYPORT
</command>
<features>
proxy

View file

@ -51,7 +51,7 @@ lib%TESTNUMBER
Same headers with CURLOPT_HEADEROPT == CURLHEADER_UNIFIED
</name>
<command>
http://the.old.moo.%TESTNUMBER:%HTTPPORT/%TESTNUMBER %HOSTIP:%PROXYPORT
http://the.old.moo.%TESTNUMBER:%HTTPPORT/%TESTNUMBER %HOSTIP:%PROXYPORT
</command>
<features>
proxy

View file

@ -42,7 +42,7 @@ lib%TESTNUMBER
Separately specified proxy/server headers sent in a proxy GET
</name>
<command>
http://the.old.moo:%HTTPPORT/%TESTNUMBER %HOSTIP:%PROXYPORT
http://the.old.moo:%HTTPPORT/%TESTNUMBER %HOSTIP:%PROXYPORT
</command>
<features>
proxy

View file

@ -30,7 +30,7 @@ lib%TESTNUMBER
HTTP request-injection in URL sent over proxy
</name>
<command>
"http://the.old.moo:%HTTPPORT/%TESTNUMBER" %HOSTIP:%PROXYPORT
"http://the.old.moo:%HTTPPORT/%TESTNUMBER" %HOSTIP:%PROXYPORT
</command>
<features>
proxy

View file

@ -12,12 +12,12 @@ HTTP Digest auth
<!--
Explanation for the duplicate 400 requests:
Explanation for the duplicate 400 requests:
libcurl does not detect that a given Digest password is wrong already on the
first 401 response (as the data400 gives). libcurl will instead consider the
new response just as a duplicate and it sends another and detects the auth
problem on the second 401 response!
libcurl does not detect that a given Digest password is wrong already on the
first 401 response (as the data400 gives). libcurl will instead consider the
new response just as a duplicate and it sends another and detects the auth
problem on the second 401 response!
-->

View file

@ -17,12 +17,12 @@ ensure that the order does not matter. -->
<!--
Explanation for the duplicate 400 requests:
Explanation for the duplicate 400 requests:
libcurl does not detect that a given Digest password is wrong already on the
first 401 response (as the data400 gives). libcurl will instead consider the
new response just as a duplicate and it sends another and detects the auth
problem on the second 401 response!
libcurl does not detect that a given Digest password is wrong already on the
first 401 response (as the data400 gives). libcurl will instead consider the
new response just as a duplicate and it sends another and detects the auth
problem on the second 401 response!
-->

View file

@ -30,7 +30,7 @@ IMAP custom FETCH with larger literal response (~7KB)
</name>
# The quoted string contains {50} which must not be parsed as a literal
<command>
imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/ -u user:secret -X 'FETCH 456 ("fake {50}" BODY[TEXT])'
imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/ -u user:secret -X 'FETCH 456 ("fake {50}" BODY[TEXT])'
</command>
</client>

View file

@ -36,7 +36,7 @@ http
<name>
--remove-on-error with --no-clobber and an added number
</name>
<command option="no-output">
<command option="no-output">
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -o %LOGDIR/save --remove-on-error --no-clobber
</command>
</client>

View file

@ -37,7 +37,7 @@ imap
IMAP custom request does not check continuation data
</name>
<command>
imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/ -u user:secret -X 'FETCH 123 BODY[1]'
imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/ -u user:secret -X 'FETCH 123 BODY[1]'
</command>
</client>

View file

@ -28,48 +28,48 @@
static CURLcode test_tool1622(const char *arg)
{
UNITTEST_BEGIN_SIMPLE
{
char buffer[9];
curl_off_t secs;
int i;
static const curl_off_t check[] = {
/* bytes to check */
131072,
12645826,
1073741824,
12938588979,
1099445657078333,
0 /* end of list */
};
puts("time2str");
for(i = 0, secs = 0; i < 63; i++) {
time2str(buffer, sizeof(buffer), secs);
curl_mprintf("%20" FMT_OFF_T " - %s\n", secs, buffer);
if(strlen(buffer) != 8) {
curl_mprintf("^^ was too long!\n");
}
secs *= 2;
secs++;
char buffer[9];
curl_off_t secs;
int i;
static const curl_off_t check[] = {
/* bytes to check */
131072,
12645826,
1073741824,
12938588979,
1099445657078333,
0 /* end of list */
};
puts("time2str");
for(i = 0, secs = 0; i < 63; i++) {
time2str(buffer, sizeof(buffer), secs);
curl_mprintf("%20" FMT_OFF_T " - %s\n", secs, buffer);
if(strlen(buffer) != 8) {
curl_mprintf("^^ was too long!\n");
}
puts("max5data");
for(i = 0, secs = 0; i < 63; i++) {
max5data(secs, buffer, sizeof(buffer));
curl_mprintf("%20" FMT_OFF_T " - %s\n", secs, buffer);
if(strlen(buffer) != 5) {
curl_mprintf("^^ was too long!\n");
}
secs *= 2;
secs++;
secs *= 2;
secs++;
}
puts("max5data");
for(i = 0, secs = 0; i < 63; i++) {
max5data(secs, buffer, sizeof(buffer));
curl_mprintf("%20" FMT_OFF_T " - %s\n", secs, buffer);
if(strlen(buffer) != 5) {
curl_mprintf("^^ was too long!\n");
}
for(i = 0; check[i]; i++) {
secs = check[i];
max5data(secs, buffer, sizeof(buffer));
curl_mprintf("%20" FMT_OFF_T " - %s\n", secs, buffer);
if(strlen(buffer) != 5) {
curl_mprintf("^^ was too long!\n");
}
secs *= 2;
secs++;
}
for(i = 0; check[i]; i++) {
secs = check[i];
max5data(secs, buffer, sizeof(buffer));
curl_mprintf("%20" FMT_OFF_T " - %s\n", secs, buffer);
if(strlen(buffer) != 5) {
curl_mprintf("^^ was too long!\n");
}
}
UNITTEST_END_SIMPLE
}

View file

@ -34,94 +34,93 @@ struct check1623 {
static CURLcode test_tool1623(const char *arg)
{
UNITTEST_BEGIN_SIMPLE
{
int i;
static const struct check1623 check[] = {
{ "0", 0, PARAM_OK},
{ "00", 0, PARAM_OK},
{ "000", 0, PARAM_OK},
{ "1", 1, PARAM_OK},
{ "1b", 1, PARAM_OK},
{ "99B", 99, PARAM_OK},
{ "2", 2, PARAM_OK},
{ "3", 3, PARAM_OK},
{ "4", 4, PARAM_OK},
{ "5", 5, PARAM_OK},
{ "6", 6, PARAM_OK},
{ "7", 7, PARAM_OK},
{ "77", 77, PARAM_OK},
{ "8", 8, PARAM_OK},
{ "9", 9, PARAM_OK},
{ "10", 10, PARAM_OK},
{ "010", 10, PARAM_OK},
{ "000000000000000000000000000000000010", 10, PARAM_OK},
{ "1k", 1024, PARAM_OK},
{ "2K", 2048, PARAM_OK},
{ "3k", 3072, PARAM_OK},
{ "4K", 4096, PARAM_OK},
{ "5k", 5120, PARAM_OK},
{ "6K", 6144, PARAM_OK},
{ "7k", 7168, PARAM_OK},
{ "8K", 8192, PARAM_OK},
{ "9k", 9216, PARAM_OK},
{ "10K", 10240, PARAM_OK},
{ "20M", 20971520, PARAM_OK},
{ "30G", 32212254720, PARAM_OK},
{ "40T", 43980465111040, PARAM_OK},
{ "50P", 56294995342131200, PARAM_OK},
{ "1.1k", 1126, PARAM_OK},
{ "1.01k", 1034, PARAM_OK},
{ "1.001k", 1025, PARAM_OK},
{ "1.0001k", 1024, PARAM_OK},
{ "22.1m", 23173529, PARAM_OK},
{ "22.01m", 23079157, PARAM_OK},
{ "22.001m", 23069720, PARAM_OK},
{ "22.0001m", 23068776, PARAM_OK},
{ "22.00001m", 23068682, PARAM_OK},
{ "22.000001m", 23068673, PARAM_OK},
{ "22.0000001m", 23068672, PARAM_OK},
{ "22.000000001m", 23068672, PARAM_OK},
{ "3.4", 0, PARAM_BAD_USE},
{ "3.14b", 0, PARAM_BAD_USE},
{ "5000.9P", 5630512844129278361, PARAM_OK},
{ "5000.99P", 5630614175120894197, PARAM_OK},
{ "5000.999P", 5630624308220055781, PARAM_OK},
{ "5000.9999P", 5630625321529969316, PARAM_OK},
{ "8191P", 9222246136947933184, PARAM_OK},
{ "8191.9999999P", 9223372036735343194, PARAM_OK},
{ "8192P", 0, PARAM_NUMBER_TOO_LARGE},
{ "9223372036854775807", 9223372036854775807, PARAM_OK},
{ "9223372036854775808", 0, PARAM_NUMBER_TOO_LARGE},
{ "a", 0, PARAM_BAD_NUMERIC},
{ "-2", 0, PARAM_BAD_NUMERIC},
{ "+2", 0, PARAM_BAD_NUMERIC},
{ "2,2k", 0, PARAM_BAD_USE},
{ NULL, 0, PARAM_OK } /* end of list */
};
for(i = 0; check[i].input; i++) {
bool ok = FALSE;
curl_off_t output = 0;
ParameterError err =
GetSizeParameter(check[i].input, &output);
if(err != check[i].err)
curl_mprintf("'%s' unexpectedly returned %d \n",
check[i].input, err);
else if(check[i].amount != output)
curl_mprintf("'%s' unexpectedly gave %" FMT_OFF_T "\n",
check[i].input, output);
else {
int i;
static const struct check1623 check[] = {
{ "0", 0, PARAM_OK },
{ "00", 0, PARAM_OK },
{ "000", 0, PARAM_OK },
{ "1", 1, PARAM_OK },
{ "1b", 1, PARAM_OK },
{ "99B", 99, PARAM_OK },
{ "2", 2, PARAM_OK },
{ "3", 3, PARAM_OK },
{ "4", 4, PARAM_OK },
{ "5", 5, PARAM_OK },
{ "6", 6, PARAM_OK },
{ "7", 7, PARAM_OK },
{ "77", 77, PARAM_OK },
{ "8", 8, PARAM_OK },
{ "9", 9, PARAM_OK },
{ "10", 10, PARAM_OK },
{ "010", 10, PARAM_OK },
{ "000000000000000000000000000000000010", 10, PARAM_OK },
{ "1k", 1024, PARAM_OK },
{ "2K", 2048, PARAM_OK },
{ "3k", 3072, PARAM_OK },
{ "4K", 4096, PARAM_OK },
{ "5k", 5120, PARAM_OK },
{ "6K", 6144, PARAM_OK },
{ "7k", 7168, PARAM_OK },
{ "8K", 8192, PARAM_OK },
{ "9k", 9216, PARAM_OK },
{ "10K", 10240, PARAM_OK },
{ "20M", 20971520, PARAM_OK },
{ "30G", 32212254720, PARAM_OK },
{ "40T", 43980465111040, PARAM_OK },
{ "50P", 56294995342131200, PARAM_OK },
{ "1.1k", 1126, PARAM_OK },
{ "1.01k", 1034, PARAM_OK },
{ "1.001k", 1025, PARAM_OK },
{ "1.0001k", 1024, PARAM_OK },
{ "22.1m", 23173529, PARAM_OK },
{ "22.01m", 23079157, PARAM_OK },
{ "22.001m", 23069720, PARAM_OK },
{ "22.0001m", 23068776, PARAM_OK },
{ "22.00001m", 23068682, PARAM_OK },
{ "22.000001m", 23068673, PARAM_OK },
{ "22.0000001m", 23068672, PARAM_OK },
{ "22.000000001m", 23068672, PARAM_OK },
{ "3.4", 0, PARAM_BAD_USE },
{ "3.14b", 0, PARAM_BAD_USE },
{ "5000.9P", 5630512844129278361, PARAM_OK },
{ "5000.99P", 5630614175120894197, PARAM_OK },
{ "5000.999P", 5630624308220055781, PARAM_OK },
{ "5000.9999P", 5630625321529969316, PARAM_OK },
{ "8191P", 9222246136947933184, PARAM_OK },
{ "8191.9999999P", 9223372036735343194, PARAM_OK },
{ "8192P", 0, PARAM_NUMBER_TOO_LARGE },
{ "9223372036854775807", 9223372036854775807, PARAM_OK },
{ "9223372036854775808", 0, PARAM_NUMBER_TOO_LARGE },
{ "a", 0, PARAM_BAD_NUMERIC },
{ "-2", 0, PARAM_BAD_NUMERIC },
{ "+2", 0, PARAM_BAD_NUMERIC },
{ "2,2k", 0, PARAM_BAD_USE },
{ NULL, 0, PARAM_OK } /* end of list */
};
for(i = 0; check[i].input; i++) {
bool ok = FALSE;
curl_off_t output = 0;
ParameterError err = GetSizeParameter(check[i].input, &output);
if(err != check[i].err)
curl_mprintf("'%s' unexpectedly returned %d \n",
check[i].input, err);
else if(check[i].amount != output)
curl_mprintf("'%s' unexpectedly gave %" FMT_OFF_T "\n",
check[i].input, output);
else {
#if 0 /* enable for debugging */
if(err)
curl_mprintf("'%s' returned %d\n", check[i].input, err);
else
curl_mprintf("'%s' == %" FMT_OFF_T "\n", check[i].input, output);
if(err)
curl_mprintf("'%s' returned %d\n", check[i].input, err);
else
curl_mprintf("'%s' == %" FMT_OFF_T "\n", check[i].input, output);
#endif
ok = TRUE;
}
if(!ok)
unitfail++;
ok = TRUE;
}
if(!ok)
unitfail++;
}
UNITTEST_END_SIMPLE
}