]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
printing: Simplify file_version_is_newer()
authorVolker Lendecke <vl@samba.org>
Sun, 4 Jan 2026 10:31:17 +0000 (11:31 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 20 Jan 2026 11:53:34 +0000 (11:53 +0000)
We don't need to call fstat(), driver_unix_convert() already does it
via filename_convert_dirfsp().

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/printing/nt_printing.c

index 89f31a60406c97cdea87970162c4dec0f3f9660d..9f7c3e6ac7f4b7bfa953a54f56b8aa40751f3a68 100644 (file)
@@ -823,6 +823,8 @@ static int file_version_is_newer(connection_struct *conn,
                goto error_exit;
        }
 
+       old_stat = smb_fname->st;
+
        status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */
                NULL,                                   /* req */
@@ -860,16 +862,12 @@ static int file_version_is_newer(connection_struct *conn,
 
        if (!ret) {
                struct timeval_buf buf;
-               DBG_NOTICE("Version info not found [%s], use mod time\n",
-                          old_file);
-               use_version = false;
-               if (SMB_VFS_FSTAT(fsp, &old_stat) == -1) {
-                       goto error_exit;
-               }
-               DBG_NOTICE("mod time = %s\n",
+               DBG_NOTICE("Version info not found [%s], use mod time = %s\n",
+                          old_file,
                           timespec_string_buf(&old_stat.st_ex_mtime,
                                               true,
                                               &buf));
+               use_version = false;
        }
 
        close_file_free(NULL, &fsp, NORMAL_CLOSE);
@@ -880,6 +878,8 @@ static int file_version_is_newer(connection_struct *conn,
                goto error_exit;
        }
 
+       new_stat = smb_fname->st;
+
        status = SMB_VFS_CREATE_FILE(
                conn,                                   /* conn */
                NULL,                                   /* req */
@@ -916,16 +916,12 @@ static int file_version_is_newer(connection_struct *conn,
 
        if (!ret) {
                struct timeval_buf buf;
-               DBG_INFO("Version info not found [%s], use mod time\n",
-                        new_file);
+               DBG_INFO("Version info not found [%s], use mod time = %s\n",
+                        new_file,
+                        timespec_string_buf(&new_stat.st_ex_mtime,
+                                            true,
+                                            &buf));
                use_version = false;
-               if (SMB_VFS_FSTAT(fsp, &new_stat) == -1) {
-                       goto error_exit;
-               }
-               DBG_NOTICE("mod time = %s\n",
-                          timespec_string_buf(&new_stat.st_ex_mtime,
-                                              true,
-                                              &buf));
        }
 
        close_file_free(NULL, &fsp, NORMAL_CLOSE);