]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
locale: move logging from library-like functions to caller
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 26 Jan 2023 14:30:27 +0000 (23:30 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 28 Jan 2023 06:06:00 +0000 (15:06 +0900)
src/locale/localed-util.c
src/locale/localed.c

index 54e32e2e1cb4f934c2d65cdbb6367f42b6fe69c2..f5cc46c83687075e1186938db21052e130a99c6f 100644 (file)
@@ -605,7 +605,6 @@ int vconsole_convert_to_x11(const VCContext *vc, X11Context *ret) {
                 if (r < 0)
                         return r;
                 if (r == 0) {
-                        log_notice("No conversion found for virtual console keymap \"%s\".", vc->keymap);
                         *ret = (X11Context) {};
                         return 0;
                 }
@@ -613,19 +612,13 @@ int vconsole_convert_to_x11(const VCContext *vc, X11Context *ret) {
                 if (!streq(vc->keymap, a[0]))
                         continue;
 
-                r = x11_context_copy(ret,
+                return x11_context_copy(ret,
                                      &(X11Context) {
                                              .layout  = empty_or_dash_to_null(a[1]),
                                              .model   = empty_or_dash_to_null(a[2]),
                                              .variant = empty_or_dash_to_null(a[3]),
                                              .options = empty_or_dash_to_null(a[4]),
                                      });
-                if (r < 0)
-                        return r;
-
-                log_info("The virtual console keymap '%s' is converted to X11 keyboard layout '%s' model '%s' variant '%s' options '%s'",
-                         vc->keymap, strempty(ret->layout), strempty(ret->model), strempty(ret->variant), strempty(ret->options));
-                return 0;
         }
 }
 
@@ -819,14 +812,6 @@ int x11_convert_to_vconsole(const X11Context *xc, VCContext *ret) {
                 r = find_legacy_keymap(xc, &keymap);
         if (r < 0)
                 return r;
-        if (r == 0)
-                /* We search for layout-variant match first, but then we also look
-                 * for anything which matches just the layout. So it's accurate to say
-                 * that we couldn't find anything which matches the layout. */
-                log_notice("No conversion to virtual console map found for \"%s\".", xc->layout);
-        else
-                log_info("The X11 keyboard layout '%s' is converted to virtual console keymap '%s'",
-                         xc->layout, strempty(keymap));
 
         *ret = (VCContext) {
                 .keymap = TAKE_PTR(keymap),
index 7355b2d0e2ce5b739551a147ee216dba692f06f9..267f27635b37ca8c70933b11490c532d625b3584 100644 (file)
@@ -413,6 +413,12 @@ static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_erro
                         return sd_bus_error_set_errnof(error, r, "Failed to convert keymap data: %m");
                 }
 
+                if (x11_context_isempty(&converted))
+                        log_notice("No conversion found for virtual console keymap \"%s\".", strempty(in.keymap));
+                else
+                        log_info("The virtual console keymap '%s' is converted to X11 keyboard layout '%s' model '%s' variant '%s' options '%s'",
+                                 in.keymap, strempty(converted.layout), strempty(converted.model), strempty(converted.variant), strempty(converted.options));
+
                 /* save the result of conversion to emit changed properties later. */
                 x_needs_update = !x11_context_equal(&c->x11_from_vc, &converted) || !x11_context_equal(&c->x11_from_xorg, &converted);
         } else
@@ -636,6 +642,15 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err
                         return sd_bus_error_set_errnof(error, r, "Failed to convert keymap data: %m");
                 }
 
+                if (vc_context_isempty(&converted))
+                        /* We search for layout-variant match first, but then we also look
+                         * for anything which matches just the layout. So it's accurate to say
+                         * that we couldn't find anything which matches the layout. */
+                        log_notice("No conversion to virtual console map found for \"%s\".", strempty(in.layout));
+                else
+                        log_info("The X11 keyboard layout '%s' is converted to virtual console keymap '%s'",
+                                 in.layout, converted.keymap);
+
                 /* save the result of conversion to emit changed properties later. */
                 convert = !vc_context_equal(&c->vc, &converted);
         }