[systemd-devel] [PATCH 1/5] fsckd: Don't use strjoina on gettext() call

Lennart Poettering lennart at poettering.net
Tue Mar 10 03:36:28 PDT 2015


On Tue, 10.03.15 11:32, Didier Roche (didrocks at 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...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list