From 3cea9c403c6d5ff0edb2b8fc99884f2243b1456e Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Mon, 7 Apr 2025 00:26:57 +0200 Subject: [PATCH 1/2] core/mount: remove unused temporary variable --- src/core/mount.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/core/mount.c b/src/core/mount.c index a831bac697..c496375a21 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -2416,7 +2416,6 @@ char* mount_get_what_escaped(const Mount *m) { } char* mount_get_options_escaped(const Mount *m) { - _cleanup_free_ char *escaped = NULL; const char *s = NULL; assert(m); @@ -2425,14 +2424,10 @@ char* mount_get_options_escaped(const Mount *m) { s = m->parameters_proc_self_mountinfo.options; else if (m->from_fragment && m->parameters_fragment.options) s = m->parameters_fragment.options; + if (!s) + return strdup(""); - if (s) { - escaped = utf8_escape_invalid(s); - if (!escaped) - return NULL; - } - - return escaped ? TAKE_PTR(escaped) : strdup(""); + return utf8_escape_invalid(s); } const char* mount_get_fstype(const Mount *m) { From b3cfee2f5d60e0d433246bdef86521228f1157d8 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Mon, 24 Feb 2025 18:32:58 +0100 Subject: [PATCH 2/2] mount-tool: honor arg_canonicalize for ACTION_UMOUNT path_is_absolute() check too Follow-up for 4e24796b5a64064f8b21c07356eba19e9db4bb33 --- src/mount/mount-tool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index de90f9d983..2c64ccdf30 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -418,11 +418,11 @@ static int parse_argv(int argc, char *argv[]) { return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "At least one argument required."); - if (arg_transport != BUS_TRANSPORT_LOCAL) + if (arg_transport != BUS_TRANSPORT_LOCAL || !arg_canonicalize) for (int i = optind; i < argc; i++) if (!path_is_absolute(argv[i])) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "Path must be absolute when operating remotely: %s", + "Path must be absolute when operating remotely or when canonicalization is turned off: %s", argv[i]); } else { if (optind >= argc)