diff --git a/src/vfs/local/local.c b/src/vfs/local/local.c index 84ca56ed4..249864205 100644 --- a/src/vfs/local/local.c +++ b/src/vfs/local/local.c @@ -47,8 +47,10 @@ /*** file scope variables ************************************************************************/ -static struct vfs_class vfs_local_ops; +static struct vfs_s_subclass local_subclass; +static struct vfs_class *vfs_local_ops = VFS_CLASS (&local_subclass); +/* --------------------------------------------------------------------------------------------- */ /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ @@ -422,35 +424,38 @@ local_lseek (void *data, off_t offset, int whence) void init_localfs (void) { - vfs_init_class (&vfs_local_ops, "localfs", VFS_LOCAL, NULL); - vfs_local_ops.which = local_which; - vfs_local_ops.open = local_open; - vfs_local_ops.close = local_close; - vfs_local_ops.read = local_read; - vfs_local_ops.write = local_write; - vfs_local_ops.opendir = local_opendir; - vfs_local_ops.readdir = local_readdir; - vfs_local_ops.closedir = local_closedir; - vfs_local_ops.stat = local_stat; - vfs_local_ops.lstat = local_lstat; - vfs_local_ops.fstat = local_fstat; - vfs_local_ops.chmod = local_chmod; - vfs_local_ops.chown = local_chown; - vfs_local_ops.utime = local_utime; - vfs_local_ops.readlink = local_readlink; - vfs_local_ops.symlink = local_symlink; - vfs_local_ops.link = local_link; - vfs_local_ops.unlink = local_unlink; - vfs_local_ops.rename = local_rename; - vfs_local_ops.chdir = local_chdir; - vfs_local_ops.ferrno = local_errno; - vfs_local_ops.lseek = local_lseek; - vfs_local_ops.mknod = local_mknod; - vfs_local_ops.getlocalcopy = local_getlocalcopy; - vfs_local_ops.ungetlocalcopy = local_ungetlocalcopy; - vfs_local_ops.mkdir = local_mkdir; - vfs_local_ops.rmdir = local_rmdir; - vfs_register_class (&vfs_local_ops); + /* NULLize vfs_s_subclass members */ + memset (&local_subclass, 0, sizeof (local_subclass)); + + vfs_init_class (vfs_local_ops, "localfs", VFS_LOCAL, NULL); + vfs_local_ops->which = local_which; + vfs_local_ops->open = local_open; + vfs_local_ops->close = local_close; + vfs_local_ops->read = local_read; + vfs_local_ops->write = local_write; + vfs_local_ops->opendir = local_opendir; + vfs_local_ops->readdir = local_readdir; + vfs_local_ops->closedir = local_closedir; + vfs_local_ops->stat = local_stat; + vfs_local_ops->lstat = local_lstat; + vfs_local_ops->fstat = local_fstat; + vfs_local_ops->chmod = local_chmod; + vfs_local_ops->chown = local_chown; + vfs_local_ops->utime = local_utime; + vfs_local_ops->readlink = local_readlink; + vfs_local_ops->symlink = local_symlink; + vfs_local_ops->link = local_link; + vfs_local_ops->unlink = local_unlink; + vfs_local_ops->rename = local_rename; + vfs_local_ops->chdir = local_chdir; + vfs_local_ops->ferrno = local_errno; + vfs_local_ops->lseek = local_lseek; + vfs_local_ops->mknod = local_mknod; + vfs_local_ops->getlocalcopy = local_getlocalcopy; + vfs_local_ops->ungetlocalcopy = local_ungetlocalcopy; + vfs_local_ops->mkdir = local_mkdir; + vfs_local_ops->rmdir = local_rmdir; + vfs_register_class (vfs_local_ops); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/vfs/sfs/sfs.c b/src/vfs/sfs/sfs.c index 19cd60021..63ebcc795 100644 --- a/src/vfs/sfs/sfs.c +++ b/src/vfs/sfs/sfs.c @@ -102,7 +102,8 @@ typedef struct cachedfile static GSList *head; -static struct vfs_class vfs_sfs_ops; +static struct vfs_s_subclass sfs_subclass; +static struct vfs_class *vfs_sfs_ops = VFS_CLASS (&sfs_subclass); static int sfs_no = 0; static char *sfs_prefix[MAXFS]; @@ -235,7 +236,7 @@ sfs_redirect (const vfs_path_t * vpath) if (cur != NULL) { cf = (cachedfile *) cur->data; - vfs_stamp (&vfs_sfs_ops, cf); + vfs_stamp (vfs_sfs_ops, cf); return cf->cache; } @@ -254,7 +255,7 @@ sfs_redirect (const vfs_path_t * vpath) head = g_slist_prepend (head, cf); vfs_path_free (cache_vpath); - vfs_stamp_create (&vfs_sfs_ops, (cachedfile *) head->data); + vfs_stamp_create (vfs_sfs_ops, (cachedfile *) head->data); return cf->cache; } @@ -549,29 +550,32 @@ sfs_which (struct vfs_class *me, const char *path) void init_sfs (void) { - vfs_init_class (&vfs_sfs_ops, "sfs", VFS_UNKNOWN, NULL); - vfs_sfs_ops.init = sfs_init; - vfs_sfs_ops.done = sfs_done; - vfs_sfs_ops.fill_names = sfs_fill_names; - vfs_sfs_ops.which = sfs_which; - vfs_sfs_ops.open = sfs_open; - vfs_sfs_ops.close = local_close; - vfs_sfs_ops.read = local_read; - vfs_sfs_ops.stat = sfs_stat; - vfs_sfs_ops.lstat = sfs_lstat; - vfs_sfs_ops.fstat = local_fstat; - vfs_sfs_ops.chmod = sfs_chmod; - vfs_sfs_ops.chown = sfs_chown; - vfs_sfs_ops.utime = sfs_utime; - vfs_sfs_ops.readlink = sfs_readlink; - vfs_sfs_ops.ferrno = local_errno; - vfs_sfs_ops.lseek = local_lseek; - vfs_sfs_ops.getid = sfs_getid; - vfs_sfs_ops.nothingisopen = sfs_nothingisopen; - vfs_sfs_ops.free = sfs_free; - vfs_sfs_ops.getlocalcopy = sfs_getlocalcopy; - vfs_sfs_ops.ungetlocalcopy = sfs_ungetlocalcopy; - vfs_register_class (&vfs_sfs_ops); + /* NULLize vfs_s_subclass members */ + memset (&sfs_subclass, 0, sizeof (sfs_subclass)); + + vfs_init_class (vfs_sfs_ops, "sfs", VFS_UNKNOWN, NULL); + vfs_sfs_ops->init = sfs_init; + vfs_sfs_ops->done = sfs_done; + vfs_sfs_ops->fill_names = sfs_fill_names; + vfs_sfs_ops->which = sfs_which; + vfs_sfs_ops->open = sfs_open; + vfs_sfs_ops->close = local_close; + vfs_sfs_ops->read = local_read; + vfs_sfs_ops->stat = sfs_stat; + vfs_sfs_ops->lstat = sfs_lstat; + vfs_sfs_ops->fstat = local_fstat; + vfs_sfs_ops->chmod = sfs_chmod; + vfs_sfs_ops->chown = sfs_chown; + vfs_sfs_ops->utime = sfs_utime; + vfs_sfs_ops->readlink = sfs_readlink; + vfs_sfs_ops->ferrno = local_errno; + vfs_sfs_ops->lseek = local_lseek; + vfs_sfs_ops->getid = sfs_getid; + vfs_sfs_ops->nothingisopen = sfs_nothingisopen; + vfs_sfs_ops->free = sfs_free; + vfs_sfs_ops->getlocalcopy = sfs_getlocalcopy; + vfs_sfs_ops->ungetlocalcopy = sfs_ungetlocalcopy; + vfs_register_class (vfs_sfs_ops); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/vfs/smbfs/smbfs.c b/src/vfs/smbfs/smbfs.c index 56e8cde1a..a5639e3c1 100644 --- a/src/vfs/smbfs/smbfs.c +++ b/src/vfs/smbfs/smbfs.c @@ -38,6 +38,7 @@ #include #include +#include /* memset() */ #undef USE_NCURSES /* Don't include *curses.h */ #undef USE_NCURSESW @@ -138,7 +139,8 @@ static gboolean got_pass = FALSE; static pstring password; static pstring username; -static struct vfs_class vfs_smbfs_ops; +static struct vfs_s_subclass smbfs_subclass; +static struct vfs_class *vfs_smbfs_ops = VFS_CLASS (&smbfs_subclass); static struct _smbfs_connection { @@ -2240,36 +2242,39 @@ init_smbfs (void) { tcp_init (); - vfs_init_class (&vfs_smbfs_ops, "smbfs", VFS_NOLINKS, "smb"); - vfs_smbfs_ops.init = smbfs_init; - vfs_smbfs_ops.fill_names = smbfs_fill_names; - vfs_smbfs_ops.open = smbfs_open; - vfs_smbfs_ops.close = smbfs_close; - vfs_smbfs_ops.read = smbfs_read; - vfs_smbfs_ops.write = smbfs_write; - vfs_smbfs_ops.opendir = smbfs_opendir; - vfs_smbfs_ops.readdir = smbfs_readdir; - vfs_smbfs_ops.closedir = smbfs_closedir; - vfs_smbfs_ops.stat = smbfs_stat; - vfs_smbfs_ops.lstat = smbfs_lstat; - vfs_smbfs_ops.fstat = smbfs_fstat; - vfs_smbfs_ops.chmod = smbfs_chmod; - vfs_smbfs_ops.chown = smbfs_chown; - vfs_smbfs_ops.utime = smbfs_utime; - vfs_smbfs_ops.readlink = smbfs_readlink; - vfs_smbfs_ops.symlink = smbfs_symlink; - vfs_smbfs_ops.link = smbfs_link; - vfs_smbfs_ops.unlink = smbfs_unlink; - vfs_smbfs_ops.rename = smbfs_rename; - vfs_smbfs_ops.chdir = smbfs_chdir; - vfs_smbfs_ops.ferrno = smbfs_errno; - vfs_smbfs_ops.lseek = smbfs_lseek; - vfs_smbfs_ops.mknod = smbfs_mknod; - vfs_smbfs_ops.free = smbfs_free; - vfs_smbfs_ops.mkdir = smbfs_mkdir; - vfs_smbfs_ops.rmdir = smbfs_rmdir; - vfs_smbfs_ops.setctl = smbfs_setctl; - vfs_register_class (&vfs_smbfs_ops); + /* NULLize vfs_s_subclass members */ + memset (&smbfs_subclass, 0, sizeof (smbfs_subclass)); + + vfs_init_class (vfs_smbfs_ops, "smbfs", VFS_NOLINKS, "smb"); + vfs_smbfs_ops->init = smbfs_init; + vfs_smbfs_ops->fill_names = smbfs_fill_names; + vfs_smbfs_ops->open = smbfs_open; + vfs_smbfs_ops->close = smbfs_close; + vfs_smbfs_ops->read = smbfs_read; + vfs_smbfs_ops->write = smbfs_write; + vfs_smbfs_ops->opendir = smbfs_opendir; + vfs_smbfs_ops->readdir = smbfs_readdir; + vfs_smbfs_ops->closedir = smbfs_closedir; + vfs_smbfs_ops->stat = smbfs_stat; + vfs_smbfs_ops->lstat = smbfs_lstat; + vfs_smbfs_ops->fstat = smbfs_fstat; + vfs_smbfs_ops->chmod = smbfs_chmod; + vfs_smbfs_ops->chown = smbfs_chown; + vfs_smbfs_ops->utime = smbfs_utime; + vfs_smbfs_ops->readlink = smbfs_readlink; + vfs_smbfs_ops->symlink = smbfs_symlink; + vfs_smbfs_ops->link = smbfs_link; + vfs_smbfs_ops->unlink = smbfs_unlink; + vfs_smbfs_ops->rename = smbfs_rename; + vfs_smbfs_ops->chdir = smbfs_chdir; + vfs_smbfs_ops->ferrno = smbfs_errno; + vfs_smbfs_ops->lseek = smbfs_lseek; + vfs_smbfs_ops->mknod = smbfs_mknod; + vfs_smbfs_ops->free = smbfs_free; + vfs_smbfs_ops->mkdir = smbfs_mkdir; + vfs_smbfs_ops->rmdir = smbfs_rmdir; + vfs_smbfs_ops->setctl = smbfs_setctl; + vfs_register_class (vfs_smbfs_ops); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/vfs/undelfs/undelfs.c b/src/vfs/undelfs/undelfs.c index cbd7f95bc..79c23b617 100644 --- a/src/vfs/undelfs/undelfs.c +++ b/src/vfs/undelfs/undelfs.c @@ -48,6 +48,7 @@ #include #include #include +#include /* memset() */ #ifdef HAVE_EXT2FS_EXT2_FS_H #include @@ -131,7 +132,8 @@ static const char *undelfserr = N_("undelfs: error"); static int readdir_ptr; static int undelfs_usage; -static struct vfs_class vfs_undelfs_ops; +static struct vfs_s_subclass undelfs_subclass; +static struct vfs_class *vfs_undelfs_ops = VFS_CLASS (&undelfs_subclass); /* --------------------------------------------------------------------------------------------- */ /*** file scope functions ************************************************************************/ @@ -823,23 +825,26 @@ com_err (const char *whoami, long err_code, const char *fmt, ...) void init_undelfs (void) { - vfs_init_class (&vfs_undelfs_ops, "undelfs", VFS_UNKNOWN, "undel"); - vfs_undelfs_ops.init = undelfs_init; - vfs_undelfs_ops.open = undelfs_open; - vfs_undelfs_ops.close = undelfs_close; - vfs_undelfs_ops.read = undelfs_read; - vfs_undelfs_ops.opendir = undelfs_opendir; - vfs_undelfs_ops.readdir = undelfs_readdir; - vfs_undelfs_ops.closedir = undelfs_closedir; - vfs_undelfs_ops.stat = undelfs_stat; - vfs_undelfs_ops.lstat = undelfs_lstat; - vfs_undelfs_ops.fstat = undelfs_fstat; - vfs_undelfs_ops.chdir = undelfs_chdir; - vfs_undelfs_ops.lseek = undelfs_lseek; - vfs_undelfs_ops.getid = undelfs_getid; - vfs_undelfs_ops.nothingisopen = undelfs_nothingisopen; - vfs_undelfs_ops.free = undelfs_free; - vfs_register_class (&vfs_undelfs_ops); + /* NULLize vfs_s_subclass members */ + memset (&undelfs_subclass, 0, sizeof (undelfs_subclass)); + + vfs_init_class (vfs_undelfs_ops, "undelfs", VFS_UNKNOWN, "undel"); + vfs_undelfs_ops->init = undelfs_init; + vfs_undelfs_ops->open = undelfs_open; + vfs_undelfs_ops->close = undelfs_close; + vfs_undelfs_ops->read = undelfs_read; + vfs_undelfs_ops->opendir = undelfs_opendir; + vfs_undelfs_ops->readdir = undelfs_readdir; + vfs_undelfs_ops->closedir = undelfs_closedir; + vfs_undelfs_ops->stat = undelfs_stat; + vfs_undelfs_ops->lstat = undelfs_lstat; + vfs_undelfs_ops->fstat = undelfs_fstat; + vfs_undelfs_ops->chdir = undelfs_chdir; + vfs_undelfs_ops->lseek = undelfs_lseek; + vfs_undelfs_ops->getid = undelfs_getid; + vfs_undelfs_ops->nothingisopen = undelfs_nothingisopen; + vfs_undelfs_ops->free = undelfs_free; + vfs_register_class (vfs_undelfs_ops); } /* --------------------------------------------------------------------------------------------- */ diff --git a/tests/lib/vfs/current_dir.c b/tests/lib/vfs/current_dir.c index b2813335d..0bc4192d8 100644 --- a/tests/lib/vfs/current_dir.c +++ b/tests/lib/vfs/current_dir.c @@ -27,13 +27,16 @@ #include "tests/mctest.h" +#include /* memset() */ + #include "lib/global.h" #include "lib/strutil.h" #include "lib/vfs/xdirentry.h" #include "src/vfs/local/local.c" -static struct vfs_class vfs_test_ops; +static struct vfs_s_subclass vfs_test_subclass; +static struct vfs_class *vfs_test_ops = VFS_CLASS (&vfs_test_subclass); /* --------------------------------------------------------------------------------------------- */ @@ -58,8 +61,9 @@ setup (void) init_localfs (); vfs_setup_work_dir (); - vfs_init_class (&vfs_test_ops, "testfs", VFS_UNKNOWN, "test"); - vfs_test_ops.chdir = test_chdir; + memset (&vfs_test_subclass, 0, sizeof (vfs_test_subclass)); + vfs_init_class (vfs_test_ops, "testfs", VFS_UNKNOWN, "test"); + vfs_test_ops->chdir = test_chdir; } /* --------------------------------------------------------------------------------------------- */ @@ -150,8 +154,8 @@ START_PARAMETRIZED_TEST (test_cd, test_cd_ds) /* given */ vfs_path_t *vpath; - vfs_test_ops.flags = data->input_class_flags; - vfs_register_class (&vfs_test_ops); + vfs_test_ops->flags = data->input_class_flags; + vfs_register_class (vfs_test_ops); vfs_set_raw_current_dir (vfs_path_from_str (data->input_initial_path)); @@ -170,7 +174,7 @@ START_PARAMETRIZED_TEST (test_cd, test_cd_ds) } vfs_path_free (vpath); - vfs_unregister_class (&vfs_test_ops); + vfs_unregister_class (vfs_test_ops); } /* *INDENT-OFF* */ END_PARAMETRIZED_TEST diff --git a/tests/lib/vfs/relative_cd.c b/tests/lib/vfs/relative_cd.c index 417cb0a29..2d140a10f 100644 --- a/tests/lib/vfs/relative_cd.c +++ b/tests/lib/vfs/relative_cd.c @@ -26,6 +26,8 @@ #include "tests/mctest.h" +#include /* memset() */ + #include "lib/strutil.h" #include "lib/vfs/xdirentry.h" #include "lib/vfs/path.h" @@ -33,7 +35,8 @@ #include "src/vfs/local/local.c" -static struct vfs_class vfs_test_ops1; +static struct vfs_s_subclass vfs_test_subclass1; +static struct vfs_class *vfs_test_ops1 = VFS_CLASS (&vfs_test_subclass1); static int test_chdir (const vfs_path_t * vpath); @@ -76,13 +79,14 @@ setup (void) init_localfs (); vfs_setup_work_dir (); - vfs_init_class (&vfs_test_ops1, "testfs1", VFS_NOLINKS | VFS_REMOTE, "test1"); - vfs_test_ops1.chdir = test_chdir; - vfs_register_class (&vfs_test_ops1); + memset (&vfs_test_subclass1, 0, sizeof (vfs_test_subclass1)); + vfs_init_class (vfs_test_ops1, "testfs1", VFS_NOLINKS | VFS_REMOTE, "test1"); + vfs_test_ops1->chdir = test_chdir; + vfs_register_class (vfs_test_ops1); mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR; - vfs_local_ops.chdir = test_chdir; + vfs_local_ops->chdir = test_chdir; test_chdir__init (); } diff --git a/tests/lib/vfs/vfs_path_string_convert.c b/tests/lib/vfs/vfs_path_string_convert.c index 266664f94..8fe1690bd 100644 --- a/tests/lib/vfs/vfs_path_string_convert.c +++ b/tests/lib/vfs/vfs_path_string_convert.c @@ -107,7 +107,7 @@ static const struct test_from_to_string_ds "/", "/", 1, - &vfs_local_ops + VFS_CLASS (&local_subclass) }, { /* 2. */ "/test1://bla-bla/some/path/test2://user:passwd@some.host:1234/bla-bla/some/path/test3://111/22/33",