RFR: 8296812: sprintf is deprecated in Xcode 14 [v6]

Thomas Stuefe stuefe at openjdk.org
Tue Nov 15 08:35:11 UTC 2022


On Tue, 15 Nov 2022 07:13:49 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Xue-Lei Andrew Fan has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   delete swp file
>
> src/hotspot/os/bsd/attachListener_bsd.cpp line 294:
> 
>> 292:               (atoi(buf) != ATTACH_PROTOCOL_VER)) {
>> 293:             char msg[32];
>> 294:             os::snprintf(msg, sizeof(msg), "%d\n", ATTACH_ERROR_BADVERSION);
> 
> Rather than using `strlen(msg)` in the next line, use the result from `os::snprintf`.

The problem with using the return value of os::snprintf() is that we need to handle the -1 case to prevent the position from running backward. Might be better to use stringStream instead, which should handle the -1 case transparently.

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

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



More information about the client-libs-dev mailing list