Le 10/03/2015 11:36, Lennart Poettering a écrit :
On Tue, 10.03.15 11:32, Didier Roche (didro...@ubuntu.com) wrote:

  static int manager_send_plymouth_message(Manager *m, const char *message) {
-        const char *plymouth_cancel_message = NULL;
+        _cleanup_free_ const char *plymouth_cancel_message = NULL;
          int r;
r = manager_connect_plymouth(m);
@@ -258,7 +258,7 @@ static int manager_send_plymouth_message(Manager *m, const 
char *message) {
m->plymouth_cancel_sent = true; - plymouth_cancel_message = strjoina("fsckd-cancel-msg:", _("Press Ctrl+C to cancel all filesystem checks in progress"));
+                plymouth_cancel_message = strjoin("fsckd-cancel-msg:", _("Press 
Ctrl+C to cancel all filesystem checks in progress"), NULL);
Well, there's an OOM check missing now, as strjoin() can fail...

That said, I think using strjoina is actually a good idea here, the
string is not unbounded. Hence I think it would be a good idea to
first assign the result of _() to a const char* variable in one step,
and then concat it in a second...

Makes sense. Here is the suggested change.

Didier

PS: just posting a couple of patches from your suggestion, I'll work on the bigger discussion of passing the fsck pipe to systemd-fsckd later in the week.
>From ab84557e5840ff0a606b4b6f694b655b85bdcd45 Mon Sep 17 00:00:00 2001
From: Didier Roche <didro...@ubuntu.com>
Date: Tue, 10 Mar 2015 08:58:23 +0100
Subject: [PATCH 1/2] fsckd: Don't use strjoina on gettext() call

---
 src/fsckd/fsckd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/fsckd/fsckd.c b/src/fsckd/fsckd.c
index 3c587a3..f23f272 100644
--- a/src/fsckd/fsckd.c
+++ b/src/fsckd/fsckd.c
@@ -272,7 +272,7 @@ static int plymouth_send_message(int plymouth_fd, const char *message, bool upda
 }
 
 static int manager_send_plymouth_message(Manager *m, const char *message) {
-        const char *plymouth_cancel_message = NULL;
+        _cleanup_free_ const char *plymouth_cancel_message = NULL, *l10n_cancel_message = NULL;
         int r;
 
         r = manager_connect_plymouth(m);
@@ -288,7 +288,8 @@ static int manager_send_plymouth_message(Manager *m, const char *message) {
 
                 m->plymouth_cancel_sent = true;
 
-                plymouth_cancel_message = strjoina("fsckd-cancel-msg:", _("Press Ctrl+C to cancel all filesystem checks in progress"));
+                l10n_cancel_message = _("Press Ctrl+C to cancel all filesystem checks in progress");
+                plymouth_cancel_message = strjoina("fsckd-cancel-msg:", l10n_cancel_message);
 
                 r = plymouth_send_message(m->plymouth_fd, plymouth_cancel_message, false);
                 if (r < 0)
-- 
2.1.4

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to