Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8218935

Make jfr strncpy uses GCC 8.x friendly

    Details

    • Subcomponent:
      jfr
    • Resolved In Build:
      b09

      Backports

        Description

         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.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mikael Mikael Vidstedt
                  Reporter:
                  mikael Mikael Vidstedt
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: