]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
disk/cryptodisk: Optimize luks_script_get()
authorGlenn Washburn <development@efficientek.com>
Fri, 14 Jul 2023 20:49:17 +0000 (15:49 -0500)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 12 Oct 2023 15:37:16 +0000 (17:37 +0200)
Use the return value of grub_snprintf() to move the string pointer forward,
instead of incrementing the string pointer iteratively until a NULL byte is
reached. Move the space out of the format string argument, a small
optimization, but also makes the spacing clearer. Also, use the new
PRIxGRUB_OFFSET instead of PRIuGRUB_UINT64_T to accurately reflect the
format string for this type.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/disk/cryptodisk.c

index fb807e2a6a275874d3d6e701eb48778ef9068e98..d40bdc060488d5bbe548b3fec8b2d480ec8ce6a7 100644 (file)
@@ -1504,9 +1504,8 @@ luks_script_get (grub_size_t *sz)
        ptr = grub_stpcpy (ptr, "luks_mount ");
        ptr = grub_stpcpy (ptr, i->uuid);
        *ptr++ = ' ';
-       grub_snprintf (ptr, 21, "%" PRIuGRUB_UINT64_T " ", i->offset_sectors);
-       while (*ptr)
-         ptr++;
+       ptr += grub_snprintf (ptr, 21, "%" PRIxGRUB_OFFSET, i->offset_sectors);
+       *ptr++ = ' ';
        for (iptr = i->cipher->cipher->name; *iptr; iptr++)
          *ptr++ = grub_tolower (*iptr);
        switch (i->mode)