diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2016-06-27 22:23:42 -0400 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2016-08-30 18:10:40 +1000 |
commit | c981f5ad76cb77363dcb4ebcc199670c3378995f (patch) | |
tree | 45b189760ed2fe4d2327f89c872ee532485c4b0e | |
parent | af83a585745d6108d7af2d4a2d1eae9b28a8c4b6 (diff) |
hook.c: replace readdir_r with readdir
glibc 2.24 deprecates readdir_r.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r-- | lib/libalpm/hook.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/libalpm/hook.c b/lib/libalpm/hook.c index 6890a6ec..9b4f215d 100644 --- a/lib/libalpm/hook.c +++ b/lib/libalpm/hook.c @@ -623,10 +623,9 @@ int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when) int ret = 0; for(i = alpm_list_last(handle->hookdirs); i; i = alpm_list_previous(i)) { - int err; char path[PATH_MAX]; size_t dirlen; - struct dirent entry, *result; + struct dirent *entry; DIR *d; if((dirlen = strlen(i->data)) >= PATH_MAX) { @@ -648,35 +647,35 @@ int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when) } } - while((err = readdir_r(d, &entry, &result)) == 0 && result) { + while((errno = 0, entry = readdir(d))) { struct _alpm_hook_cb_ctx ctx = { handle, NULL }; struct stat buf; size_t name_len; - if(strcmp(entry.d_name, ".") == 0 || strcmp(entry.d_name, "..") == 0) { - continue; + if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) { + continue; } - if((name_len = strlen(entry.d_name)) >= PATH_MAX - dirlen) { + if((name_len = strlen(entry->d_name)) >= PATH_MAX - dirlen) { _alpm_log(handle, ALPM_LOG_ERROR, _("could not open file: %s%s: %s\n"), - path, entry.d_name, strerror(ENAMETOOLONG)); + path, entry->d_name, strerror(ENAMETOOLONG)); ret = -1; continue; } - memcpy(path + dirlen, entry.d_name, name_len + 1); + memcpy(path + dirlen, entry->d_name, name_len + 1); if(name_len < suflen - || strcmp(entry.d_name + name_len - suflen, suffix) != 0) { + || strcmp(entry->d_name + name_len - suflen, suffix) != 0) { _alpm_log(handle, ALPM_LOG_DEBUG, "skipping non-hook file %s\n", path); continue; } - if(find_hook(hooks, entry.d_name)) { + if(find_hook(hooks, entry->d_name)) { _alpm_log(handle, ALPM_LOG_DEBUG, "skipping overridden hook %s\n", path); continue; } - if(fstatat(dirfd(d), entry.d_name, &buf, 0) != 0) { + if(fstatat(dirfd(d), entry->d_name, &buf, 0) != 0) { _alpm_log(handle, ALPM_LOG_ERROR, _("could not stat file %s: %s\n"), path, strerror(errno)); ret = -1; @@ -700,11 +699,10 @@ int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when) continue; } - STRDUP(ctx.hook->name, entry.d_name, ret = -1; closedir(d); goto cleanup); + STRDUP(ctx.hook->name, entry->d_name, ret = -1; closedir(d); goto cleanup); hooks = alpm_list_add(hooks, ctx.hook); } - - if(err != 0) { + if(errno != 0) { _alpm_log(handle, ALPM_LOG_ERROR, _("could not read directory: %s: %s\n"), (char *) i->data, strerror(errno)); ret = -1; |