RFR: 8286562: GCC 12 reports some compiler warnings [v2]
Yasumasa Suenaga
ysuenaga at openjdk.java.net
Thu May 12 01:17:37 UTC 2022
On Wed, 11 May 2022 13:43:55 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> Yasumasa Suenaga has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Avoid pragma error in before GCC 12
>
> src/java.base/unix/native/libjli/java_md_common.c line 135:
>
>> 133: if ((JLI_StrLen(indir) + JLI_StrLen(cmd) + 2) > sizeof(name)) return 0;
>> 134: JLI_Snprintf(name, sizeof(name), "%s%c%s", indir, FILE_SEPARATOR, cmd);
>> 135: #pragma GCC diagnostic pop
>
> Wouldn't it be better to just call JLI_Snprintf without the precheck and check the result to determine whether it was successful or was truncated? I think that kind of check is supposed to make gcc's truncation checker happy.
The warning has gone when using return value from `JLI_Snprintf()` in new commit!
-------------
PR: https://git.openjdk.java.net/jdk/pull/8646
More information about the build-dev
mailing list