xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 7bca47e521ffcb1d12f97bea12e10e5bb3684c6c

Handle `cfg.slow_fs_list == NULL` in code
This simplifies some tests and avoids initializing this data in places
which don't deal with application's configuration in any way.
Author: xaizek
Author date (UTC): 2026-02-14 13:57
Committer name: xaizek
Committer date (UTC): 2026-02-19 09:45
Parent(s): c56d8e380c3a19fc85863e65e6c966abe7bcc105
Signing key: 99DC5E4DB05F6BE2
Tree: cf8849641391bcd86163cae2b3d7f758e789ace4
File Lines added Lines deleted
src/utils/utils_nix.c 14 6
tests/commands/autocmds.c 0 4
tests/commands/completion.c 0 4
tests/commands/sync.c 0 6
tests/fileops/suite.c 0 2
tests/ior/suite.c 0 2
tests/misc/chase_links.c 0 3
tests/misc/filtering.c 0 2
tests/misc/flist_custom.c 0 2
tests/misc/flist_hist.c 0 4
tests/misc/flist_reload.c 0 4
tests/misc/fuse.c 0 2
tests/misc/integration.c 0 2
tests/misc/marks.c 0 5
tests/misc/navigation.c 0 2
tests/misc/running.c 0 2
tests/misc/sort.c 0 5
File src/utils/utils_nix.c changed (mode: 100644) (index 3ac157519..e540b4bc2)
... ... get_perm_string(char buf[], int len, mode_t mode)
464 464 int int
465 465 refers_to_slower_fs(const char from[], const char to[]) refers_to_slower_fs(const char from[], const char to[])
466 466 { {
467 /* At least some tests don't need to know anything about this being
468 * configurable and yet this code gets run from tests. Bail out if the value
469 * isn't set, this is a well-defined behaviour anyway. */
470 if(is_null_or_empty(cfg.slow_fs_list))
471 {
472 return 0;
473 }
474
467 475 const int i = find_path_prefix_index(to, cfg.slow_fs_list); const int i = find_path_prefix_index(to, cfg.slow_fs_list);
468 476 /* When destination is not on slow file system, no performance penalties are /* When destination is not on slow file system, no performance penalties are
469 477 * expected. */ * expected. */
 
... ... refers_to_slower_fs(const char from[], const char to[])
479 487 int int
480 488 is_on_slow_fs(const char full_path[], const char slowfs_specs[]) is_on_slow_fs(const char full_path[], const char slowfs_specs[])
481 489 { {
490 /* Empty list optimization and bail out for some tests. */
491 if(is_null_or_empty(slowfs_specs))
492 {
493 return 0;
494 }
495
482 496 char fs_name[PATH_MAX + 1]; char fs_name[PATH_MAX + 1];
483 497 get_mount_point_traverser_state state = { get_mount_point_traverser_state state = {
484 498 .type = MI_FS_TYPE, .type = MI_FS_TYPE,
 
... ... is_on_slow_fs(const char full_path[], const char slowfs_specs[])
488 502 .curr_len = 0UL, .curr_len = 0UL,
489 503 }; };
490 504
491 /* Empty list optimization. */
492 if(slowfs_specs[0] == '\0')
493 {
494 return 0;
495 }
496
497 505 /* If slowfs equals "*" then all file systems are considered slow. On cygwin /* If slowfs equals "*" then all file systems are considered slow. On cygwin
498 506 * obtaining list of mounts from /etc/mtab, which is linked to /proc/mounts, * obtaining list of mounts from /etc/mtab, which is linked to /proc/mounts,
499 507 * is very slow in presence of network drives. */ * is very slow in presence of network drives. */
File tests/commands/autocmds.c changed (mode: 100644) (index 8510ace8a..a79e2d5af)
... ... SETUP()
39 39 curr_view = &lwin; curr_view = &lwin;
40 40 other_view = &rwin; other_view = &rwin;
41 41
42 update_string(&cfg.slow_fs_list, "");
43
44 42 cmds_init(); cmds_init();
45 43 opt_handlers_setup(); opt_handlers_setup();
46 44
 
... ... TEARDOWN()
55 53
56 54 opt_handlers_teardown(); opt_handlers_teardown();
57 55
58 update_string(&cfg.slow_fs_list, NULL);
59
60 56 vle_aucmd_remove(NULL, NULL); vle_aucmd_remove(NULL, NULL);
61 57 } }
62 58
File tests/commands/completion.c changed (mode: 100644) (index eb06c4dc3..39d7f04c6)
... ... SETUP()
80 80 static int option_changed; static int option_changed;
81 81 optval_t def = { .str_val = "/tmp" }; optval_t def = { .str_val = "/tmp" };
82 82
83 cfg.slow_fs_list = strdup("");
84
85 83 init_builtin_functions(); init_builtin_functions();
86 84
87 85 stats.line = wcsdup(L"set "); stats.line = wcsdup(L"set ");
 
... ... TEARDOWN()
121 119
122 120 restore_cwd(saved_cwd); restore_cwd(saved_cwd);
123 121
124 update_string(&cfg.slow_fs_list, NULL);
125
126 122 free(stats.line); free(stats.line);
127 123 vle_opts_reset(); vle_opts_reset();
128 124
File tests/commands/sync.c changed (mode: 100644) (index 399e70a88..9254a99d7)
11 11
12 12 #include "../../src/compat/fs_limits.h" #include "../../src/compat/fs_limits.h"
13 13 #include "../../src/compat/os.h" #include "../../src/compat/os.h"
14 #include "../../src/cfg/config.h"
15 14 #include "../../src/ui/column_view.h" #include "../../src/ui/column_view.h"
16 15 #include "../../src/utils/fs.h" #include "../../src/utils/fs.h"
17 16 #include "../../src/utils/path.h" #include "../../src/utils/path.h"
 
... ... SETUP()
31 30
32 31 cmds_init(); cmds_init();
33 32
34 cfg.slow_fs_list = strdup("");
35
36 33 view_setup(&lwin); view_setup(&lwin);
37 34 view_setup(&rwin); view_setup(&rwin);
38 35
 
... ... TEARDOWN()
48 45
49 46 vle_cmds_reset(); vle_cmds_reset();
50 47
51 free(cfg.slow_fs_list);
52 cfg.slow_fs_list = NULL;
53
54 48 view_teardown(&lwin); view_teardown(&lwin);
55 49 view_teardown(&rwin); view_teardown(&rwin);
56 50 } }
File tests/fileops/suite.c changed (mode: 100644) (index b3ff0ab85..7685ec6a0)
... ... SETUP()
36 36 init_undo_list_for_tests(&exec_func, &undo_levels); init_undo_list_for_tests(&exec_func, &undo_levels);
37 37
38 38 cfg.use_system_calls = 1; cfg.use_system_calls = 1;
39 cfg.slow_fs_list = strdup("");
40 39 cfg.delete_prg = strdup(""); cfg.delete_prg = strdup("");
41 40
42 41 #ifndef _WIN32 #ifndef _WIN32
 
... ... SETUP()
58 57
59 58 TEARDOWN() TEARDOWN()
60 59 { {
61 free(cfg.slow_fs_list);
62 60 free(cfg.delete_prg); free(cfg.delete_prg);
63 61 free(cfg.shell); free(cfg.shell);
64 62 free(cfg.shell_cmd_flag); free(cfg.shell_cmd_flag);
File tests/ior/suite.c changed (mode: 100644) (index 2ef32e68b..f78a2e5cf)
... ... SETUP()
11 11 { {
12 12 cfg.shell = strdup("/bin/bash"); cfg.shell = strdup("/bin/bash");
13 13 cfg.shell_cmd_flag = strdup("-c"); cfg.shell_cmd_flag = strdup("-c");
14 cfg.slow_fs_list = strdup("");
15 14 } }
16 15
17 16 TEARDOWN() TEARDOWN()
18 17 { {
19 18 free(cfg.shell_cmd_flag); free(cfg.shell_cmd_flag);
20 19 free(cfg.shell); free(cfg.shell);
21 free(cfg.slow_fs_list);
22 20 } }
23 21
24 22 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
File tests/misc/chase_links.c changed (mode: 100644) (index 50040acb0..f919e44f3)
... ... SETUP()
32 32
33 33 cmds_init(); cmds_init();
34 34
35 cfg.slow_fs_list = strdup("");
36 35 cfg.chase_links = 1; cfg.chase_links = 1;
37 36
38 37 init_view(&lwin); init_view(&lwin);
 
... ... TEARDOWN()
43 42 { {
44 43 vle_cmds_reset(); vle_cmds_reset();
45 44
46 update_string(&cfg.slow_fs_list, NULL);
47
48 45 cfg.chase_links = 0; cfg.chase_links = 0;
49 46
50 47 free_view(&lwin); free_view(&lwin);
File tests/misc/filtering.c changed (mode: 100644) (index d767f9adb..a653d6d6e)
... ... SETUP_ONCE()
40 40 SETUP() SETUP()
41 41 { {
42 42 update_string(&cfg.fuse_home, "no"); update_string(&cfg.fuse_home, "no");
43 update_string(&cfg.slow_fs_list, "");
44 43
45 44 cfg.filter_inverted_by_default = 1; cfg.filter_inverted_by_default = 1;
46 45
 
... ... SETUP()
74 73
75 74 TEARDOWN() TEARDOWN()
76 75 { {
77 update_string(&cfg.slow_fs_list, NULL);
78 76 update_string(&cfg.fuse_home, NULL); update_string(&cfg.fuse_home, NULL);
79 77
80 78 view_teardown(&lwin); view_teardown(&lwin);
File tests/misc/flist_custom.c changed (mode: 100644) (index 0cea89be6..ab1aa67fd)
... ... SETUP_ONCE()
52 52 SETUP() SETUP()
53 53 { {
54 54 update_string(&cfg.fuse_home, "no"); update_string(&cfg.fuse_home, "no");
55 update_string(&cfg.slow_fs_list, "");
56 55
57 56 /* So that nothing is written into directory history. */ /* So that nothing is written into directory history. */
58 57 rwin.list_rows = 0; rwin.list_rows = 0;
 
... ... SETUP()
69 68
70 69 TEARDOWN() TEARDOWN()
71 70 { {
72 update_string(&cfg.slow_fs_list, NULL);
73 71 update_string(&cfg.fuse_home, NULL); update_string(&cfg.fuse_home, NULL);
74 72
75 73 view_teardown(&lwin); view_teardown(&lwin);
File tests/misc/flist_hist.c changed (mode: 100644) (index 5dea3749e..9f54c0371)
27 27
28 28 SETUP() SETUP()
29 29 { {
30 update_string(&cfg.slow_fs_list, "");
31
32 30 view_setup(&lwin); view_setup(&lwin);
33 31 strcpy(lwin.curr_dir, "/lwin"); strcpy(lwin.curr_dir, "/lwin");
34 32 append_view_entry(&lwin, "lfile0"); append_view_entry(&lwin, "lfile0");
 
... ... SETUP()
42 40
43 41 TEARDOWN() TEARDOWN()
44 42 { {
45 update_string(&cfg.slow_fs_list, NULL);
46
47 43 cfg_resize_histories(0); cfg_resize_histories(0);
48 44
49 45 view_teardown(&lwin); view_teardown(&lwin);
File tests/misc/flist_reload.c changed (mode: 100644) (index 01feddba0..42606e565)
... ... SETUP()
21 21
22 22 assert_success(chdir(SANDBOX_PATH)); assert_success(chdir(SANDBOX_PATH));
23 23
24 update_string(&cfg.slow_fs_list, "");
25
26 24 assert_true(get_cwd(cwd, sizeof(cwd)) == cwd); assert_true(get_cwd(cwd, sizeof(cwd)) == cwd);
27 25
28 26 view_setup(view); view_setup(view);
 
... ... TEARDOWN()
44 42 (void)rmdir("1"); (void)rmdir("1");
45 43 (void)rmdir("2"); (void)rmdir("2");
46 44 (void)rmdir("3"); (void)rmdir("3");
47
48 update_string(&cfg.slow_fs_list, NULL);
49 45 } }
50 46
51 47 TEST(exact_match_is_preferred) TEST(exact_match_is_preferred)
File tests/misc/fuse.c changed (mode: 100644) (index 4cb093585..85027cf2a)
... ... SETUP()
50 50
51 51 replace_string(&cfg.fuse_home, fuse_home); replace_string(&cfg.fuse_home, fuse_home);
52 52 replace_string(&cfg.shell, "/bin/sh"); replace_string(&cfg.shell, "/bin/sh");
53 replace_string(&cfg.slow_fs_list, "");
54 53 curr_stats.fuse_umount_cmd = "true"; curr_stats.fuse_umount_cmd = "true";
55 54
56 55 saved_cwd = save_cwd(); saved_cwd = save_cwd();
 
... ... TEARDOWN()
66 65
67 66 update_string(&cfg.fuse_home, NULL); update_string(&cfg.fuse_home, NULL);
68 67 update_string(&cfg.shell, NULL); update_string(&cfg.shell, NULL);
69 update_string(&cfg.slow_fs_list, NULL);
70 68 curr_stats.fuse_umount_cmd = NULL; curr_stats.fuse_umount_cmd = NULL;
71 69
72 70 restore_cwd(saved_cwd); restore_cwd(saved_cwd);
File tests/misc/integration.c changed (mode: 100644) (index 0d36d264b..192696f26)
... ... static int bad_editor_call(const char type[], const char title[],
32 32 SETUP() SETUP()
33 33 { {
34 34 update_string(&cfg.shell, ""); update_string(&cfg.shell, "");
35 update_string(&cfg.slow_fs_list, "");
36 35 assert_success(stats_init(&cfg)); assert_success(stats_init(&cfg));
37 36 } }
38 37
39 38 TEARDOWN() TEARDOWN()
40 39 { {
41 40 update_string(&cfg.shell, NULL); update_string(&cfg.shell, NULL);
42 update_string(&cfg.slow_fs_list, NULL);
43 41 } }
44 42
45 43 /* Because of fmemopen(). */ /* Because of fmemopen(). */
File tests/misc/marks.c changed (mode: 100644) (index accd1a538..eac69da7b)
5 5
6 6 #include <test-utils.h> #include <test-utils.h>
7 7
8 #include "../../src/cfg/config.h"
9 8 #include "../../src/compat/os.h" #include "../../src/compat/os.h"
10 9 #include "../../src/ui/ui.h" #include "../../src/ui/ui.h"
11 10 #include "../../src/marks.h" #include "../../src/marks.h"
 
... ... static int calls;
23 22
24 23 SETUP() SETUP()
25 24 { {
26 cfg.slow_fs_list = strdup("");
27 25 lwin.list_pos = 0; lwin.list_pos = 0;
28 26 lwin.column_count = 1; lwin.column_count = 1;
29 27 rwin.list_pos = 0; rwin.list_pos = 0;
 
... ... SETUP()
34 32
35 33 TEARDOWN() TEARDOWN()
36 34 { {
37 free(cfg.slow_fs_list);
38 cfg.slow_fs_list = NULL;
39
40 35 marks_clear_all(); marks_clear_all();
41 36 } }
42 37
File tests/misc/navigation.c changed (mode: 100644) (index 887142b2a..48609813b)
... ... SETUP()
21 21 other_view = &rwin; other_view = &rwin;
22 22
23 23 cfg.fuse_home = strdup("no"); cfg.fuse_home = strdup("no");
24 cfg.slow_fs_list = strdup("");
25 24 cfg.chase_links = 1; cfg.chase_links = 1;
26 25
27 26 view_setup(&lwin); view_setup(&lwin);
 
... ... SETUP()
34 33
35 34 TEARDOWN() TEARDOWN()
36 35 { {
37 update_string(&cfg.slow_fs_list, NULL);
38 36 update_string(&cfg.fuse_home, NULL); update_string(&cfg.fuse_home, NULL);
39 37
40 38 cfg.chase_links = 0; cfg.chase_links = 0;
File tests/misc/running.c changed (mode: 100644) (index 7dca74b18..675ef5802)
... ... SETUP()
47 47 #endif #endif
48 48
49 49 update_string(&cfg.vi_command, "echo"); update_string(&cfg.vi_command, "echo");
50 update_string(&cfg.slow_fs_list, "");
51 50 update_string(&cfg.fuse_home, ""); update_string(&cfg.fuse_home, "");
52 51
53 52 stats_update_shell_type(cfg.shell); stats_update_shell_type(cfg.shell);
 
... ... TEARDOWN()
76 75
77 76 ft_reset(0); ft_reset(0);
78 77 update_string(&cfg.vi_command, NULL); update_string(&cfg.vi_command, NULL);
79 update_string(&cfg.slow_fs_list, NULL);
80 78 update_string(&cfg.fuse_home, NULL); update_string(&cfg.fuse_home, NULL);
81 79 } }
82 80
File tests/misc/sort.c changed (mode: 100644) (index c01612cda..ac6f9115e)
... ... TEST(symlink_to_dir, IF(not_windows))
70 70 lwin.dir_entry[2].origin = lwin.curr_dir; lwin.dir_entry[2].origin = lwin.curr_dir;
71 71 lwin.dir_entry[2].dir_link = 1; lwin.dir_entry[2].dir_link = 1;
72 72
73 cfg.slow_fs_list = strdup("");
74
75 73 sort_view(&lwin); sort_view(&lwin);
76 74
77 free(cfg.slow_fs_list);
78 cfg.slow_fs_list = NULL;
79
80 75 assert_string_equal("self", lwin.dir_entry[0].name); assert_string_equal("self", lwin.dir_entry[0].name);
81 76
82 77 assert_int_equal(0, unlink("self")); assert_int_equal(0, unlink("self"));
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master