RFR (XS): 8218937: Make mlvmJvmtiUtils strncpy uses GCC 8.x friendly
Igor Ignatyev
igor.ignatyev at oracle.com
Thu Feb 14 00:12:06 UTC 2019
Hi Mikael,
I really don't like us adding goto in cpp code, can we avoid that?
I also doubt that any of mlvm tests are run in tier1, could you please also run :vmTestbase_vm_mlvm to test your fix?
Thanks,
-- Igor
> On Feb 13, 2019, at 3:45 PM, Mikael Vidstedt <mikael.vidstedt at oracle.com> wrote:
>
>
> Please review this small fix which updates some uses of strncpy to address some GCC 8.x warnings.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8218937 <https://bugs.openjdk.java.net/browse/JDK-8218937>
> Webrev: http://cr.openjdk.java.net/~mikael/webrevs/8218937/webrev.00/open/webrev/ <http://cr.openjdk.java.net/~mikael/webrevs/8218937/webrev.00/open/webrev/>
>
> GCC 8.2 is producing a warning for mlvmJvmtiUtils.cpp:
>
> In file included from test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/share/libIndyRedefineClass.cpp:31:
> test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp: In function 'MethodName* getMethodName(jvmtiEnv*, jmethodID)':
> test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp:80:12: error: 'char* strncpy(char*, const char*, size_t)' specified bound 256 equals destination size [-Werror=stringop-truncation]
> strncpy(mn->methodName, szName, sizeof(mn->methodName));
> ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Basically, gcc is pointing out that the resulting string is not necessarily going to be terminated. Explicitly checking the length of the source strings provides the information needed to guarantee that the strings will be terminated, and silences the warning.
>
> Passes tier1.
>
> Cheers,
> Mikael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20190213/a1fdfea5/attachment.html>
More information about the hotspot-compiler-dev
mailing list