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

Xue-Lei Andrew Fan xuelei at openjdk.org
Mon Nov 14 19:30:29 UTC 2022


On Mon, 14 Nov 2022 10:21:07 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> Xue-Lei Andrew Fan has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   include missing os head file
>
> src/hotspot/share/adlc/output_c.cpp line 2570:
> 
>> 2568:     int idx = inst.operand_position_format(arg_name);
>> 2569:     if (strcmp(arg_name, "constanttablebase") == 0) {
>> 2570:       ib += snprintf(ib, (buflen - (ib - idxbuf)), "  unsigned idx_%-5s = mach_constant_base_node_input(); \t// %s, \t%s\n",
> 
> Use sizeof(buffer) instead of buflen?
> Also, possibly using a helper macro like this:
> 
> 
> #define remaining_buflen(buffer, position) (sizeof(buffer) - (position - buffer))
> 
> would make the code a bit easier on the eye. Or, if not a macro, an inline helper function, that could assert also array boundaries.

Thanks for suggestion, which makes the code much easier to read.

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

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



More information about the client-libs-dev mailing list