From 38a1214af1c2dbe2e57e96451a10f9c058fa3f20 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sun, 29 Jan 2017 21:04:50 +0100
Subject: Use readdir instead of readdir_r
To eliminate compiler warnings, we're single-threaded anyway.
---
plugins/lua-loader.c | 19 ++++++-------------
ponymap.c | 20 +++++++-------------
2 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/plugins/lua-loader.c b/plugins/lua-loader.c
index 8fa1875..725ba06 100644
--- a/plugins/lua-loader.c
+++ b/plugins/lua-loader.c
@@ -424,20 +424,9 @@ initialize (void *ctx, struct plugin_api *api)
lua_setfield (L, -2, "__index");
luaL_setfuncs (L, xlua_unit_table, 0);
- struct dirent buf, *iter;
- while (true)
+ struct dirent *iter;
+ while ((errno = 0, iter = readdir (dir)))
{
- if (readdir_r (dir, &buf, &iter))
- {
- print_fatal ("%s: %s: %s", "Lua", "readdir_r", strerror (errno));
- break;
- }
- if (!iter)
- {
- success = true;
- break;
- }
-
char *dot = strrchr (iter->d_name, '.');
if (!dot || strcmp (dot, ".lua"))
continue;
@@ -446,6 +435,10 @@ initialize (void *ctx, struct plugin_api *api)
(void) load_one_plugin (L, iter->d_name, path);
free (path);
}
+ if (errno)
+ print_fatal ("%s: %s: %s", "Lua", "readdir", strerror (errno));
+ else
+ success = true;
end:
closedir (dir);
diff --git a/ponymap.c b/ponymap.c
index 6f001a2..10bcf7c 100644
--- a/ponymap.c
+++ b/ponymap.c
@@ -894,20 +894,9 @@ load_plugins (struct app_context *ctx)
}
bool success = false;
- struct dirent buf, *iter;
- while (true)
+ struct dirent *iter;
+ while ((errno = 0, iter = readdir (dir)))
{
- if (readdir_r (dir, &buf, &iter))
- {
- print_fatal ("%s: %s", "readdir_r", strerror (errno));
- break;
- }
- if (!iter)
- {
- success = true;
- break;
- }
-
char *dot = strrchr (iter->d_name, '.');
if (!dot || strcmp (dot, ".so"))
continue;
@@ -916,6 +905,11 @@ load_plugins (struct app_context *ctx)
(void) load_one_plugin (ctx, iter->d_name, path);
free (path);
}
+ if (errno)
+ print_fatal ("%s: %s", "readdir", strerror (errno));
+ else
+ success = true;
+
closedir (dir);
return success;
}
--
cgit v1.2.3-70-g09d2