chiark / gitweb /
locale: make sure that l is freed
[elogind.git] / src / locale / localed.c
index b8007d7..a2d3814 100644 (file)
@@ -271,24 +271,8 @@ static int read_data_x11(void) {
         free_data_x11();
 
         f = fopen("/etc/X11/xorg.conf.d/00-keyboard.conf", "re");
         free_data_x11();
 
         f = fopen("/etc/X11/xorg.conf.d/00-keyboard.conf", "re");
-        if (!f) {
-                if (errno == ENOENT) {
-
-#ifdef TARGET_FEDORA
-                        f = fopen("/etc/X11/xorg.conf.d/00-system-setup-keyboard.conf", "re");
-                        if (!f) {
-                                if (errno == ENOENT)
-                                        return 0;
-                                else
-                                        return -errno;
-                        }
-#else
-                        return 0;
-#endif
-
-                } else
-                          return -errno;
-        }
+        if (!f)
+                return errno == ENOENT ? 0 : -errno;
 
         while (fgets(line, sizeof(line), f)) {
                 char *l;
 
         while (fgets(line, sizeof(line), f)) {
                 char *l;
@@ -425,7 +409,7 @@ static void push_data(DBusConnection *bus) {
         l_set = new0(char*, _PROP_MAX);
         l_unset = new0(char*, _PROP_MAX);
         if (!l_set || !l_unset) {
         l_set = new0(char*, _PROP_MAX);
         l_unset = new0(char*, _PROP_MAX);
         if (!l_set || !l_unset) {
-                log_error("Out of memory.");
+                log_oom();
                 goto finish;
         }
 
                 goto finish;
         }
 
@@ -438,7 +422,7 @@ static void push_data(DBusConnection *bus) {
                         char *s;
 
                         if (asprintf(&s, "%s=%s", names[p], data[p]) < 0) {
                         char *s;
 
                         if (asprintf(&s, "%s=%s", names[p], data[p]) < 0) {
-                                log_error("Out of memory.");
+                                log_oom();
                                 goto finish;
                         }
 
                                 goto finish;
                         }
 
@@ -456,30 +440,30 @@ static void push_data(DBusConnection *bus) {
         dbus_message_iter_init_append(m, &iter);
 
         if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
         dbus_message_iter_init_append(m, &iter);
 
         if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
-                log_error("Out of memory.");
+                log_oom();
                 goto finish;
         }
 
         STRV_FOREACH(t, l_unset)
                 if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
                 goto finish;
         }
 
         STRV_FOREACH(t, l_unset)
                 if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
-                        log_error("Out of memory.");
+                        log_oom();
                         goto finish;
                 }
 
         if (!dbus_message_iter_close_container(&iter, &sub) ||
             !dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
                         goto finish;
                 }
 
         if (!dbus_message_iter_close_container(&iter, &sub) ||
             !dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub)) {
-                log_error("Out of memory.");
+                log_oom();
                 goto finish;
         }
 
         STRV_FOREACH(t, l_set)
                 if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
                 goto finish;
         }
 
         STRV_FOREACH(t, l_set)
                 if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, t)) {
-                        log_error("Out of memory.");
+                        log_oom();
                         goto finish;
                 }
 
         if (!dbus_message_iter_close_container(&iter, &sub)) {
                         goto finish;
                 }
 
         if (!dbus_message_iter_close_container(&iter, &sub)) {
-                log_error("Out of memory.");
+                log_oom();
                 goto finish;
         }
 
                 goto finish;
         }
 
@@ -577,14 +561,6 @@ static int write_data_x11(void) {
             isempty(state.x11_variant) &&
             isempty(state.x11_options)) {
 
             isempty(state.x11_variant) &&
             isempty(state.x11_options)) {
 
-#ifdef TARGET_FEDORA
-                unlink("/etc/X11/xorg.conf.d/00-system-setup-keyboard.conf");
-
-                /* Symlink this to /dev/null, so that s-s-k (if it is
-                 * still running) doesn't recreate this. */
-                symlink("/dev/null", "/etc/X11/xorg.conf.d/00-system-setup-keyboard.conf");
-#endif
-
                 if (unlink("/etc/X11/xorg.conf.d/00-keyboard.conf") < 0)
                         return errno == ENOENT ? 0 : -errno;
 
                 if (unlink("/etc/X11/xorg.conf.d/00-keyboard.conf") < 0)
                         return errno == ENOENT ? 0 : -errno;
 
@@ -624,18 +600,8 @@ static int write_data_x11(void) {
                 r = -errno;
                 unlink("/etc/X11/xorg.conf.d/00-keyboard.conf");
                 unlink(temp_path);
                 r = -errno;
                 unlink("/etc/X11/xorg.conf.d/00-keyboard.conf");
                 unlink(temp_path);
-        } else {
-
-#ifdef TARGET_FEDORA
-                unlink("/etc/X11/xorg.conf.d/00-system-setup-keyboard.conf");
-
-                /* Symlink this to /dev/null, so that s-s-k (if it is
-                 * still running) doesn't recreate this. */
-                symlink("/dev/null", "/etc/X11/xorg.conf.d/00-system-setup-keyboard.conf");
-#endif
-
+        } else
                 r = 0;
                 r = 0;
-        }
 
         fclose(f);
         free(temp_path);
 
         fclose(f);
         free(temp_path);
@@ -1157,7 +1123,9 @@ static DBusHandlerResult locale_message_handler(
                                         "Locale\0");
                         if (!changed)
                                 goto oom;
                                         "Locale\0");
                         if (!changed)
                                 goto oom;
-                }
+                } else
+                        strv_free(l);
+
         } else if (dbus_message_is_method_call(message, "org.freedesktop.locale1", "SetVConsoleKeyboard")) {
 
                 const char *keymap, *keymap_toggle;
         } else if (dbus_message_is_method_call(message, "org.freedesktop.locale1", "SetVConsoleKeyboard")) {
 
                 const char *keymap, *keymap_toggle;
@@ -1344,8 +1312,7 @@ static int connect_bus(DBusConnection **_bus) {
 
         if (!dbus_connection_register_object_path(bus, "/org/freedesktop/locale1", &locale_vtable, NULL) ||
             !dbus_connection_add_filter(bus, bus_exit_idle_filter, &remain_until, NULL)) {
 
         if (!dbus_connection_register_object_path(bus, "/org/freedesktop/locale1", &locale_vtable, NULL) ||
             !dbus_connection_add_filter(bus, bus_exit_idle_filter, &remain_until, NULL)) {
-                log_error("Out of memory.");
-                r = -ENOMEM;
+                r = log_oom();
                 goto fail;
         }
 
                 goto fail;
         }