cleanup: update bug prone argument comments (#37281)
@DaanDeMeyer Obviously this doesn't fix nearly everything, so gradually
moving things over is probably a smart thing? It seems clang-tidy does
support drop in configs for example:
```
# SPDX-License-Identifier: LGPL-2.1-or-later
---
Checks: '
-*,
bugprone-argument-comment
'
WarningsAsErrors: '*'
```
Its a bit strange that `WarningsAsErrors` isn't propagated, but dropping
this file in src/report/.clang-tiday invokes:
```
[1314/1543][1.5s] /usr/bin/clang-tidy --use-color -extra-arg=-fno-caret-diagnostics -p=/home/jelle/projects/systemd/build -quiet /home/jelle/projec
ts/systemd/src/repart/repart.c
../src/repart/repart.c:4715:41: error: argument name 'pubkey' in comment does not match parameter name 'public' [bugprone-argument-comment,-warning
s-as-errors]
4715 | /* pubkey= */ NULL, /* Turn this one off for the 2nd shard */
| ^
../src/shared/tpm2-util.h:281:108: note: 'public' declared here
281 | int tpm2_calculate_sealing_policy(const Tpm2PCRValue *pcr_values, size_t n_pcr_values, const TPM2B_PUBLIC *public, bool use_pin, const Tpm2
PCRLockPolicy *policy, TPM2B_DIGEST *digest);
| ^
```
So that seems to behave as intended :)
And in some cases I am not sure if switching to the correct argument is
an improvement ie.:
```
../src/bootctl/bootctl-reboot-to-firmware.c:66:51: [38;2;190;132;255m0;1;31merror: argument name 'dispatch_table' in comment does not match paramet
er name 'table' [bugprone-argument-comment,-warnings-as-errors]
66 | r = sd_varlink_dispatch(link, parameters, /* dispatch_table = */ NULL, /* userdata = */ NULL);
| [38;2;190;132;255m0;1;32m ^
../src/systemd/sd-varlink.h:187:98: [38;2;190;132;255m0;1;36mnote: 'table' declared here
187 | int sd_varlink_dispatch(sd_varlink *v, sd_json_variant *parameters, const sd_json_dispatch_field table[], void *userdata);
| [38;2;190;132;255m0;1;32m ^
```
or
```
../src/validatefs/validatefs.c:274:83: [38;2;190;132;255m0;1;31merror: argument name 'ret_len' in comment does not match parameter name 'len' [bugprone-argument-comment,-warnings-as-errors]
274 | (void) blkid_probe_lookup_value(b, "PART_ENTRY_TYPE", &v, /* ret_len= */ NULL);
| [38;2;190;132;255m0;1;32m ^
/usr/include/blkid/blkid.h:455:52: [38;2;190;132;255m0;1;36mnote: 'len' declared here
455 | const char **data, size_t *len)
| [38;2;190;132;255m0;1;32m ^
```
But that's also half a style thing with `len` winning over `ret_len`.
This commit is contained in:
@@ -793,7 +793,7 @@ static int address_update(Address *address) {
|
||||
return r;
|
||||
}
|
||||
|
||||
link_update_operstate(link, /* also_update_master = */ true);
|
||||
link_update_operstate(link, /* also_update_bond_master = */ true);
|
||||
link_check_ready(link);
|
||||
return 0;
|
||||
}
|
||||
@@ -868,7 +868,7 @@ static int address_drop(Address *in, bool removed_by_us) {
|
||||
}
|
||||
}
|
||||
|
||||
link_update_operstate(link, /* also_update_master = */ true);
|
||||
link_update_operstate(link, /* also_update_bond_master = */ true);
|
||||
link_check_ready(link);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1230,6 +1230,6 @@ int manager_reload(Manager *m, sd_bus_message *message) {
|
||||
log_debug("Reloaded.");
|
||||
r = 0;
|
||||
finish:
|
||||
(void) sd_notify(/* unset= */ false, NOTIFY_READY);
|
||||
(void) sd_notify(/* unset_environment= */ false, NOTIFY_READY);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ static int process_vsock_cid(unsigned cid, const char *port) {
|
||||
return log_error_errno(errno, "Failed to connect to vsock:%u:%u: %m", sa.vm.svm_cid, sa.vm.svm_port);
|
||||
|
||||
/* OpenSSH wants us to send a single byte along with the file descriptor, hence do so */
|
||||
r = send_one_fd_iov(STDOUT_FILENO, fd, &iovec_nul_byte, /* n_iovec= */ 1, /* flags= */ 0);
|
||||
r = send_one_fd_iov(STDOUT_FILENO, fd, &iovec_nul_byte, /* iovlen= */ 1, /* flags= */ 0);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to send socket via STDOUT: %m");
|
||||
|
||||
@@ -86,7 +86,7 @@ static int process_unix(const char *path) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to connect to AF_UNIX socket %s: %m", path);
|
||||
|
||||
r = send_one_fd_iov(STDOUT_FILENO, fd, &iovec_nul_byte, /* n_iovec= */ 1, /* flags= */ 0);
|
||||
r = send_one_fd_iov(STDOUT_FILENO, fd, &iovec_nul_byte, /* iovlen= */ 1, /* flags= */ 0);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to send socket via STDOUT: %m");
|
||||
|
||||
@@ -130,7 +130,7 @@ static int process_vsock_mux(const char *path, const char *port) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to send CONNECT to %s:%s: %m", path, port);
|
||||
|
||||
r = send_one_fd_iov(STDOUT_FILENO, fd, &iovec_nul_byte, /* n_iovec= */ 1, /* flags= */ 0);
|
||||
r = send_one_fd_iov(STDOUT_FILENO, fd, &iovec_nul_byte, /* iovlen= */ 1, /* flags= */ 0);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to send socket via STDOUT: %m");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user