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

Sergey Bylokhov serb at openjdk.org
Fri Sep 1 05:43:18 UTC 2023


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.

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

Commit messages:
 - better compression
 - save some space
 - test
 - 8313220: Remove Windows specific workaround in LCMS.c for _snprintf

Changes: https://git.openjdk.org/jdk/pull/15396/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15396&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8313220
  Stats: 94 lines in 3 files changed: 80 ins; 11 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/15396.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15396/head:pull/15396

PR: https://git.openjdk.org/jdk/pull/15396


More information about the client-libs-dev mailing list