Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit 5f1e01b

Browse files
committed
(main): clarify last wd saving, join assignment and declaration, constify
Signed-off-by: Yury V. Zaytsev <[email protected]>
1 parent e5020d1 commit 5f1e01b

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

src/filemanager/filemanager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ do_nc (void)
18311831

18321832
// widget_destroy destroys even current_panel->cwd_vpath, so we have to save a copy :)
18331833
if (mc_args__last_wd_file != NULL && vfs_current_is_local ())
1834-
last_wd_string = g_strdup (vfs_path_as_str (current_panel->cwd_vpath));
1834+
last_wd_str = g_strdup (vfs_path_as_str (current_panel->cwd_vpath));
18351835

18361836
// don't handle VFS timestamps for dirs opened in panels
18371837
mc_event_destroy (MCEVENT_GROUP_CORE, "vfs_timestamp");

src/main.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -498,23 +498,19 @@ main (int argc, char *argv[])
498498
if (mc_global.tty.console_flag != '\0')
499499
handle_console (CONSOLE_DONE);
500500

501-
if (mc_global.mc_run_mode == MC_RUN_FULL && mc_args__last_wd_file != NULL
502-
&& last_wd_string != NULL && !print_last_revert)
501+
if (mc_global.mc_run_mode == MC_RUN_FULL && mc_args__last_wd_file != NULL && last_wd_str != NULL
502+
&& !print_last_revert)
503503
{
504-
int last_wd_fd;
505-
506-
last_wd_fd = open (mc_args__last_wd_file, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
504+
const int last_wd_fd =
505+
open (mc_args__last_wd_file, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
507506
if (last_wd_fd != -1)
508507
{
509-
ssize_t ret1;
510-
int ret2;
511-
ret1 = write (last_wd_fd, last_wd_string, strlen (last_wd_string));
512-
ret2 = close (last_wd_fd);
513-
(void) ret1;
514-
(void) ret2;
508+
MC_UNUSED const ssize_t ret1 = write (last_wd_fd, last_wd_str, strlen (last_wd_str));
509+
MC_UNUSED const int ret2 = close (last_wd_fd);
515510
}
516511
}
517-
g_free (last_wd_string);
512+
513+
g_free (last_wd_str);
518514

519515
mc_shell_deinit ();
520516

src/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ char *spell_language = NULL;
196196
char *saved_other_dir = NULL;
197197

198198
/* If set, then print to the given file the last directory we were at */
199-
char *last_wd_string = NULL;
199+
char *last_wd_str = NULL;
200200

201201
/* Set when main loop should be terminated */
202202
int quit = 0;

src/setup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ extern char *spell_language;
125125
extern char *saved_other_dir;
126126

127127
/* If set, then print to the given file the last directory we were at */
128-
extern char *last_wd_string;
128+
extern char *last_wd_str;
129129

130130
extern int quit;
131131
/* Set to TRUE to suppress printing the last directory */

0 commit comments

Comments
 (0)