]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Inline printf templates when possible to enable format checking.
authorVladimir Serbinenko <phcoder@gmail.com>
Sat, 21 Dec 2013 12:40:18 +0000 (13:40 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 21 Dec 2013 12:40:18 +0000 (13:40 +0100)
ChangeLog
grub-core/normal/main.c
grub-core/normal/menu_text.c
grub-core/osdep/unix/getroot.c

index 694a26114c34d075487051856422decf7675b625..50948c6977d5f95518811f93e742bbe4e8607672 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-21  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Inline printf templates when possible to enable format checking.
+
 2013-12-21  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * include/grub/crypto.h: Don't discard const attribute.
index 4c57e090bcb8878e9e49fa3f025dfcfb01213ac3..c36663f738ca9db88c67a3936f3b0a863676cb14 100644 (file)
@@ -194,14 +194,13 @@ grub_normal_init_page (struct grub_term_output *term,
 {
   grub_ssize_t msg_len;
   int posx;
-  const char *msg = _("GNU GRUB  version %s");
   char *msg_formatted;
   grub_uint32_t *unicode_msg;
   grub_uint32_t *last_position;
  
   grub_term_cls (term);
 
-  msg_formatted = grub_xasprintf (msg, PACKAGE_VERSION);
+  msg_formatted = grub_xasprintf (_("GNU GRUB  version %s"), PACKAGE_VERSION);
   if (!msg_formatted)
     return;
  
@@ -350,13 +349,13 @@ static grub_err_t
 grub_normal_reader_init (int nested)
 {
   struct grub_term_output *term;
-  const char *msg = _("Minimal BASH-like line editing is supported. For "
-                     "the first word, TAB lists possible command completions. Anywhere "
-                     "else TAB lists possible device or file completions. %s");
   const char *msg_esc = _("ESC at any time exits.");
   char *msg_formatted;
 
-  msg_formatted = grub_xasprintf (msg, nested ? msg_esc : "");
+  msg_formatted = grub_xasprintf (_("Minimal BASH-like line editing is supported. For "
+                                   "the first word, TAB lists possible command completions. Anywhere "
+                                   "else TAB lists possible device or file completions. %s"),
+                                 nested ? msg_esc : "");
   if (!msg_formatted)
     return grub_errno;
 
index 90f63f0da5718bb34911238d420fcb5cddccdea4..2ff294101d8f5cf8f79ca2c36040f8d409f8d41c 100644 (file)
@@ -165,11 +165,11 @@ command-line or ESC to discard edits and return to the GRUB menu."),
     }
   else
     {
-      const char *msg = _("Use the %C and %C keys to select which "
-                         "entry is highlighted.");
       char *msg_translated;
 
-      msg_translated = grub_xasprintf (msg, GRUB_UNICODE_UPARROW,
+      msg_translated = grub_xasprintf (_("Use the %C and %C keys to select which "
+                                        "entry is highlighted."),
+                                      GRUB_UNICODE_UPARROW,
                                       GRUB_UNICODE_DOWNARROW);
       if (!msg_translated)
        return 0;
@@ -430,9 +430,6 @@ grub_menu_init_page (int nested, int edit,
 static void
 menu_text_print_timeout (int timeout, void *dataptr)
 {
-  const char *msg =
-    _("The highlighted entry will be executed automatically in %ds.");
-  const char *msg_terse = _("%ds");
   struct menu_viewer_data *data = dataptr;
   char *msg_translated = 0;
 
@@ -441,9 +438,9 @@ menu_text_print_timeout (int timeout, void *dataptr)
 
   if (data->timeout_msg == TIMEOUT_TERSE
       || data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN)
-    msg_translated = grub_xasprintf (msg_terse, timeout);
+    msg_translated = grub_xasprintf (_("%ds"), timeout);
   else
-    msg_translated = grub_xasprintf (msg, timeout);
+    msg_translated = grub_xasprintf (_("The highlighted entry will be executed automatically in %ds."), timeout);
   if (!msg_translated)
     {
       grub_print_error ();
@@ -459,7 +456,7 @@ menu_text_print_timeout (int timeout, void *dataptr)
       if (data->timeout_msg == TIMEOUT_TERSE)
        {
          grub_free (msg_translated);
-         msg_translated = grub_xasprintf (msg_terse, timeout);
+         msg_translated = grub_xasprintf (_("%ds"), timeout);
          if (grub_term_width (data->term) < 10)
            data->timeout_msg = TIMEOUT_TERSE_NO_MARGIN;
        }
index 3e40d994257feaa6a8f41801a62fb56a76dbb76f..3a938edc4d26d09cc109eb397564a736479c49bc 100644 (file)
@@ -443,17 +443,18 @@ grub_find_device (const char *dir, dev_t dev)
          /* Found!  */
          char *res;
          char *cwd;
-#if defined(__NetBSD__) || defined(__OpenBSD__)
-         /* Convert this block device to its character (raw) device.  */
-         const char *template = "%s/r%s";
-#else
-         /* Keep the device name as it is.  */
-         const char *template = "%s/%s";
-#endif
 
          cwd = xgetcwd ();
          res = xmalloc (strlen (cwd) + strlen (ent->d_name) + 3);
-         sprintf (res, template, cwd, ent->d_name);
+         sprintf (res, 
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+                  /* Convert this block device to its character (raw) device.  */
+                  "%s/r%s",
+#else
+                  /* Keep the device name as it is.  */
+                  "%s/%s",
+#endif
+                  cwd, ent->d_name);
          strip_extra_slashes (res);
          free (cwd);