From 127f97565780d050af08a57a9e7ee6c9e50d5d3d Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 13 Apr 2024 13:02:08 +0300 Subject: [PATCH] (search_content): minor refactoring of file opening. Signed-off-by: Andrew Borodin --- src/filemanager/find.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/filemanager/find.c b/src/filemanager/find.c index 7fb90e8d9..dbe23fcf0 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -1010,7 +1010,7 @@ search_content (WDialog * h, const char *directory, const char *filename) { struct stat s; char buffer[BUF_4K] = ""; /* raw input buffer */ - int file_fd; + int file_fd = -1; gboolean ret_val = FALSE; vfs_path_t *vpath; gint64 tv; @@ -1018,13 +1018,9 @@ search_content (WDialog * h, const char *directory, const char *filename) vpath = vfs_path_build_filename (directory, filename, (char *) NULL); - if (mc_stat (vpath, &s) != 0 || !S_ISREG (s.st_mode)) - { - vfs_path_free (vpath, TRUE); - return FALSE; - } + if (mc_stat (vpath, &s) == 0 && S_ISREG (s.st_mode)) + file_fd = mc_open (vpath, O_RDONLY); - file_fd = mc_open (vpath, O_RDONLY); vfs_path_free (vpath, TRUE); if (file_fd == -1)