Skip to content
Snippets Groups Projects
Commit 69d8a597 authored by Alexander Larsson's avatar Alexander Larsson
Browse files

Don't touch errno in glnx_fd_close

We're ignoring the result from the close, but it can still affect
errno, which is bad if you use this in functions that sets
errno, because errno can unexpectedly change after you've set it.
parent 08ae6639
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@
#pragma once
#include <gio/gio.h>
#include <errno.h>
G_BEGIN_DECLS
......@@ -195,13 +196,17 @@ GLNX_DEFINE_CLEANUP_FUNCTION0(GKeyFile*, glnx_local_keyfile_unref, g_key_file_un
static inline void
glnx_cleanup_close_fdp (int *fdp)
{
int fd;
int fd, errsv;
g_assert (fdp);
fd = *fdp;
if (fd != -1)
(void) close (fd);
{
errsv = errno;
(void) close (fd);
errno = errsv;
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment