mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 16:21:26 +03:00
basic/glob-util: add closedir wrapper to silence gcc
../src/test/test-glob-util.c: In function 'test_glob_no_dot': ../src/test/test-glob-util.c:61:32: warning: cast between incompatible function types from 'int (*)(DIR *)' {aka 'int (*)(struct __dirstream *)'} to 'void (*)(void *)' [-Wcast-function-type] .gl_closedir = (void (*)(void *)) closedir, ^
This commit is contained in:
parent
24c2c5689d
commit
1fe101747c
@ -29,6 +29,10 @@
|
||||
#include "path-util.h"
|
||||
#include "strv.h"
|
||||
|
||||
static void _closedir(void* v) {
|
||||
(void) closedir(v);
|
||||
}
|
||||
|
||||
int safe_glob(const char *path, int flags, glob_t *pglob) {
|
||||
int k;
|
||||
|
||||
@ -36,7 +40,7 @@ int safe_glob(const char *path, int flags, glob_t *pglob) {
|
||||
assert(!(flags & GLOB_ALTDIRFUNC));
|
||||
|
||||
if (!pglob->gl_closedir)
|
||||
pglob->gl_closedir = (void (*)(void *)) closedir;
|
||||
pglob->gl_closedir = _closedir;
|
||||
if (!pglob->gl_readdir)
|
||||
pglob->gl_readdir = (struct dirent *(*)(void *)) readdir_no_dot;
|
||||
if (!pglob->gl_opendir)
|
||||
|
@ -49,12 +49,16 @@ static void test_glob_exists(void) {
|
||||
assert_se(r == 0);
|
||||
}
|
||||
|
||||
static void _closedir(void* v) {
|
||||
(void) closedir(v);
|
||||
}
|
||||
|
||||
static void test_glob_no_dot(void) {
|
||||
char template[] = "/tmp/test-glob-util.XXXXXXX";
|
||||
const char *fn;
|
||||
|
||||
_cleanup_globfree_ glob_t g = {
|
||||
.gl_closedir = (void (*)(void *)) closedir,
|
||||
.gl_closedir = _closedir,
|
||||
.gl_readdir = (struct dirent *(*)(void *)) readdir_no_dot,
|
||||
.gl_opendir = (void *(*)(const char *)) opendir,
|
||||
.gl_lstat = lstat,
|
||||
|
Loading…
Reference in New Issue
Block a user