mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8064779: Add additional comments for "8062370: Various minor code improvements"
Provide additional comments to jio_snprintf and jio_vsnprintf Reviewed-by: simonis, coleenp, mgronlun
This commit is contained in:
parent
c217bdda86
commit
c96487313b
2 changed files with 12 additions and 4 deletions
|
@ -2593,6 +2593,10 @@ int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) {
|
|||
if ((intptr_t)count <= 0) return -1;
|
||||
|
||||
int result = vsnprintf(str, count, fmt, args);
|
||||
// Note: on truncation vsnprintf(3) on Unix returns numbers of
|
||||
// characters which would have been written had the buffer been large
|
||||
// enough; on Windows, it returns -1. We handle both cases here and
|
||||
// always return -1, and perform null termination.
|
||||
if ((result > 0 && (size_t)result >= count) || result == -1) {
|
||||
str[count - 1] = '\0';
|
||||
result = -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue