Skip to content

Commit

Permalink
MDEV-14469 build with cmake -DMYSQL_MAINTAINER_MODE=ON fails: 'readdi…
Browse files Browse the repository at this point in the history
…r_r' is deprecated

1. test readdir_r() availability under -Werror
2. don't protect readdir() with mutexes, it's not needed for the way
   we use readdir()
  • Loading branch information
vuvova committed Jan 15, 2018
1 parent d31ee64 commit d800110
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 10 additions & 1 deletion configure.cmake
Expand Up @@ -407,7 +407,6 @@ CHECK_FUNCTION_EXISTS (pthread_sigmask HAVE_PTHREAD_SIGMASK)
CHECK_FUNCTION_EXISTS (pthread_threadmask HAVE_PTHREAD_THREADMASK)
CHECK_FUNCTION_EXISTS (pthread_yield_np HAVE_PTHREAD_YIELD_NP)
CHECK_FUNCTION_EXISTS (putenv HAVE_PUTENV)
CHECK_FUNCTION_EXISTS (readdir_r HAVE_READDIR_R)
CHECK_FUNCTION_EXISTS (readlink HAVE_READLINK)
CHECK_FUNCTION_EXISTS (re_comp HAVE_RE_COMP)
CHECK_FUNCTION_EXISTS (regcomp HAVE_REGCOMP)
Expand Down Expand Up @@ -465,6 +464,16 @@ IF(HAVE_SYS_EVENT_H)
CHECK_FUNCTION_EXISTS (kqueue HAVE_KQUEUE)
ENDIF()

# readdir_r might exist, but be marked deprecated
SET(CMAKE_REQUIRED_FLAGS -Werror)
CHECK_CXX_SOURCE_COMPILES(
"#include <dirent.h>
int main() {
readdir_r(0,0,0);
return 0;
}" HAVE_READDIR_R)
SET(CMAKE_REQUIRED_FLAGS)

#--------------------------------------------------------------------
# Support for WL#2373 (Use cycle counter for timing)
#--------------------------------------------------------------------
Expand Down
10 changes: 0 additions & 10 deletions mysys/my_lib.c
Expand Up @@ -103,10 +103,6 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
DBUG_ENTER("my_dir");
DBUG_PRINT("my",("path: '%s' MyFlags: %d",path,MyFlags));

#if !defined(HAVE_READDIR_R)
mysql_mutex_lock(&THR_LOCK_open);
#endif

dirp = opendir(directory_file_name(tmp_path,(char *) path));
#if defined(__amiga__)
if ((dirp->dd_fd) < 0) /* Directory doesn't exists */
Expand Down Expand Up @@ -162,9 +158,6 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
}

(void) closedir(dirp);
#if !defined(HAVE_READDIR_R)
mysql_mutex_unlock(&THR_LOCK_open);
#endif
result->dir_entry= (FILEINFO *)dir_entries_storage->buffer;
result->number_off_files= dir_entries_storage->elements;

Expand All @@ -174,9 +167,6 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
DBUG_RETURN(result);

error:
#if !defined(HAVE_READDIR_R)
mysql_mutex_unlock(&THR_LOCK_open);
#endif
my_errno=errno;
if (dirp)
(void) closedir(dirp);
Expand Down

0 comments on commit d800110

Please sign in to comment.