All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] term/serial: Use grub_strncpy instead of grub_snprintf when only copying string
@ 2023-06-28  7:47 Glenn Washburn
  2023-06-28 12:51 ` Daniel Kiper
  0 siblings, 1 reply; 2+ messages in thread
From: Glenn Washburn @ 2023-06-28  7:47 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

Using grub_strncpy() instead of grub_snprintf() is less overhead and
indicates clearly that the dest should be the same string as the source.

Also fix indentation.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/term/serial.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c
index 69fc0600f622..869555430153 100644
--- a/grub-core/term/serial.c
+++ b/grub-core/term/serial.c
@@ -257,10 +257,10 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args)
     {
       if (grub_strncmp (state[OPTION_PORT].arg, "mmio,", sizeof ("mmio,") - 1) == 0 ||
 	  grub_strncmp (state[OPTION_PORT].arg, "pci,", sizeof ("pci,") - 1) == 0)
-          grub_snprintf (pname, sizeof (pname), "%s", state[1].arg);
+	grub_strncpy (pname, state[1].arg, sizeof (pname));
       else
-          grub_snprintf (pname, sizeof (pname), "port%lx",
-                         grub_strtoul (state[1].arg, 0, 0));
+	grub_snprintf (pname, sizeof (pname), "port%lx",
+		       grub_strtoul (state[1].arg, 0, 0));
       name = pname;
     }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-28 12:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-28  7:47 [PATCH] term/serial: Use grub_strncpy instead of grub_snprintf when only copying string Glenn Washburn
2023-06-28 12:51 ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.