All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org, Daniel Kiper <dkiper@net-space.pl>
Cc: Glenn Washburn <development@efficientek.com>
Subject: [PATCH] term/serial: Use grub_strncpy instead of grub_snprintf when only copying string
Date: Wed, 28 Jun 2023 02:47:09 -0500	[thread overview]
Message-ID: <20230628074709.485597-1-development@efficientek.com> (raw)

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



             reply	other threads:[~2023-06-28  7:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28  7:47 Glenn Washburn [this message]
2023-06-28 12:51 ` [PATCH] term/serial: Use grub_strncpy instead of grub_snprintf when only copying string Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230628074709.485597-1-development@efficientek.com \
    --to=development@efficientek.com \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.