[PATCH] virsocket: Don't preserve errno in virSocketRecvFD()

Michal Privoznik posted 1 patch 2 years, 8 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/b5f196578743289d2594350061bfbb10be587298.1629449709.git.mprivozn@redhat.com
src/util/virsocket.c | 2 --
1 file changed, 2 deletions(-)
[PATCH] virsocket: Don't preserve errno in virSocketRecvFD()
Posted by Michal Privoznik 2 years, 8 months ago
When setting O_CLOEXEC flag on received FD fails the FD is closed
using VIR_FORCE_CLOSE(). But the call is wrapped in errno save
which is not necessary because VIR_FORCE_CLOSE() preservers errno
value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/util/virsocket.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/util/virsocket.c b/src/util/virsocket.c
index b971da16e3..a6f185114d 100644
--- a/src/util/virsocket.c
+++ b/src/util/virsocket.c
@@ -477,9 +477,7 @@ virSocketRecvFD(int sock, int fdflags)
     /* set close-on-exec flag */
     if (!MSG_CMSG_CLOEXEC && (fdflags & O_CLOEXEC)) {
         if (virSetCloseExec(fd) < 0) {
-            int saved_errno = errno;
             VIR_FORCE_CLOSE(fd);
-            errno = saved_errno;
             return -1;
         }
     }
-- 
2.31.1

Re: [PATCH] virsocket: Don't preserve errno in virSocketRecvFD()
Posted by Ján Tomko 2 years, 8 months ago
On a Friday in 2021, Michal Privoznik wrote:
>When setting O_CLOEXEC flag on received FD fails the FD is closed
>using VIR_FORCE_CLOSE(). But the call is wrapped in errno save
>which is not necessary because VIR_FORCE_CLOSE() preservers errno

*preserves

>value.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> src/util/virsocket.c | 2 --
> 1 file changed, 2 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano