RFR(XS): 8218935: Make jfr strncpy uses GCC 8.x friendly

Mikael Vidstedt mikael.vidstedt at oracle.com
Thu Feb 14 23:23:39 UTC 2019


Thank you! I updated the copyright year, added the spaces (on both lines) and pushed the change.

Cheers,
Mikael

> On Feb 13, 2019, at 11:40 PM, Langer, Christoph <christoph.langer at sap.com> wrote:
> 
> Hi Mikael,
> 
> lokks good to me.
> 
> In src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp:
> Line 242: Could you use spaces between "len+1" ? Maybe you could fix it in the line above as well...
> 
> Also assuming you update the copyright year when pushing.
> 
> Best regards
> Christoph
> 
>> -----Original Message-----
>> From: hotspot-jfr-dev <hotspot-jfr-dev-bounces at openjdk.java.net> On
>> Behalf Of Mikael Vidstedt
>> Sent: Mittwoch, 13. Februar 2019 23:54
>> To: hotspot-jfr-dev at openjdk.java.net
>> Cc: Dmitry Chuyko <dmitry.chuyko at bell-sw.com>
>> Subject: RFR(XS): 8218935: Make jfr strncpy uses GCC 8.x friendly
>> 
>> 
>> 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-8218935
>> Webrev:
>> http://cr.openjdk.java.net/~mikael/webrevs/8218935/webrev.00/open/we
>> brev/
>> <http://cr.openjdk.java.net/~mikael/webrevs/8218935/webrev.00/open/w
>> ebrev/>
>> 
>> 
>> Specifically, GCC 8.2 is producing warnings like this:
>> 
>> In function 'char* copy_path(const char*)',
>>    inlined from 'void JfrChunkState::set_path(const char*)' at
>> src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp:115:22:
>> src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp:103:10: error:
>> 'char* strncpy(char*, const char*, size_t)' output truncated before
>> terminating nul copying as many bytes from a string as its length [-
>> Werror=stringop-truncation]
>>   strncpy(new_path, path, path_len);
>>   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
>> 
>> Basically, gcc is pointing out that the resulting string is not going to be
>> terminated. This is fine from a functional perspective, because in all cases the
>> very next thing we do is add the necessary nul termination, but having
>> strncpy produce a nul terminated string has the benefit of not having to
>> terminate it explicitly, and, of course, silence the warnings.
>> 
>> (Note: additional changes are needed to make the build GCC 8.2 warning
>> free.)
>> 
>> Passes tier1.
>> 
>> Cheers,
>> Mikael
> 



More information about the hotspot-jfr-dev mailing list