mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
udev-detect: don't use readdir_r(), it's deprecated
readdir_r() was supposed to be a thread-safe version of readdir(), but the interface turned out to be problematic. Due to the problems and the fact that readdir() is safe enough on modern libc implementations, glibc deprecated readdir_r() in version 2.24. The man page contains more information about what's wrong with readdir_r(): http://man7.org/linux/man-pages/man3/readdir_r.3.html
This commit is contained in:
parent
1992c4cce1
commit
6022a1ee99
1 changed files with 9 additions and 13 deletions
|
|
@ -177,10 +177,8 @@ static bool is_card_busy(const char *id) {
|
||||||
char *card_path = NULL, *pcm_path = NULL, *sub_status = NULL;
|
char *card_path = NULL, *pcm_path = NULL, *sub_status = NULL;
|
||||||
DIR *card_dir = NULL, *pcm_dir = NULL;
|
DIR *card_dir = NULL, *pcm_dir = NULL;
|
||||||
FILE *status_file = NULL;
|
FILE *status_file = NULL;
|
||||||
size_t len;
|
struct dirent *de;
|
||||||
struct dirent *space = NULL, *de;
|
|
||||||
bool busy = false;
|
bool busy = false;
|
||||||
int r;
|
|
||||||
|
|
||||||
pa_assert(id);
|
pa_assert(id);
|
||||||
|
|
||||||
|
|
@ -194,14 +192,11 @@ static bool is_card_busy(const char *id) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = offsetof(struct dirent, d_name) + fpathconf(dirfd(card_dir), _PC_NAME_MAX) + 1;
|
|
||||||
space = pa_xmalloc(len);
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
de = NULL;
|
errno = 0;
|
||||||
|
de = readdir(card_dir);
|
||||||
if ((r = readdir_r(card_dir, space, &de)) != 0) {
|
if (!de && errno) {
|
||||||
pa_log_warn("readdir_r() failed: %s", pa_cstrerror(r));
|
pa_log_warn("readdir() failed: %s", pa_cstrerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,8 +223,10 @@ static bool is_card_busy(const char *id) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char line[32];
|
char line[32];
|
||||||
|
|
||||||
if ((r = readdir_r(pcm_dir, space, &de)) != 0) {
|
errno = 0;
|
||||||
pa_log_warn("readdir_r() failed: %s", pa_cstrerror(r));
|
de = readdir(pcm_dir);
|
||||||
|
if (!de && errno) {
|
||||||
|
pa_log_warn("readdir() failed: %s", pa_cstrerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,7 +264,6 @@ fail:
|
||||||
pa_xfree(card_path);
|
pa_xfree(card_path);
|
||||||
pa_xfree(pcm_path);
|
pa_xfree(pcm_path);
|
||||||
pa_xfree(sub_status);
|
pa_xfree(sub_status);
|
||||||
pa_xfree(space);
|
|
||||||
|
|
||||||
if (card_dir)
|
if (card_dir)
|
||||||
closedir(card_dir);
|
closedir(card_dir);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue