tidy-up: miscellaneous

- badwords: replace stray synonyms with 'null-terminator'.
- tests/FILEFORMAT.md: tidy up feature descriptions.
- printf: replace stray `%i` masks with `%d` for consistency.
- pytest: add comments for empty excepts to try silencing GitHub CodeQL
  warnings.
- tool1394, unit1675: merge nested `if`s.
- dnscache: fix typo in comment.
- fix whitespace, indent and newlines.

Closes #21921
This commit is contained in:
Viktor Szakats 2026-06-05 23:02:11 +02:00
parent 849317ff5c
commit 952b04474c
No known key found for this signature in database
31 changed files with 90 additions and 90 deletions

View file

@ -197,6 +197,7 @@ class TestErrors:
conn.recv(1) # wait for ClientHello
conn.close()
except Exception:
# ignore expected socket error
pass
t = threading.Thread(target=accept_and_close)

View file

@ -89,6 +89,7 @@ class RunProfile:
'rss': mem.rss,
})
except psutil.NoSuchProcess:
# process may exit between sampling ticks: ignore this
pass
def finish(self):
@ -238,6 +239,7 @@ class RunTcpDump:
try:
self._proc.wait(timeout=1)
except subprocess.TimeoutExpired:
# timeout means tcpdump is still running
pass
except Exception:
log.exception('Tcpdump')

View file

@ -37,6 +37,7 @@ async def echo(websocket):
async for message in websocket:
await websocket.send(message)
except ConnectionClosedError:
# websocket connection closed by client
pass

View file

@ -203,7 +203,7 @@ static int t530_checkForCompletion(CURLM *multi, int *success)
*success = 0;
}
else {
curl_mfprintf(stderr, "%s got an unexpected message from curl: %i\n",
curl_mfprintf(stderr, "%s got an unexpected message from curl: %d\n",
t530_tag(), message->msg);
result = 1;
*success = 0;
@ -247,7 +247,7 @@ static CURLMcode socket_action(CURLM *multi, curl_socket_t s, int evBitmask,
CURLMcode mresult = curl_multi_socket_action(multi, s, evBitmask,
&numhandles);
if(mresult != CURLM_OK) {
curl_mfprintf(stderr, "%s curl error on %s (%i) %s\n",
curl_mfprintf(stderr, "%s curl error on %s (%d) %s\n",
t530_tag(), info, mresult, curl_multi_strerror(mresult));
}
return mresult;

View file

@ -150,7 +150,7 @@ static int t582_checkForCompletion(CURLM *multi, int *success)
*success = 0;
}
else {
curl_mfprintf(stderr, "Got an unexpected message from curl: %i\n",
curl_mfprintf(stderr, "Got an unexpected message from curl: %d\n",
message->msg);
result = 1;
*success = 0;
@ -194,7 +194,7 @@ static void notifyCurl(CURLM *multi, curl_socket_t s, int evBitmask,
CURLMcode mresult = curl_multi_socket_action(multi, s, evBitmask,
&numhandles);
if(mresult != CURLM_OK) {
curl_mfprintf(stderr, "curl error on %s (%i) %s\n",
curl_mfprintf(stderr, "curl error on %s (%d) %s\n",
info, mresult, curl_multi_strerror(mresult));
}
}

View file

@ -249,7 +249,7 @@ static int t758_checkForCompletion(CURLM *multi, int *success)
*success = 0;
}
else {
curl_mfprintf(stderr, "%s got an unexpected message from curl: %i\n",
curl_mfprintf(stderr, "%s got an unexpected message from curl: %d\n",
t758_tag(), message->msg);
result = 1;
*success = 0;
@ -293,7 +293,7 @@ static CURLMcode t758_saction(CURLM *multi, curl_socket_t s,
CURLMcode mresult = curl_multi_socket_action(multi, s, evBitmask,
&numhandles);
if(mresult != CURLM_OK) {
curl_mfprintf(stderr, "%s curl error on %s (%i) %s\n",
curl_mfprintf(stderr, "%s curl error on %s (%d) %s\n",
t758_tag(), info, mresult, curl_multi_strerror(mresult));
}
return mresult;

View file

@ -180,7 +180,6 @@ static ssize_t write_wincon(int fd, const void *buf, size_t count)
* in nbytes or it fails with a condition that cannot be handled with a simple
* retry of the read call.
*/
static ssize_t fullread(int filedes, void *buffer, size_t nbytes)
{
int error;
@ -234,7 +233,6 @@ static ssize_t fullread(int filedes, void *buffer, size_t nbytes)
* indicated in nbytes or it fails with a condition that cannot be handled
* with a simple retry of the write call.
*/
static ssize_t fullwrite(int filedes, const void *buffer, size_t nbytes)
{
int error;
@ -283,7 +281,6 @@ static ssize_t fullwrite(int filedes, const void *buffer, size_t nbytes)
* read or FALSE when an unrecoverable error has been detected. Failure of this
* function is an indication that the sockfilt process should terminate.
*/
static bool read_stdin(void *buffer, size_t nbytes)
{
ssize_t nread = fullread(fileno(stdin), buffer, nbytes);
@ -300,7 +297,6 @@ static bool read_stdin(void *buffer, size_t nbytes)
* written or FALSE when an unrecoverable error has been detected. Failure of
* this function is an indication that the sockfilt process should terminate.
*/
static bool write_stdout(const void *buffer, size_t nbytes)
{
ssize_t nwrite;

View file

@ -88,12 +88,10 @@ static CURLcode test_tool1394(const char *arg)
fail("assertion failure");
}
}
else {
if(certname) {
curl_mprintf("expected certname NULL but got '%s' "
"for -E param '%s'\n", certname, p->param);
fail("assertion failure");
}
else if(certname) {
curl_mprintf("expected certname NULL but got '%s' "
"for -E param '%s'\n", certname, p->param);
fail("assertion failure");
}
if(p->passwd) {
if(passphrase) {
@ -109,12 +107,10 @@ static CURLcode test_tool1394(const char *arg)
fail("assertion failure");
}
}
else {
if(passphrase) {
curl_mprintf("expected passphrase NULL but got '%s' "
"for -E param '%s'\n", passphrase, p->param);
fail("assertion failure");
}
else if(passphrase) {
curl_mprintf("expected passphrase NULL but got '%s' "
"for -E param '%s'\n", passphrase, p->param);
fail("assertion failure");
}
if(certname)
curlx_free(certname);

View file

@ -117,12 +117,10 @@ static CURLcode test_unit1655(const char *arg)
fail_unless(victim.canary3 == 41,
"three-byte buffer overwrite has happened");
}
else {
if(d == DOH_OK) {
fail_unless(olen <= sizeof(victim.dohbuffer),
"wrote outside bounds");
fail_unless(olen > strlen(name), "unrealistic low size");
}
else if(d == DOH_OK) {
fail_unless(olen <= sizeof(victim.dohbuffer),
"wrote outside bounds");
fail_unless(olen > strlen(name), "unrealistic low size");
}
}
} while(0);

View file

@ -29,7 +29,7 @@ static CURLcode test_unit1675(const char *arg)
{
UNITTEST_BEGIN_SIMPLE
/* Test ipv4_normalize */
/* Test ipv4_normalize */
{
struct dynbuf host;
int fails = 0;
@ -123,13 +123,11 @@ static CURLcode test_unit1675(const char *arg)
fails++;
}
}
else {
if(rc == HOST_IPV4) {
curl_mfprintf(stderr, "ipv4_normalize('%s') succeeded unexpectedly:"
" got '%s'\n",
tests[i].in, curlx_dyn_ptr(&host));
fails++;
}
else if(rc == HOST_IPV4) {
curl_mfprintf(stderr, "ipv4_normalize('%s') succeeded unexpectedly:"
" got '%s'\n",
tests[i].in, curlx_dyn_ptr(&host));
fails++;
}
}
curlx_dyn_free(&host);
@ -238,12 +236,10 @@ static CURLcode test_unit1675(const char *arg)
}
}
}
else {
if(!uc) {
curl_mfprintf(stderr, "ipv6_parse('%s') succeeded unexpectedly\n",
tests[i].in);
fails++;
}
else if(!uc) {
curl_mfprintf(stderr, "ipv6_parse('%s') succeeded unexpectedly\n",
tests[i].in);
fails++;
}
curlx_free(u.host);
curlx_free(u.zoneid);