On Mon, 14 Nov 2022 05:32:20 GMT, Xue-Lei Andrew Fan <[email protected]> wrote:

>> Hi,
>> 
>> May I have this update reviewed?
>> 
>> The sprintf is deprecated in Xcode 14 because of security concerns, and the 
>> use of it causing building failure.  The build could pass if warnings are 
>> disabled for codes that use sprintf method.  For the long run, the sprintf 
>> could be replaced with snprintf.  This patch is trying to check if snprintf 
>> could be used.
>> 
>> Thanks,
>> Xuelei
>
> 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.

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

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

Reply via email to