1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-18 10:04:04 +03:00

Merge pull request #32055 from mrc0mmand/pre-rc-coccinelle

Coccinelle-suggested tweaks, pre-rc edition
This commit is contained in:
Luca Boccassi 2024-04-02 21:58:39 +01:00 committed by GitHub
commit 52c15e9c9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 15 additions and 18 deletions

View File

@ -530,7 +530,7 @@ static int parse_one_option(const char *option) {
* - text descriptions prefixed with "%:" or "%keyring:".
* - text description with no prefix.
* - numeric keyring id (ignored in current patch set). */
if (*val == '@' || *val == '%')
if (IN_SET(*val, '@', '%'))
keyring = strndup(val, sep - val);
else
/* add type prefix if missing (crypt_set_keyring_to_link() expects it) */

View File

@ -1711,7 +1711,7 @@ static int pkcs11_acquire_public_key_callback(
switch (attributes[i].type) {
case CKA_CLASS: {
CK_OBJECT_CLASS requested_class = *((CK_OBJECT_CLASS*) attributes[i].pValue);
if (requested_class != CKO_PUBLIC_KEY && requested_class != CKO_CERTIFICATE)
if (!IN_SET(requested_class, CKO_PUBLIC_KEY, CKO_CERTIFICATE))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Selected PKCS#11 object is not a public key or certificate, refusing.");
break;
@ -1743,7 +1743,7 @@ static int pkcs11_acquire_public_key_callback(
candidate_attributes[0].ulValueLen = sizeof(class);
candidate_attributes[1].ulValueLen = sizeof(type);
rv = m->C_GetAttributeValue(session, candidate, candidate_attributes, ELEMENTSOF(candidate_attributes));
if (rv != CKR_OK && rv != CKR_ATTRIBUTE_TYPE_INVALID)
if (!IN_SET(rv, CKR_OK, CKR_ATTRIBUTE_TYPE_INVALID))
return log_error_errno(SYNTHETIC_ERRNO(EIO),
"Failed to get attributes of a selected candidate: %s", sym_p11_kit_strerror(rv));

View File

@ -478,7 +478,7 @@ static int pty_forward_ansi_process(PTYForward *f, size_t offset) {
* since we cannot lookahead to see if the Esc is followed by a \
* we cut a corner here and assume it will be \. */
if (c == '\x07' || c == '\x1b') {
if (IN_SET(c, '\x07', '\x1b')) {
r = insert_window_title_fix(f, i+1);
if (r < 0)
return r;

View File

@ -401,10 +401,8 @@ static int parse_credentials(void) {
int r;
r = read_credential_with_decryption("ssh.listen", (void*) &b, &sz);
if (r < 0)
if (r <= 0)
return r;
if (r == 0)
return 0;
_cleanup_fclose_ FILE *f = NULL;
f = fmemopen_unlocked(b, sz, "r");

View File

@ -748,8 +748,7 @@ static OverlayFSPaths *overlayfs_paths_free(OverlayFSPaths *op) {
free(op->work_dir);
strv_free(op->lower_dirs);
free(op);
return NULL;
return mfree(op);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(OverlayFSPaths *, overlayfs_paths_free);

View File

@ -68,7 +68,7 @@ TEST (test_dirent_is_file) {
}
dir = opendir(t);
if (dir == NULL) {
if (!dir) {
log_error_errno(errno, "Failed to open directory '%s': %m", t);
exit(EXIT_FAILURE);
}
@ -144,7 +144,7 @@ TEST (test_dirent_is_file_with_suffix) {
}
dir = opendir(t);
if (dir == NULL) {
if (!dir) {
log_error_errno(errno, "Failed to open directory '%s': %m", t);
exit(EXIT_FAILURE);
}

View File

@ -375,31 +375,31 @@ TEST(strjoin) {
actual = strjoin("", "foo", "bar");
assert_se(streq(actual, "foobar"));
mfree(actual);
free(actual);
actual = strjoin("foo", "bar", "baz");
assert_se(streq(actual, "foobarbaz"));
mfree(actual);
free(actual);
actual = strjoin("foo", "", "bar", "baz");
assert_se(streq(actual, "foobarbaz"));
mfree(actual);
free(actual);
actual = strjoin("foo", NULL);
assert_se(streq(actual, "foo"));
mfree(actual);
free(actual);
actual = strjoin(NULL, NULL);
assert_se(streq(actual, ""));
mfree(actual);
free(actual);
actual = strjoin(NULL, "foo");
assert_se(streq(actual, ""));
mfree(actual);
free(actual);
actual = strjoin("foo", NULL, "bar");
assert_se(streq(actual, "foo"));
mfree(actual);
free(actual);
}
TEST(strcmp_ptr) {