RFR: 8336289: Obliterate most references to _snprintf in the Windows JDK [v5]
Julian Waters
jwaters at openjdk.org
Sat Aug 24 05:12:42 UTC 2024
> snprintf has been available for all officially and unofficially supported compilers for Windows, Visual Studio since version 2015 and gcc since, well, forever. snprintf is conforming to C99 since the start when compiling using gcc, and 2015 when using Visual Studio. Since it conforms to C99 and provides better semantics than _snprintf, and is not compiler specific, we should use it in most places where we currently use _snprintf. This makes JDK code where this is used more robust due to the null terminating guarantee of snprintf. Since most of the changes are extremely simple, I've included all of them hoping to get this all done in one shot. The only places _snprintf is not replaced is places where I'm not sure whether the code is ours or not (As in, imported source code for external libraries). Note that the existing checks in place for the size of the characters written still work, as the return value of snprintf works mostly the same as _snprintf. The only difference is the nul
l terminating character at the end and the returning of the number of written characters if the buffer was terminated early, as seen here: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l?view=msvc-170
>
> Reviews Required: 2 for HotSpot, jdk.hotspot.agent, and jdk.jdwp.agent, 1 for awt and jdk.accessibility, 1 for java.base, 1 for security, 1 for jdk.management(?)
Julian Waters has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:
- Merge branch 'master' into snprintf
- Change copyright years and formatting
- Revert Standard Integer type rewrite
- USe os::snprintf in HotSpot
- Obliterate most references to _snprintf in the Windows JDK
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/20153/files
- new: https://git.openjdk.org/jdk/pull/20153/files/e14ef6b6..d8f7b849
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=20153&range=04
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=20153&range=03-04
Stats: 56099 lines in 1629 files changed: 32020 ins; 16189 del; 7890 mod
Patch: https://git.openjdk.org/jdk/pull/20153.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20153/head:pull/20153
PR: https://git.openjdk.org/jdk/pull/20153
More information about the core-libs-dev
mailing list