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

Build fails with warn_unused_result in openjdk/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b12

      Backports

        Description

        This error

        openjdk/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c:798:7: error: ignoring return value of 'pread', declared with attribute warn_unused_result [-Werror=unused-result]
               pread(ph->core->exec_fd, interp_name, exec_php->p_filesz, exec_php->p_offset);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        cc1: all warnings being treated as errors

        was seen while trying to build OpenJDK on an Ubuntu 18.04 VM with compiler

        * Toolchain: gcc (GNU Compiler Collection)
        * C Compiler: Version 7.3.0 (at /usr/bin/gcc)
        * C++ Compiler: Version 7.3.0 (at /usr/bin/g++)

        This change fixes the problem:

        +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c
        @@ -795,7 +795,9 @@
               if (exec_php->p_filesz > BUF_SIZE) {
                 goto err;
               }
        - pread(ph->core->exec_fd, interp_name, exec_php->p_filesz, exec_php->p_offset);
        + if (pread(ph->core->exec_fd, interp_name, exec_php->p_filesz, exec_php->p_offset) != exec_php->p_filesz) {
        + goto err;
        + }
               interp_name[exec_php->p_filesz] = '\0';
               print_debug("ELF interpreter %s\n", interp_name);
               // read interpreter segments as well

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                jgeorge Jini George (Inactive)
                Reporter:
                bpb Brian Burkhalter
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: