term/serial: Use grub_strncpy instead of grub_snprintf when only copying string
PATCH 1/1 term/serial: Use grub_strncpy instead of grub_snprintf when only copying string
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 <[email protected]>
--- grub-core/term/serial.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
grub-core/term/serial.c +3 -3
@@ -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; }
Signature · 1 line
2.34.1
Quoted 6 lines · Glenn Washburn
Using
grub_strncpy()instead ofgrub_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 <[email protected]>
Reviewed-by Daniel Kiper <[email protected]>
Daniel