]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
kern/misc: Make grub_vsnprintf() C99/POSIX conformant
authorGlenn Washburn <development@efficientek.com>
Fri, 18 Aug 2023 17:15:27 +0000 (12:15 -0500)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 31 Aug 2023 14:57:22 +0000 (16:57 +0200)
To comply with C99 and POSIX standards, snprintf() should return the
number of bytes that would be written to the string (excluding the
terminating NUL byte) if the buffer size was big enough. Before this
change, the return value was the minimum of the standard return and the
length of the buffer. Rarely is the return value of grub_snprintf() or
grub_vsnprintf() used with current code, and the few places where it is
used do not need to be changed.

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

index 2890aad49fa7f900117115eb82b35d70ce4f73be..b57249acb81b5acb7a444c6ec9e2c88cab42ba5f 100644 (file)
@@ -1201,7 +1201,7 @@ grub_vsnprintf (char *str, grub_size_t n, const char *fmt, va_list ap)
 
   free_printf_args (&args);
 
-  return ret < n ? ret : n;
+  return ret;
 }
 
 int