Skip to content

Commit

Permalink
[Minor] Simplify legacy calls via glib
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Oct 30, 2022
1 parent 8b8ee6a commit 530b872
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/libserver/cfg_rcl.c
Expand Up @@ -810,14 +810,12 @@ rspamd_rcl_lua_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
struct rspamd_config *cfg = ud;
const gchar *lua_src = rspamd_mempool_strdup (pool,
ucl_object_tostring (obj));
gchar *cur_dir, *lua_dir, *lua_file, *tmp1, *tmp2;
gchar *cur_dir, *lua_dir, *lua_file;
lua_State *L = cfg->lua_state;
gint err_idx;

tmp1 = g_strdup (lua_src);
tmp2 = g_strdup (lua_src);
lua_dir = dirname (tmp1);
lua_file = basename (tmp2);
lua_dir = g_path_get_dirname(lua_src);
lua_file = g_path_get_basename(lua_src);

if (lua_dir && lua_file) {
cur_dir = g_malloc (PATH_MAX);
Expand All @@ -839,8 +837,8 @@ rspamd_rcl_lua_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
strerror (errno));
}
g_free (cur_dir);
g_free (tmp1);
g_free (tmp2);
g_free (lua_dir);
g_free (lua_file);
return FALSE;
}

Expand All @@ -860,8 +858,8 @@ rspamd_rcl_lua_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
}

g_free (cur_dir);
g_free (tmp1);
g_free (tmp2);
g_free (lua_file);
g_free (lua_dir);

return FALSE;
}
Expand All @@ -875,21 +873,21 @@ rspamd_rcl_lua_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
msg_err_config ("cannot chdir to %s: %s", cur_dir, strerror (errno));
}
g_free (cur_dir);
g_free (tmp1);
g_free (tmp2);
g_free (lua_dir);
g_free (lua_file);
return FALSE;

}
if (chdir (cur_dir) == -1) {
msg_err_config ("cannot chdir to %s: %s", cur_dir, strerror (errno));
}
g_free (cur_dir);
g_free (tmp1);
g_free (tmp2);
g_free (lua_dir);
g_free (lua_file);
}
else {
g_free (tmp1);
g_free (tmp2);
g_free (lua_dir);
g_free (lua_file);
g_set_error (err, CFG_RCL_ERROR, ENOENT, "cannot find to %s: %s",
lua_src, strerror (errno));
return FALSE;
Expand Down

0 comments on commit 530b872

Please sign in to comment.