mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-10-04 07:57:45 +00:00
coroparse: Use readdir instead of readdir_r
readdir_r is deprecated in glibc 2.24 in favor of readdir (which became thread safe). Also because corosync never calls read_uidgid_files_into_icmap in muliple threads, no problem should appears even with libc where readdir is thread-safe. Signed-off-by: Bin Liu <bliu@suse.com> Reviewed-by: Jan Friesse <jfriesse@redhat.com>
This commit is contained in:
parent
725f9039e9
commit
c83e6c7ed9
@ -1321,11 +1321,8 @@ static int read_uidgid_files_into_icmap(
|
||||
const char *dirname;
|
||||
DIR *dp;
|
||||
struct dirent *dirent;
|
||||
struct dirent *entry;
|
||||
char filename[PATH_MAX + FILENAME_MAX + 1];
|
||||
int res = 0;
|
||||
size_t len;
|
||||
int return_code;
|
||||
struct stat stat_buf;
|
||||
enum main_cp_cb_data_state state = MAIN_CP_CB_DATA_STATE_NORMAL;
|
||||
char key_name[ICMAP_KEYNAME_MAXLEN];
|
||||
@ -1336,17 +1333,9 @@ static int read_uidgid_files_into_icmap(
|
||||
if (dp == NULL)
|
||||
return 0;
|
||||
|
||||
len = offsetof(struct dirent, d_name) + FILENAME_MAX + 1;
|
||||
|
||||
entry = malloc(len);
|
||||
if (entry == NULL) {
|
||||
res = 0;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
for (return_code = readdir_r(dp, entry, &dirent);
|
||||
dirent != NULL && return_code == 0;
|
||||
return_code = readdir_r(dp, entry, &dirent)) {
|
||||
for (dirent = readdir(dp);
|
||||
dirent != NULL;
|
||||
dirent = readdir(dp)) {
|
||||
|
||||
snprintf(filename, sizeof (filename), "%s/%s", dirname, dirent->d_name);
|
||||
res = stat (filename, &stat_buf);
|
||||
@ -1368,7 +1357,6 @@ static int read_uidgid_files_into_icmap(
|
||||
}
|
||||
|
||||
error_exit:
|
||||
free (entry);
|
||||
closedir(dp);
|
||||
|
||||
return res;
|
||||
|
Loading…
Reference in New Issue
Block a user