RFR: 8313220: Remove Windows specific workaround in LCMS.c for _snprintf

Phil Race prr at openjdk.org
Tue Sep 19 21:19:42 UTC 2023


On Wed, 23 Aug 2023 00:42:47 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> This patch addresses two issues:
>  * For Windows: The snprintf is available with Visual Studio 2015 and above, so we do not need to use the windows speciific "_snprintf". We also do not need to set a zero at the end of the string since the "new" snprintf works according c99: see this [link](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l?view=msvc-170#behavior-summary) for details.
>  * For unix: It seems the standard snprintf does not guaratier that the zero is set at the start of the string if error is occured and the negative value is returned. It could be fixed by checking the return value and set zero manually, but I just decided to memset the whole array to zero, that is shorte and should not affect the performance in this error handler.
> 
> See some discussin at the end of [this](https://github.com/openjdk/jdk/pull/10625) PR
> 
> The new test just covered the changed code path and verifies that it works as expected.

Marked as reviewed by prr (Reviewer).

-------------

PR Review: https://git.openjdk.org/jdk/pull/15396#pullrequestreview-1634202965


More information about the client-libs-dev mailing list