8202353: os::readdir should use readdir instead of readdir_r

Mon, 17 Jun 2019 16:41:38 +0100

author
andrew
date
Mon, 17 Jun 2019 16:41:38 +0100
changeset 9711
0f2fe7d37d8c
parent 9710
5d306df084eb
child 9712
d7e1e002b496

8202353: os::readdir should use readdir instead of readdir_r
Summary: Summary: os::readdir uses POSIX readdir, drop buffer arg, fix JFR uses.
Reviewed-by: coleenp, tschatzl, bsrbnd, shade, phh

src/os/aix/vm/os_aix.cpp file | annotate | diff | comparison | revisions
src/os/aix/vm/os_aix.inline.hpp file | annotate | diff | comparison | revisions
src/os/aix/vm/perfMemory_aix.cpp file | annotate | diff | comparison | revisions
src/os/bsd/vm/os_bsd.cpp file | annotate | diff | comparison | revisions
src/os/bsd/vm/os_bsd.inline.hpp file | annotate | diff | comparison | revisions
src/os/bsd/vm/perfMemory_bsd.cpp file | annotate | diff | comparison | revisions
src/os/linux/vm/os_linux.cpp file | annotate | diff | comparison | revisions
src/os/linux/vm/os_linux.inline.hpp file | annotate | diff | comparison | revisions
src/os/linux/vm/perfMemory_linux.cpp file | annotate | diff | comparison | revisions
src/os/posix/vm/os_posix.cpp file | annotate | diff | comparison | revisions
src/os/solaris/vm/os_solaris.cpp file | annotate | diff | comparison | revisions
src/os/solaris/vm/os_solaris.inline.hpp file | annotate | diff | comparison | revisions
src/os/solaris/vm/perfMemory_solaris.cpp file | annotate | diff | comparison | revisions
src/os/windows/vm/os_windows.cpp file | annotate | diff | comparison | revisions
src/os/windows/vm/os_windows.inline.hpp file | annotate | diff | comparison | revisions
src/os/windows/vm/perfMemory_windows.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/arguments.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/os.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/os/aix/vm/os_aix.cpp	Tue Apr 30 14:49:19 2019 +0200
     1.2 +++ b/src/os/aix/vm/os_aix.cpp	Mon Jun 17 16:41:38 2019 +0100
     1.3 @@ -4184,8 +4184,7 @@
     1.4  
     1.5    /* Scan the directory */
     1.6    bool result = true;
     1.7 -  char buf[sizeof(struct dirent) + MAX_PATH];
     1.8 -  while (result && (ptr = ::readdir(dir)) != NULL) {
     1.9 +  while (result && (ptr = readdir(dir)) != NULL) {
    1.10      if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
    1.11        result = false;
    1.12      }
     2.1 --- a/src/os/aix/vm/os_aix.inline.hpp	Tue Apr 30 14:49:19 2019 +0200
     2.2 +++ b/src/os/aix/vm/os_aix.inline.hpp	Mon Jun 17 16:41:38 2019 +0100
     2.3 @@ -92,19 +92,6 @@
     2.4  
     2.5  inline const int os::default_file_open_flags() { return 0;}
     2.6  
     2.7 -inline DIR* os::opendir(const char* dirname)
     2.8 -{
     2.9 -  assert(dirname != NULL, "just checking");
    2.10 -  return ::opendir(dirname);
    2.11 -}
    2.12 -
    2.13 -inline int os::readdir_buf_size(const char *path)
    2.14 -{
    2.15 -  // according to aix sys/limits, NAME_MAX must be retrieved at runtime. */
    2.16 -  const long my_NAME_MAX = pathconf(path, _PC_NAME_MAX);
    2.17 -  return my_NAME_MAX + sizeof(dirent) + 1;
    2.18 -}
    2.19 -
    2.20  inline jlong os::lseek(int fd, jlong offset, int whence) {
    2.21    return (jlong) ::lseek64(fd, offset, whence);
    2.22  }
    2.23 @@ -121,28 +108,6 @@
    2.24    return ::ftruncate64(fd, length);
    2.25  }
    2.26  
    2.27 -inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
    2.28 -{
    2.29 -  dirent* p;
    2.30 -  int status;
    2.31 -  assert(dirp != NULL, "just checking");
    2.32 -
    2.33 -  // NOTE: Linux readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX
    2.34 -  // version. Here is the doc for this function:
    2.35 -  // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html
    2.36 -
    2.37 -  if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
    2.38 -    errno = status;
    2.39 -    return NULL;
    2.40 -  } else
    2.41 -    return p;
    2.42 -}
    2.43 -
    2.44 -inline int os::closedir(DIR *dirp) {
    2.45 -  assert(dirp != NULL, "argument is NULL");
    2.46 -  return ::closedir(dirp);
    2.47 -}
    2.48 -
    2.49  // macros for restartable system calls
    2.50  
    2.51  #define RESTARTABLE(_cmd, _result) do { \
     3.1 --- a/src/os/aix/vm/perfMemory_aix.cpp	Tue Apr 30 14:49:19 2019 +0200
     3.2 +++ b/src/os/aix/vm/perfMemory_aix.cpp	Mon Jun 17 16:41:38 2019 +0100
     3.3 @@ -612,9 +612,8 @@
     3.4    // to determine the user name for the process id.
     3.5    //
     3.6    struct dirent* dentry;
     3.7 -  char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname), mtInternal);
     3.8    errno = 0;
     3.9 -  while ((dentry = os::readdir(tmpdirp, (struct dirent *)tdbuf)) != NULL) {
    3.10 +  while ((dentry = os::readdir(tmpdirp)) != NULL) {
    3.11  
    3.12      // check if the directory entry is a hsperfdata file
    3.13      if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
    3.14 @@ -648,9 +647,8 @@
    3.15      }
    3.16  
    3.17      struct dirent* udentry;
    3.18 -    char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name), mtInternal);
    3.19      errno = 0;
    3.20 -    while ((udentry = os::readdir(subdirp, (struct dirent *)udbuf)) != NULL) {
    3.21 +    while ((udentry = os::readdir(subdirp)) != NULL) {
    3.22  
    3.23        if (filename_to_pid(udentry->d_name) == vmid) {
    3.24          struct stat statbuf;
    3.25 @@ -694,11 +692,9 @@
    3.26        }
    3.27      }
    3.28      os::closedir(subdirp);
    3.29 -    FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
    3.30      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
    3.31    }
    3.32    os::closedir(tmpdirp);
    3.33 -  FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
    3.34  
    3.35    return(oldest_user);
    3.36  }
    3.37 @@ -774,10 +770,8 @@
    3.38    // loop under these conditions is dependent upon the implementation of
    3.39    // opendir/readdir.
    3.40    struct dirent* entry;
    3.41 -  char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
    3.42 -
    3.43    errno = 0;
    3.44 -  while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) {
    3.45 +  while ((entry = os::readdir(dirp)) != NULL) {
    3.46  
    3.47      pid_t pid = filename_to_pid(entry->d_name);
    3.48  
    3.49 @@ -816,7 +810,6 @@
    3.50    // Close the directory and reset the current working directory.
    3.51    close_directory_secure_cwd(dirp, saved_cwd_fd);
    3.52  
    3.53 -  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
    3.54  }
    3.55  
    3.56  // Make the user specific temporary directory. Returns true if
     4.1 --- a/src/os/bsd/vm/os_bsd.cpp	Tue Apr 30 14:49:19 2019 +0200
     4.2 +++ b/src/os/bsd/vm/os_bsd.cpp	Mon Jun 17 16:41:38 2019 +0100
     4.3 @@ -3957,8 +3957,7 @@
     4.4  
     4.5    /* Scan the directory */
     4.6    bool result = true;
     4.7 -  char buf[sizeof(struct dirent) + MAX_PATH];
     4.8 -  while (result && (ptr = ::readdir(dir)) != NULL) {
     4.9 +  while (result && (ptr = readdir(dir)) != NULL) {
    4.10      if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
    4.11        result = false;
    4.12      }
     5.1 --- a/src/os/bsd/vm/os_bsd.inline.hpp	Tue Apr 30 14:49:19 2019 +0200
     5.2 +++ b/src/os/bsd/vm/os_bsd.inline.hpp	Mon Jun 17 16:41:38 2019 +0100
     5.3 @@ -95,17 +95,6 @@
     5.4  
     5.5  inline const int os::default_file_open_flags() { return 0;}
     5.6  
     5.7 -inline DIR* os::opendir(const char* dirname)
     5.8 -{
     5.9 -  assert(dirname != NULL, "just checking");
    5.10 -  return ::opendir(dirname);
    5.11 -}
    5.12 -
    5.13 -inline int os::readdir_buf_size(const char *path)
    5.14 -{
    5.15 -  return NAME_MAX + sizeof(dirent) + 1;
    5.16 -}
    5.17 -
    5.18  inline jlong os::lseek(int fd, jlong offset, int whence) {
    5.19    return (jlong) ::lseek(fd, offset, whence);
    5.20  }
    5.21 @@ -122,28 +111,6 @@
    5.22    return ::ftruncate(fd, length);
    5.23  }
    5.24  
    5.25 -inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
    5.26 -{
    5.27 -  dirent* p;
    5.28 -  int status;
    5.29 -  assert(dirp != NULL, "just checking");
    5.30 -
    5.31 -  // NOTE: Bsd readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX
    5.32 -  // version. Here is the doc for this function:
    5.33 -  // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html
    5.34 -
    5.35 -  if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
    5.36 -    errno = status;
    5.37 -    return NULL;
    5.38 -  } else
    5.39 -    return p;
    5.40 -}
    5.41 -
    5.42 -inline int os::closedir(DIR *dirp) {
    5.43 -  assert(dirp != NULL, "argument is NULL");
    5.44 -  return ::closedir(dirp);
    5.45 -}
    5.46 -
    5.47  // macros for restartable system calls
    5.48  
    5.49  #define RESTARTABLE(_cmd, _result) do { \
     6.1 --- a/src/os/bsd/vm/perfMemory_bsd.cpp	Tue Apr 30 14:49:19 2019 +0200
     6.2 +++ b/src/os/bsd/vm/perfMemory_bsd.cpp	Mon Jun 17 16:41:38 2019 +0100
     6.3 @@ -533,9 +533,8 @@
     6.4    // to determine the user name for the process id.
     6.5    //
     6.6    struct dirent* dentry;
     6.7 -  char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname), mtInternal);
     6.8    errno = 0;
     6.9 -  while ((dentry = os::readdir(tmpdirp, (struct dirent *)tdbuf)) != NULL) {
    6.10 +  while ((dentry = os::readdir(tmpdirp)) != NULL) {
    6.11  
    6.12      // check if the directory entry is a hsperfdata file
    6.13      if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
    6.14 @@ -557,9 +556,8 @@
    6.15      }
    6.16  
    6.17      struct dirent* udentry;
    6.18 -    char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name), mtInternal);
    6.19      errno = 0;
    6.20 -    while ((udentry = os::readdir(subdirp, (struct dirent *)udbuf)) != NULL) {
    6.21 +    while ((udentry = os::readdir(subdirp)) != NULL) {
    6.22  
    6.23        if (filename_to_pid(udentry->d_name) == vmid) {
    6.24          struct stat statbuf;
    6.25 @@ -603,11 +601,9 @@
    6.26        }
    6.27      }
    6.28      os::closedir(subdirp);
    6.29 -    FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
    6.30      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
    6.31    }
    6.32    os::closedir(tmpdirp);
    6.33 -  FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
    6.34  
    6.35    return(oldest_user);
    6.36  }
    6.37 @@ -686,10 +682,8 @@
    6.38    // opendir/readdir.
    6.39    //
    6.40    struct dirent* entry;
    6.41 -  char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
    6.42 -
    6.43    errno = 0;
    6.44 -  while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) {
    6.45 +  while ((entry = os::readdir(dirp)) != NULL) {
    6.46  
    6.47      pid_t pid = filename_to_pid(entry->d_name);
    6.48  
    6.49 @@ -729,7 +723,6 @@
    6.50    // close the directory and reset the current working directory
    6.51    close_directory_secure_cwd(dirp, saved_cwd_fd);
    6.52  
    6.53 -  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
    6.54  }
    6.55  
    6.56  // make the user specific temporary directory. Returns true if
     7.1 --- a/src/os/linux/vm/os_linux.cpp	Tue Apr 30 14:49:19 2019 +0200
     7.2 +++ b/src/os/linux/vm/os_linux.cpp	Mon Jun 17 16:41:38 2019 +0100
     7.3 @@ -5501,8 +5501,7 @@
     7.4  
     7.5    /* Scan the directory */
     7.6    bool result = true;
     7.7 -  char buf[sizeof(struct dirent) + MAX_PATH];
     7.8 -  while (result && (ptr = ::readdir(dir)) != NULL) {
     7.9 +  while (result && (ptr = readdir(dir)) != NULL) {
    7.10      if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
    7.11        result = false;
    7.12      }
     8.1 --- a/src/os/linux/vm/os_linux.inline.hpp	Tue Apr 30 14:49:19 2019 +0200
     8.2 +++ b/src/os/linux/vm/os_linux.inline.hpp	Mon Jun 17 16:41:38 2019 +0100
     8.3 @@ -87,17 +87,6 @@
     8.4  
     8.5  inline const int os::default_file_open_flags() { return 0;}
     8.6  
     8.7 -inline DIR* os::opendir(const char* dirname)
     8.8 -{
     8.9 -  assert(dirname != NULL, "just checking");
    8.10 -  return ::opendir(dirname);
    8.11 -}
    8.12 -
    8.13 -inline int os::readdir_buf_size(const char *path)
    8.14 -{
    8.15 -  return NAME_MAX + sizeof(dirent) + 1;
    8.16 -}
    8.17 -
    8.18  inline jlong os::lseek(int fd, jlong offset, int whence) {
    8.19    return (jlong) ::lseek64(fd, offset, whence);
    8.20  }
    8.21 @@ -114,28 +103,6 @@
    8.22    return ::ftruncate64(fd, length);
    8.23  }
    8.24  
    8.25 -inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
    8.26 -{
    8.27 -  dirent* p;
    8.28 -  int status;
    8.29 -  assert(dirp != NULL, "just checking");
    8.30 -
    8.31 -  // NOTE: Linux readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX
    8.32 -  // version. Here is the doc for this function:
    8.33 -  // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html
    8.34 -
    8.35 -  if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
    8.36 -    errno = status;
    8.37 -    return NULL;
    8.38 -  } else
    8.39 -    return p;
    8.40 -}
    8.41 -
    8.42 -inline int os::closedir(DIR *dirp) {
    8.43 -  assert(dirp != NULL, "argument is NULL");
    8.44 -  return ::closedir(dirp);
    8.45 -}
    8.46 -
    8.47  // macros for restartable system calls
    8.48  
    8.49  #define RESTARTABLE(_cmd, _result) do { \
     9.1 --- a/src/os/linux/vm/perfMemory_linux.cpp	Tue Apr 30 14:49:19 2019 +0200
     9.2 +++ b/src/os/linux/vm/perfMemory_linux.cpp	Mon Jun 17 16:41:38 2019 +0100
     9.3 @@ -533,9 +533,8 @@
     9.4    // to determine the user name for the process id.
     9.5    //
     9.6    struct dirent* dentry;
     9.7 -  char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname), mtInternal);
     9.8    errno = 0;
     9.9 -  while ((dentry = os::readdir(tmpdirp, (struct dirent *)tdbuf)) != NULL) {
    9.10 +  while ((dentry = os::readdir(tmpdirp)) != NULL) {
    9.11  
    9.12      // check if the directory entry is a hsperfdata file
    9.13      if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
    9.14 @@ -569,9 +568,8 @@
    9.15      }
    9.16  
    9.17      struct dirent* udentry;
    9.18 -    char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name), mtInternal);
    9.19      errno = 0;
    9.20 -    while ((udentry = os::readdir(subdirp, (struct dirent *)udbuf)) != NULL) {
    9.21 +    while ((udentry = os::readdir(subdirp)) != NULL) {
    9.22  
    9.23        if (filename_to_pid(udentry->d_name) == vmid) {
    9.24          struct stat statbuf;
    9.25 @@ -615,11 +613,9 @@
    9.26        }
    9.27      }
    9.28      os::closedir(subdirp);
    9.29 -    FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
    9.30      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
    9.31    }
    9.32    os::closedir(tmpdirp);
    9.33 -  FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
    9.34  
    9.35    return(oldest_user);
    9.36  }
    9.37 @@ -698,10 +694,8 @@
    9.38    // opendir/readdir.
    9.39    //
    9.40    struct dirent* entry;
    9.41 -  char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
    9.42 -
    9.43    errno = 0;
    9.44 -  while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) {
    9.45 +  while ((entry = os::readdir(dirp)) != NULL) {
    9.46  
    9.47      pid_t pid = filename_to_pid(entry->d_name);
    9.48  
    9.49 @@ -738,8 +732,6 @@
    9.50  
    9.51    // close the directory and reset the current working directory
    9.52    close_directory_secure_cwd(dirp, saved_cwd_fd);
    9.53 -
    9.54 -  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
    9.55  }
    9.56  
    9.57  // make the user specific temporary directory. Returns true if
    10.1 --- a/src/os/posix/vm/os_posix.cpp	Tue Apr 30 14:49:19 2019 +0200
    10.2 +++ b/src/os/posix/vm/os_posix.cpp	Mon Jun 17 16:41:38 2019 +0100
    10.3 @@ -302,6 +302,21 @@
    10.4    return ::fdopen(fd, mode);
    10.5  }
    10.6  
    10.7 +DIR* os::opendir(const char* dirname) {
    10.8 +  assert(dirname != NULL, "just checking");
    10.9 +  return ::opendir(dirname);
   10.10 +}
   10.11 +
   10.12 +struct dirent* os::readdir(DIR* dirp) {
   10.13 +  assert(dirp != NULL, "just checking");
   10.14 +  return ::readdir(dirp);
   10.15 +}
   10.16 +
   10.17 +int os::closedir(DIR *dirp) {
   10.18 +  assert(dirp != NULL, "just checking");
   10.19 +  return ::closedir(dirp);
   10.20 +}
   10.21 +
   10.22  // Builds a platform dependent Agent_OnLoad_<lib_name> function name
   10.23  // which is used to find statically linked in agents.
   10.24  // Parameters:
    11.1 --- a/src/os/solaris/vm/os_solaris.cpp	Tue Apr 30 14:49:19 2019 +0200
    11.2 +++ b/src/os/solaris/vm/os_solaris.cpp	Mon Jun 17 16:41:38 2019 +0100
    11.3 @@ -5163,9 +5163,7 @@
    11.4  
    11.5    /* Scan the directory */
    11.6    bool result = true;
    11.7 -  char buf[sizeof(struct dirent) + MAX_PATH];
    11.8 -  struct dirent *dbuf = (struct dirent *) buf;
    11.9 -  while (result && (ptr = readdir(dir, dbuf)) != NULL) {
   11.10 +  while (result && (ptr = readdir(dir)) != NULL) {
   11.11      if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
   11.12        result = false;
   11.13      }
    12.1 --- a/src/os/solaris/vm/os_solaris.inline.hpp	Tue Apr 30 14:49:19 2019 +0200
    12.2 +++ b/src/os/solaris/vm/os_solaris.inline.hpp	Mon Jun 17 16:41:38 2019 +0100
    12.3 @@ -71,37 +71,6 @@
    12.4  }
    12.5  inline void os::dll_unload(void *lib) { ::dlclose(lib); }
    12.6  
    12.7 -inline DIR* os::opendir(const char* dirname) {
    12.8 -  assert(dirname != NULL, "just checking");
    12.9 -  return ::opendir(dirname);
   12.10 -}
   12.11 -
   12.12 -inline int os::readdir_buf_size(const char *path) {
   12.13 -  int size = pathconf(path, _PC_NAME_MAX);
   12.14 -  return (size < 0 ? MAXPATHLEN : size) + sizeof(dirent) + 1;
   12.15 -}
   12.16 -
   12.17 -inline struct dirent* os::readdir(DIR* dirp, dirent* dbuf) {
   12.18 -  assert(dirp != NULL, "just checking");
   12.19 -#if defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64
   12.20 -  dirent* p;
   12.21 -  int status;
   12.22 -
   12.23 -  if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
   12.24 -    errno = status;
   12.25 -    return NULL;
   12.26 -  } else
   12.27 -    return p;
   12.28 -#else  // defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64
   12.29 -  return ::readdir_r(dirp, dbuf);
   12.30 -#endif // defined(_LP64) || defined(_GNU_SOURCE) || _FILE_OFFSET_BITS==64
   12.31 -}
   12.32 -
   12.33 -inline int os::closedir(DIR *dirp) {
   12.34 -  assert(dirp != NULL, "argument is NULL");
   12.35 -  return ::closedir(dirp);
   12.36 -}
   12.37 -
   12.38  //////////////////////////////////////////////////////////////////////////////
   12.39  ////////////////////////////////////////////////////////////////////////////////
   12.40  
    13.1 --- a/src/os/solaris/vm/perfMemory_solaris.cpp	Tue Apr 30 14:49:19 2019 +0200
    13.2 +++ b/src/os/solaris/vm/perfMemory_solaris.cpp	Mon Jun 17 16:41:38 2019 +0100
    13.3 @@ -524,9 +524,8 @@
    13.4    // to determine the user name for the process id.
    13.5    //
    13.6    struct dirent* dentry;
    13.7 -  char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname), mtInternal);
    13.8    errno = 0;
    13.9 -  while ((dentry = os::readdir(tmpdirp, (struct dirent *)tdbuf)) != NULL) {
   13.10 +  while ((dentry = os::readdir(tmpdirp)) != NULL) {
   13.11  
   13.12      // check if the directory entry is a hsperfdata file
   13.13      if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
   13.14 @@ -560,9 +559,8 @@
   13.15      }
   13.16  
   13.17      struct dirent* udentry;
   13.18 -    char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name), mtInternal);
   13.19      errno = 0;
   13.20 -    while ((udentry = os::readdir(subdirp, (struct dirent *)udbuf)) != NULL) {
   13.21 +    while ((udentry = os::readdir(subdirp)) != NULL) {
   13.22  
   13.23        if (filename_to_pid(udentry->d_name) == vmid) {
   13.24          struct stat statbuf;
   13.25 @@ -606,11 +604,9 @@
   13.26        }
   13.27      }
   13.28      os::closedir(subdirp);
   13.29 -    FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
   13.30      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
   13.31    }
   13.32    os::closedir(tmpdirp);
   13.33 -  FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
   13.34  
   13.35    return(oldest_user);
   13.36  }
   13.37 @@ -737,10 +733,8 @@
   13.38    // opendir/readdir.
   13.39    //
   13.40    struct dirent* entry;
   13.41 -  char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
   13.42 -
   13.43    errno = 0;
   13.44 -  while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) {
   13.45 +  while ((entry = os::readdir(dirp)) != NULL) {
   13.46  
   13.47      pid_t pid = filename_to_pid(entry->d_name);
   13.48  
   13.49 @@ -780,7 +774,6 @@
   13.50    // close the directory and reset the current working directory
   13.51    close_directory_secure_cwd(dirp, saved_cwd_fd);
   13.52  
   13.53 -  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
   13.54  }
   13.55  
   13.56  // make the user specific temporary directory. Returns true if
    14.1 --- a/src/os/windows/vm/os_windows.cpp	Tue Apr 30 14:49:19 2019 +0200
    14.2 +++ b/src/os/windows/vm/os_windows.cpp	Mon Jun 17 16:41:38 2019 +0100
    14.3 @@ -1172,14 +1172,12 @@
    14.4      return dirp;
    14.5  }
    14.6  
    14.7 -/* parameter dbuf unused on Windows */
    14.8 -
    14.9  struct dirent *
   14.10 -os::readdir(DIR *dirp, dirent *dbuf)
   14.11 +os::readdir(DIR *dirp)
   14.12  {
   14.13      assert(dirp != NULL, "just checking");      // hotspot change
   14.14      if (dirp->handle == INVALID_HANDLE_VALUE) {
   14.15 -        return 0;
   14.16 +        return NULL;
   14.17      }
   14.18  
   14.19      strcpy(dirp->dirent.d_name, dirp->find_data.cFileName);
   14.20 @@ -1187,7 +1185,7 @@
   14.21      if (!FindNextFile(dirp->handle, &dirp->find_data)) {
   14.22          if (GetLastError() == ERROR_INVALID_HANDLE) {
   14.23              errno = EBADF;
   14.24 -            return 0;
   14.25 +            return NULL;
   14.26          }
   14.27          FindClose(dirp->handle);
   14.28          dirp->handle = INVALID_HANDLE_VALUE;
    15.1 --- a/src/os/windows/vm/os_windows.inline.hpp	Tue Apr 30 14:49:19 2019 +0200
    15.2 +++ b/src/os/windows/vm/os_windows.inline.hpp	Mon Jun 17 16:41:38 2019 +0100
    15.3 @@ -65,14 +65,6 @@
    15.4    return true;
    15.5  }
    15.6  
    15.7 -inline int os::readdir_buf_size(const char *path)
    15.8 -{
    15.9 -  /* As Windows doesn't use the directory entry buffer passed to
   15.10 -     os::readdir() this can be as short as possible */
   15.11 -
   15.12 -  return 1;
   15.13 -}
   15.14 -
   15.15  // Bang the shadow pages if they need to be touched to be mapped.
   15.16  inline void os::bang_stack_shadow_pages() {
   15.17    // Write to each page of our new frame to force OS mapping.
    16.1 --- a/src/os/windows/vm/perfMemory_windows.cpp	Tue Apr 30 14:49:19 2019 +0200
    16.2 +++ b/src/os/windows/vm/perfMemory_windows.cpp	Mon Jun 17 16:41:38 2019 +0100
    16.3 @@ -316,9 +316,8 @@
    16.4    // to determine the user name for the process id.
    16.5    //
    16.6    struct dirent* dentry;
    16.7 -  char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname), mtInternal);
    16.8    errno = 0;
    16.9 -  while ((dentry = os::readdir(tmpdirp, (struct dirent *)tdbuf)) != NULL) {
   16.10 +  while ((dentry = os::readdir(tmpdirp)) != NULL) {
   16.11  
   16.12      // check if the directory entry is a hsperfdata file
   16.13      if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
   16.14 @@ -351,9 +350,8 @@
   16.15      }
   16.16  
   16.17      struct dirent* udentry;
   16.18 -    char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name), mtInternal);
   16.19      errno = 0;
   16.20 -    while ((udentry = os::readdir(subdirp, (struct dirent *)udbuf)) != NULL) {
   16.21 +    while ((udentry = os::readdir(subdirp)) != NULL) {
   16.22  
   16.23        if (filename_to_pid(udentry->d_name) == vmid) {
   16.24          struct stat statbuf;
   16.25 @@ -405,11 +403,9 @@
   16.26        }
   16.27      }
   16.28      os::closedir(subdirp);
   16.29 -    FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
   16.30      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
   16.31    }
   16.32    os::closedir(tmpdirp);
   16.33 -  FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
   16.34  
   16.35    return(latest_user);
   16.36  }
   16.37 @@ -639,9 +635,8 @@
   16.38    // opendir/readdir.
   16.39    //
   16.40    struct dirent* entry;
   16.41 -  char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
   16.42    errno = 0;
   16.43 -  while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) {
   16.44 +  while ((entry = os::readdir(dirp)) != NULL) {
   16.45  
   16.46      int pid = filename_to_pid(entry->d_name);
   16.47  
   16.48 @@ -682,7 +677,6 @@
   16.49      errno = 0;
   16.50    }
   16.51    os::closedir(dirp);
   16.52 -  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
   16.53  }
   16.54  
   16.55  // create a file mapping object with the requested name, and size
    17.1 --- a/src/share/vm/runtime/arguments.cpp	Tue Apr 30 14:49:19 2019 +0200
    17.2 +++ b/src/share/vm/runtime/arguments.cpp	Mon Jun 17 16:41:38 2019 +0100
    17.3 @@ -556,8 +556,7 @@
    17.4  
    17.5    /* Scan the directory for jars/zips, appending them to path. */
    17.6    struct dirent *entry;
    17.7 -  char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
    17.8 -  while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
    17.9 +  while ((entry = os::readdir(dir)) != NULL) {
   17.10      const char* name = entry->d_name;
   17.11      const char* ext = name + strlen(name) - 4;
   17.12      bool isJarOrZip = ext > name &&
   17.13 @@ -571,7 +570,6 @@
   17.14        FREE_C_HEAP_ARRAY(char, jarpath, mtInternal);
   17.15      }
   17.16    }
   17.17 -  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
   17.18    os::closedir(dir);
   17.19    return path;
   17.20  }
   17.21 @@ -3485,14 +3483,12 @@
   17.22    if (dir == NULL) return false;
   17.23  
   17.24    struct dirent *entry;
   17.25 -  char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
   17.26    bool hasJarFile = false;
   17.27 -  while (!hasJarFile && (entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
   17.28 +  while (!hasJarFile && (entry = os::readdir(dir)) != NULL) {
   17.29      const char* name = entry->d_name;
   17.30      const char* ext = name + strlen(name) - 4;
   17.31      hasJarFile = ext > name && (os::file_name_strcmp(ext, ".jar") == 0);
   17.32    }
   17.33 -  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
   17.34    os::closedir(dir);
   17.35    return hasJarFile ;
   17.36  }
   17.37 @@ -3574,8 +3570,7 @@
   17.38    if (dir != NULL) {
   17.39      int num_ext_jars = 0;
   17.40      struct dirent *entry;
   17.41 -    char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(extDir), mtInternal);
   17.42 -    while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
   17.43 +    while ((entry = os::readdir(dir)) != NULL) {
   17.44        const char* name = entry->d_name;
   17.45        const char* ext = name + strlen(name) - 4;
   17.46        if (ext > name && (os::file_name_strcmp(ext, ".jar") == 0)) {
   17.47 @@ -3594,7 +3589,6 @@
   17.48          }
   17.49        }
   17.50      }
   17.51 -    FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
   17.52      os::closedir(dir);
   17.53      if (num_ext_jars > 0) {
   17.54        nonEmptyDirs += 1;
    18.1 --- a/src/share/vm/runtime/os.hpp	Tue Apr 30 14:49:19 2019 +0200
    18.2 +++ b/src/share/vm/runtime/os.hpp	Mon Jun 17 16:41:38 2019 +0100
    18.3 @@ -561,8 +561,7 @@
    18.4  
    18.5    // Reading directories.
    18.6    static DIR*           opendir(const char* dirname);
    18.7 -  static int            readdir_buf_size(const char *path);
    18.8 -  static struct dirent* readdir(DIR* dirp, dirent* dbuf);
    18.9 +  static struct dirent* readdir(DIR* dirp);
   18.10    static int            closedir(DIR* dirp);
   18.11  
   18.12    // Dynamic library extension

mercurial