summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2023-07-14 17:39:05 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2023-07-14 23:49:01 +0200
commitbe492020eca6493ab0869ef3aee4ab629180bc7f (patch)
tree095998db0198fc0aba9c7c024259ebe57a7fb60a /src
parentMerge pull request #28370 from ldv-alt/cname (diff)
downloadsystemd-be492020eca6493ab0869ef3aee4ab629180bc7f.tar.xz
systemd-be492020eca6493ab0869ef3aee4ab629180bc7f.zip
tree-wide: a bunch of Coccinelle-suggested tweaks
rc2 edition
Diffstat (limited to 'src')
-rw-r--r--src/analyze/analyze-pcrs.c2
-rw-r--r--src/basic/string-util.c3
-rw-r--r--src/shared/creds-util.c2
-rw-r--r--src/socket-activate/socket-activate.c2
4 files changed, 4 insertions, 5 deletions
diff --git a/src/analyze/analyze-pcrs.c b/src/analyze/analyze-pcrs.c
index df678ab935..82f0f39288 100644
--- a/src/analyze/analyze-pcrs.c
+++ b/src/analyze/analyze-pcrs.c
@@ -18,7 +18,7 @@ static int get_pcr_alg(const char **ret) {
return log_oom();
if (access(p, F_OK) < 0) {
- if (errno != -ENOENT)
+ if (errno != ENOENT)
return log_error_errno(errno, "Failed to determine whether %s exists: %m", p);
} else {
*ret = alg;
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index 5be8be3d26..d3b6db9c55 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -535,8 +535,7 @@ char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne
for (const char *p = s + len; p < j; ) {
size_t slen = ansi_sequence_length(p, j - p);
if (slen > 0) {
- memcpy(dst, p, slen);
- dst += slen;
+ dst = mempcpy(dst, p, slen);
p += slen;
} else
p = utf8_next_char(p);
diff --git a/src/shared/creds-util.c b/src/shared/creds-util.c
index 40d6bc9514..573900f870 100644
--- a/src/shared/creds-util.c
+++ b/src/shared/creds-util.c
@@ -70,7 +70,7 @@ bool credential_glob_valid(const char *s) {
return false;
/* Make a copy of the string without the '*' suffix */
- a = strndupa(s, n);
+ a = strndupa_safe(s, n);
return credential_name_valid(a);
}
diff --git a/src/socket-activate/socket-activate.c b/src/socket-activate/socket-activate.c
index 2e19d125c3..644bed0dcc 100644
--- a/src/socket-activate/socket-activate.c
+++ b/src/socket-activate/socket-activate.c
@@ -458,7 +458,7 @@ static int run(int argc, char **argv) {
if (!exec_argv)
return log_oom();
- assert(strv_length(exec_argv) > 0);
+ assert(!strv_isempty(exec_argv));
r = install_chld_handler();
if (r < 0)