]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix some `unwind-protect' forms
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 3 Apr 2023 11:18:55 +0000 (13:18 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 3 Apr 2023 11:18:55 +0000 (13:18 +0200)
* lisp/net/tramp-smb.el (tramp-smb-handle-file-acl)
(tramp-smb-handle-set-file-acl): Remove superfluous `unwind-protect'.

* test/lisp/auth-source-tests.el
(auth-source-test-secrets-create-secret): Fix `unwind-protect' handler.

* test/lisp/net/tramp-tests.el (tramp-test38-find-backup-file-name):
Add dummy cleanup form.

lisp/net/tramp-smb.el
test/lisp/auth-source-tests.el
test/lisp/net/tramp-tests.el

index add230e2720a8011bfc7cf8b84906a1d4642299e..13d5e17a9ff25c29fc60f104d5de46d6089293d9 100644 (file)
@@ -800,32 +800,31 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
             (append args (list (tramp-unquote-shell-quote-argument localname)
                                (concat "2>" (tramp-get-remote-null-device v)))))
 
-           (unwind-protect
-               (with-tramp-saved-connection-properties
-                   v '("process-name" "process-buffer")
-                 (with-temp-buffer
-                   ;; Set the transfer process properties.
-                   (tramp-set-connection-property
-                    v "process-name" (buffer-name (current-buffer)))
-                   (tramp-set-connection-property
-                    v "process-buffer" (current-buffer))
-
-                   ;; Use an asynchronous process.  By this, password
-                   ;; can be handled.
-                   (let ((p (apply
-                             #'start-process
-                             (tramp-get-connection-name v)
-                             (tramp-get-connection-buffer v)
-                             tramp-smb-acl-program args)))
-
-                     (tramp-message
-                      v 6 "%s" (string-join (process-command p) " "))
-                     (process-put p 'tramp-vector v)
-                     (process-put p 'adjust-window-size-function #'ignore)
-                     (set-process-query-on-exit-flag p nil)
-                     (tramp-process-actions p v nil tramp-smb-actions-get-acl)
-                     (when (> (point-max) (point-min))
-                       (substring-no-properties (buffer-string)))))))))))))
+           (with-tramp-saved-connection-properties
+               v '("process-name" "process-buffer")
+             (with-temp-buffer
+               ;; Set the transfer process properties.
+               (tramp-set-connection-property
+                v "process-name" (buffer-name (current-buffer)))
+               (tramp-set-connection-property
+                v "process-buffer" (current-buffer))
+
+               ;; Use an asynchronous process.  By this, password
+               ;; can be handled.
+               (let ((p (apply
+                         #'start-process
+                         (tramp-get-connection-name v)
+                         (tramp-get-connection-buffer v)
+                         tramp-smb-acl-program args)))
+
+                 (tramp-message
+                  v 6 "%s" (string-join (process-command p) " "))
+                 (process-put p 'tramp-vector v)
+                 (process-put p 'adjust-window-size-function #'ignore)
+                 (set-process-query-on-exit-flag p nil)
+                 (tramp-process-actions p v nil tramp-smb-actions-get-acl)
+                 (when (> (point-max) (point-min))
+                   (substring-no-properties (buffer-string))))))))))))
 
 (defun tramp-smb-handle-file-attributes (filename &optional id-format)
   "Like `file-attributes' for Tramp files."
@@ -1401,44 +1400,43 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
                              "&&" "echo" "tramp_exit_status" "0"
                              "||" "echo" "tramp_exit_status" "1")))
 
-         (unwind-protect
-             (with-tramp-saved-connection-properties
-                 v '("process-name" "process-buffer")
-               (with-temp-buffer
-                 ;; Set the transfer process properties.
-                 (tramp-set-connection-property
-                  v "process-name" (buffer-name (current-buffer)))
-                 (tramp-set-connection-property
-                  v "process-buffer" (current-buffer))
-
-                 ;; Use an asynchronous process.  By this, password
-                 ;; can be handled.
-                 (let ((p (apply
-                           #'start-process
-                           (tramp-get-connection-name v)
-                           (tramp-get-connection-buffer v)
-                           tramp-smb-acl-program args)))
-
-                   (tramp-message
-                    v 6 "%s" (string-join (process-command p) " "))
-                   (process-put p 'tramp-vector v)
-                   (process-put p 'adjust-window-size-function #'ignore)
-                   (set-process-query-on-exit-flag p nil)
-                   (tramp-process-actions p v nil tramp-smb-actions-set-acl)
-                   ;; This is meant for traces, and returning from
-                   ;; the function.  No error is propagated outside,
-                   ;; due to the `ignore-errors' closure.
-                   (unless
-                       (tramp-search-regexp (rx "tramp_exit_status " (+ digit)))
-                     (tramp-error
-                      v 'file-error
-                      "Couldn't find exit status of `%s'"
-                      tramp-smb-acl-program))
-                   (skip-chars-forward "^ ")
-                   (when (zerop (read (current-buffer)))
-                     ;; Success.
-                     (tramp-set-file-property v localname "file-acl" acl-string)
-                     t))))))))))
+         (with-tramp-saved-connection-properties
+             v '("process-name" "process-buffer")
+           (with-temp-buffer
+             ;; Set the transfer process properties.
+             (tramp-set-connection-property
+              v "process-name" (buffer-name (current-buffer)))
+             (tramp-set-connection-property
+              v "process-buffer" (current-buffer))
+
+             ;; Use an asynchronous process.  By this, password
+             ;; can be handled.
+             (let ((p (apply
+                       #'start-process
+                       (tramp-get-connection-name v)
+                       (tramp-get-connection-buffer v)
+                       tramp-smb-acl-program args)))
+
+               (tramp-message
+                v 6 "%s" (string-join (process-command p) " "))
+               (process-put p 'tramp-vector v)
+               (process-put p 'adjust-window-size-function #'ignore)
+               (set-process-query-on-exit-flag p nil)
+               (tramp-process-actions p v nil tramp-smb-actions-set-acl)
+               ;; This is meant for traces, and returning from
+               ;; the function.  No error is propagated outside,
+               ;; due to the `ignore-errors' closure.
+               (unless
+                   (tramp-search-regexp (rx "tramp_exit_status " (+ digit)))
+                 (tramp-error
+                  v 'file-error
+                  "Couldn't find exit status of `%s'"
+                  tramp-smb-acl-program))
+               (skip-chars-forward "^ ")
+               (when (zerop (read (current-buffer)))
+                 ;; Success.
+                 (tramp-set-file-property v localname "file-acl" acl-string)
+                 t)))))))))
 
 (defun tramp-smb-handle-set-file-modes (filename mode &optional flag)
   "Like `set-file-modes' for Tramp files."
index 6f832725754e8f220ef698e9f11af8b3908dc6c1..ef915e5fc5b3911e91c4496e365871dcd792a8fc 100644 (file)
               (should
                (string-equal (plist-get auth-info :user) (user-login-name)))
               (should (string-equal (plist-get auth-info :host) host))
-              (should (string-equal auth-passwd passwd)))))
-
-      ;; Cleanup.
-      ;; Should use `auth-source-delete' when implemented for :secrets backend.
-      (secrets-delete-item
-       "session"
-       (format "%s@%s" (plist-get auth-info :user) (plist-get auth-info :host))))))
+              (should (string-equal auth-passwd passwd))))
+
+        ;; Cleanup.
+        ;; Should use `auth-source-delete' when implemented for :secrets backend.
+        (secrets-delete-item
+         "session"
+         (format
+          "%s@%s" (plist-get auth-info :user) (plist-get auth-info :host)))))))
 
 (ert-deftest auth-source-test-netrc-create-secret ()
   (ert-with-temp-file netrc-file
index 835763e02377b05d3ee9b9f68e64fc2908a7bf7f..9910aca6a7051e49c843fe8e92b27d27f5a94da2 100644 (file)
@@ -6414,7 +6414,10 @@ INPUT, if non-nil, is a string sent to the process."
                (if quoted #'file-name-quote #'identity)
                (expand-file-name
                 (format "%s~" (file-name-nondirectory tmp-name1))
-                ert-remote-temporary-file-directory)))))))
+                ert-remote-temporary-file-directory))))))
+
+       ;; Cleanup.
+       (ignore-errors))
 
       (unwind-protect
          ;; Map `backup-directory-alist'.