chiark / gitweb /
treewide: introduce UID_INVALID (and friends) as macro for (uid_t) -1
[elogind.git] / src / libsystemd / sd-bus / bus-error.c
index ad1a66da72fd73d54771ab569597d1423a491a2a..47f90c26f8f466ed8c486025bf9609c6598c93c7 100644 (file)
@@ -35,7 +35,7 @@
 #define BUS_ERROR_OOM SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_NO_MEMORY, "Out of memory")
 #define BUS_ERROR_FAILED SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_FAILED, "Operation failed")
 
-SD_BUS_ERROR_MAPPING = {
+SD_BUS_ERROR_MAPPING(sd_bus_standard) = {
         {"org.freedesktop.DBus.Error.Failed",                           EACCES},
         {"org.freedesktop.DBus.Error.NoMemory",                         ENOMEM},
         {"org.freedesktop.DBus.Error.ServiceUnknown",                   EHOSTUNREACH},
@@ -444,6 +444,7 @@ _public_ int sd_bus_error_set_errno(sd_bus_error *e, int error) {
 }
 
 int bus_error_set_errnofv(sd_bus_error *e, int error, const char *format, va_list ap) {
+        PROTECT_ERRNO;
         int r;
 
         if (error < 0)
@@ -477,8 +478,9 @@ int bus_error_set_errnofv(sd_bus_error *e, int error, const char *format, va_lis
         if (format) {
                 char *m;
 
-                /* First, let's try to fill in the supplied message */
+                /* Then, let's try to fill in the supplied message */
 
+                errno = error; /* Make sure that %m resolves to the specified error */
                 r = vasprintf(&m, format, ap);
                 if (r >= 0) {