]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
varlink-util: format system errors via %m in varlink_call_and_log()
authorLennart Poettering <lennart@poettering.net>
Thu, 5 Jun 2025 11:17:17 +0000 (13:17 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 5 Jun 2025 12:28:14 +0000 (14:28 +0200)
This kinda does what bee59ab901ca199d194f440cf37f7645004d3054 did for
varlinkctl also for the generic varlink_call_and_log() handler.

src/libsystemd/sd-varlink/varlink-util.c

index dfefe08862860b7cd3572cbbde89c22356df8aa7..cc18656d13815dd16861606024be7cb4a0314ad6 100644 (file)
@@ -59,9 +59,13 @@ int varlink_call_and_log(
         r = sd_varlink_call(v, method, parameters, &reply, &error_id);
         if (r < 0)
                 return log_error_errno(r, "Failed to issue %s() varlink call: %m", method);
-        if (error_id)
-                return log_error_errno(sd_varlink_error_to_errno(error_id, reply),
-                                         "Failed to issue %s() varlink call: %s", method, error_id);
+        if (error_id) {
+                r = sd_varlink_error_to_errno(error_id, reply); /* If this is a system errno style error, output it with %m */
+                if (r != -EBADR)
+                        return log_error_errno(r, "Failed to issue %s() varlink call: %m", method);
+
+                return log_error_errno(r, "Failed to issue %s() varlink call: %s", method, error_id);
+        }
 
         if (ret_parameters)
                 *ret_parameters = TAKE_PTR(reply);