chiark / gitweb /
log: allow negative errno values
[elogind.git] / src / timedate / timedated.c
index 8880812b49ffcfd523d4671f80f822bd5945c60a..4af054e6b03fab1d487e01faeceb5fb584a602b3 100644 (file)
 #define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n"
 #define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
 
+SD_BUS_ERROR_MAPPING(timedated) = {
+        {"org.freedesktop.timedate1.NoNTPSupport", ENOTSUP},
+};
+
 typedef struct Context {
         char *zone;
         bool local_rtc;
@@ -254,10 +258,8 @@ static int context_start_ntp(Context *c, sd_bus *bus, sd_bus_error *error) {
         if (r < 0) {
                 if (sd_bus_error_has_name(error, SD_BUS_ERROR_FILE_NOT_FOUND) ||
                     sd_bus_error_has_name(error, "org.freedesktop.systemd1.LoadFailed") ||
-                    sd_bus_error_has_name(error, "org.freedesktop.systemd1.NoSuchUnit")) {
-                        sd_bus_error_set_const(error, "org.freedesktop.timedate1.NoNTPSupport", "NTP not supported.");
-                        return -ENOTSUP;
-                }
+                    sd_bus_error_has_name(error, "org.freedesktop.systemd1.NoSuchUnit"))
+                        return sd_bus_error_set_const(error, "org.freedesktop.timedate1.NoNTPSupport", "NTP not supported.");
 
                 return r;
         }
@@ -298,10 +300,8 @@ static int context_enable_ntp(Context*c, sd_bus *bus, sd_bus_error *error) {
                                 false);
 
         if (r < 0) {
-                if (sd_bus_error_has_name(error, SD_BUS_ERROR_FILE_NOT_FOUND)) {
-                        sd_bus_error_set_const(error, "org.freedesktop.timedate1.NoNTPSupport", "NTP not supported.");
-                        return -ENOTSUP;
-                }
+                if (sd_bus_error_has_name(error, SD_BUS_ERROR_FILE_NOT_FOUND))
+                        return sd_bus_error_set_const(error, "org.freedesktop.timedate1.NoNTPSupport", "NTP not supported.");
 
                 return r;
         }
@@ -429,9 +429,9 @@ static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata, s
         }
 
         log_struct(LOG_INFO,
-                   MESSAGE_ID(SD_MESSAGE_TIMEZONE_CHANGE),
+                   LOG_MESSAGE_ID(SD_MESSAGE_TIMEZONE_CHANGE),
                    "TIMEZONE=%s", c->zone,
-                   "MESSAGE=Changed time zone to '%s'.", c->zone,
+                   LOG_MESSAGE("Changed time zone to '%s'.", c->zone),
                    NULL);
 
         sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "Timezone", NULL);
@@ -581,9 +581,9 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu
         clock_set_hwclock(tm);
 
         log_struct(LOG_INFO,
-                   MESSAGE_ID(SD_MESSAGE_TIME_CHANGE),
+                   LOG_MESSAGE_ID(SD_MESSAGE_TIME_CHANGE),
                    "REALTIME="USEC_FMT, timespec_load(&ts),
-                   "MESSAGE=Changed local time to %s", ctime(&ts.tv_sec),
+                   LOG_MESSAGE("Changed local time to %s", ctime(&ts.tv_sec)),
                    NULL);
 
         return sd_bus_reply_method_return(m, NULL);