* [PATCH] misc: Make grub_vsnprintf C99/POSIX conformant
@ 2023-08-18 17:15 Glenn Washburn
2023-08-30 14:43 ` Daniel Kiper
0 siblings, 1 reply; 2+ messages in thread
From: Glenn Washburn @ 2023-08-18 17:15 UTC (permalink / raw)
To: grub-devel, Daniel Kiper, Vladimir 'phcoder' Serbinenko
Cc: Glenn Washburn
To comply with C99 and POSIX standards, snprintf should return the
number of bytes that would be written to the string (excluding the
terminating NULL 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>
---
grub-core/kern/misc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index 95bf7860f3da..afb41bd63a6a 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -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
--
2.34.1
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] misc: Make grub_vsnprintf C99/POSIX conformant
2023-08-18 17:15 [PATCH] misc: Make grub_vsnprintf C99/POSIX conformant Glenn Washburn
@ 2023-08-30 14:43 ` Daniel Kiper
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2023-08-30 14:43 UTC (permalink / raw)
To: Glenn Washburn; +Cc: grub-devel, Vladimir 'phcoder' Serbinenko
On Fri, Aug 18, 2023 at 12:15:27PM -0500, Glenn Washburn wrote:
> To comply with C99 and POSIX standards, snprintf should return the
> number of bytes that would be written to the string (excluding the
> terminating NULL 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>
Daniel
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-30 14:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-18 17:15 [PATCH] misc: Make grub_vsnprintf C99/POSIX conformant Glenn Washburn
2023-08-30 14:43 ` 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.