summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-11-14 14:22:21 +0100
committerThomas Haller <thaller@redhat.com>2017-11-14 15:10:42 +0100
commit5b29c2e5b93c30347919b40e0885280fdb83c1a5 (patch)
tree5a33fd815571354552583f27a6e726f0ef4bd156
parentf4780f85ae02fa32141cd56aa759d041ed4b27cf (diff)
downloadNetworkManager-5b29c2e5b93c30347919b40e0885280fdb83c1a5.tar.gz
all: use nm_close() instead of close()
-rw-r--r--clients/cli/connections.c2
-rw-r--r--clients/cli/utils.c12
-rw-r--r--clients/tui/newt/nmt-newt-utils.c2
-rw-r--r--shared/nm-test-utils-impl.c2
-rw-r--r--shared/nm-utils/nm-random-utils.c2
-rw-r--r--src/devices/tests/test-lldp.c2
-rw-r--r--src/main-utils.c2
-rw-r--r--src/nm-core-utils.c8
-rw-r--r--src/nm-manager.c4
-rw-r--r--src/nm-sleep-monitor.c2
-rw-r--r--src/platform/nm-linux-platform.c2
-rw-r--r--src/platform/tests/test-common.c30
-rw-r--r--src/tests/config/test-config.c2
-rw-r--r--src/tests/test-general-with-expect.c8
14 files changed, 40 insertions, 40 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index c05a9e82fc..d85901e6fd 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -8605,7 +8605,7 @@ do_connection_export (NmCli *nmc, int argc, char **argv)
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
goto finish;
}
- close (fd);
+ nm_close (fd);
path = tmpfile;
}
diff --git a/clients/cli/utils.c b/clients/cli/utils.c
index 570bfb98d4..f20e24ce09 100644
--- a/clients/cli/utils.c
+++ b/clients/cli/utils.c
@@ -1504,16 +1504,16 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
nm_cli.pager_pid = fork ();
if (nm_cli.pager_pid == -1) {
g_printerr (_("Failed to fork pager: %s\n"), strerror (errno));
- close (fd[0]);
- close (fd[1]);
+ nm_close (fd[0]);
+ nm_close (fd[1]);
return;
}
/* In the child start the pager */
if (nm_cli.pager_pid == 0) {
dup2 (fd[0], STDIN_FILENO);
- close (fd[0]);
- close (fd[1]);
+ nm_close (fd[0]);
+ nm_close (fd[1]);
setenv ("LESS", "FRSXMK", 1);
setenv ("LESSCHARSET", "utf-8", 1);
@@ -1553,8 +1553,8 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
if (dup2 (fd[1], STDERR_FILENO) < 0)
g_printerr (_("Failed to duplicate pager pipe: %s\n"), strerror (errno));
- close (fd[0]);
- close (fd[1]);
+ nm_close (fd[0]);
+ nm_close (fd[1]);
}
/*****************************************************************************/
diff --git a/clients/tui/newt/nmt-newt-utils.c b/clients/tui/newt/nmt-newt-utils.c
index a8541829de..f37a851e6c 100644
--- a/clients/tui/newt/nmt-newt-utils.c
+++ b/clients/tui/newt/nmt-newt-utils.c
@@ -336,7 +336,7 @@ nmt_newt_edit_string (const char *data)
len -= nwrote;
data += nwrote;
}
- close (fd);
+ nm_close (fd);
argv[0] = (char *) g_getenv ("VISUAL");
if (!argv[0])
diff --git a/shared/nm-test-utils-impl.c b/shared/nm-test-utils-impl.c
index 6926ea3060..3eb726d91f 100644
--- a/shared/nm-test-utils-impl.c
+++ b/shared/nm-test-utils-impl.c
@@ -146,7 +146,7 @@ nmtstc_service_cleanup (NMTstcServiceInfo *info)
g_assert (i > 0);
g_object_unref (info->bus);
- close (info->keepalive_fd);
+ nm_close (info->keepalive_fd);
#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
g_clear_pointer (&info->libdbus.bus, dbus_g_connection_unref);
diff --git a/shared/nm-utils/nm-random-utils.c b/shared/nm-utils/nm-random-utils.c
index 5d9e29da89..65986b3dde 100644
--- a/shared/nm-utils/nm-random-utils.c
+++ b/shared/nm-utils/nm-random-utils.c
@@ -120,7 +120,7 @@ fd_open:
goto fd_open;
} else {
r = nm_utils_fd_read_loop_exact (fd, buf, n, TRUE);
- close (fd);
+ nm_close (fd);
if (r >= 0)
urandom_success = TRUE;
}
diff --git a/src/devices/tests/test-lldp.c b/src/devices/tests/test-lldp.c
index 1e600cdf1a..c3c4f0d2c5 100644
--- a/src/devices/tests/test-lldp.c
+++ b/src/devices/tests/test-lldp.c
@@ -366,7 +366,7 @@ _test_recv_fixture_setup (TestRecvFixture *fixture, gconstpointer user_data)
g_assert (s >= 0);
ifr.ifr_flags |= IFF_UP;
g_assert (ioctl (s, SIOCSIFFLAGS, &ifr) >= 0);
- close (s);
+ nm_close (s);
link = nmtstp_assert_wait_for_link (NM_PLATFORM_GET, TEST_IFNAME, NM_LINK_TYPE_TAP, 100);
fixture->ifindex = link->ifindex;
diff --git a/src/main-utils.c b/src/main-utils.c
index c84f1e4c16..0f79053607 100644
--- a/src/main-utils.c
+++ b/src/main-utils.c
@@ -106,7 +106,7 @@ nm_main_utils_write_pidfile (const char *pidfile)
else
success = TRUE;
- if (close (fd))
+ if (nm_close (fd))
fprintf (stderr, _("Closing %s failed: %s\n"), pidfile, strerror (errno));
return success;
diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c
index a8ff351333..00a44fde58 100644
--- a/src/nm-core-utils.c
+++ b/src/nm-core-utils.c
@@ -2841,7 +2841,7 @@ nm_utils_fd_get_contents (int fd,
}
if (!(f = fdopen (fd2, "r"))) {
- close (fd2);
+ nm_close (fd2);
return _get_contents_error (error, 0, "failure during fdopen");
}
@@ -4119,7 +4119,7 @@ nm_utils_file_set_contents (const gchar *filename,
if (errsv == EINTR)
continue;
- close (fd);
+ nm_close (fd);
unlink (tmp_name);
g_set_error (error,
@@ -4148,7 +4148,7 @@ nm_utils_file_set_contents (const gchar *filename,
&& fsync (fd) != 0) {
errsv = errno;
- close (fd);
+ nm_close (fd);
unlink (tmp_name);
g_set_error (error,
@@ -4160,7 +4160,7 @@ nm_utils_file_set_contents (const gchar *filename,
return FALSE;
}
- close (fd);
+ nm_close (fd);
if (rename (tmp_name, filename)) {
errsv = errno;
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 1d51bbdfd9..06423603b7 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -5909,7 +5909,7 @@ rfkill_change (NMManager *self, const char *desc, RfKillType rtype, gboolean ena
if (fcntl (fd, F_SETFL, O_NONBLOCK) < 0) {
_LOGW (LOGD_RFKILL, "rfkill: (%s): failed to set killswitch device for "
"non-blocking operation", desc);
- close (fd);
+ nm_close (fd);
return;
}
@@ -5939,7 +5939,7 @@ rfkill_change (NMManager *self, const char *desc, RfKillType rtype, gboolean ena
_LOGW (LOGD_RFKILL, "rfkill: (%s): failed to change WiFi killswitch state", desc);
}
- close (fd);
+ nm_close (fd);
}
static void
diff --git a/src/nm-sleep-monitor.c b/src/nm-sleep-monitor.c
index 037db11b7f..7a3738748d 100644
--- a/src/nm-sleep-monitor.c
+++ b/src/nm-sleep-monitor.c
@@ -134,7 +134,7 @@ drop_inhibitor (NMSleepMonitor *self, gboolean force)
if (self->inhibit_fd >= 0) {
_LOGD ("inhibit: dropping sleep inhibitor %d", self->inhibit_fd);
- close (self->inhibit_fd);
+ nm_close (self->inhibit_fd);
self->inhibit_fd = -1;
}
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 46b7bd209e..3d319ab205 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -5644,7 +5644,7 @@ tun_add (NMPlatform *platform, const char *name, gboolean tap,
if (out_link)
*out_link = obj ? &obj->link : NULL;
- close (fd);
+ nm_close (fd);
return !!obj;
}
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c
index 1807671201..3abb8e2dc2 100644
--- a/src/platform/tests/test-common.c
+++ b/src/platform/tests/test-common.c
@@ -1703,8 +1703,8 @@ nmtstp_namespace_create (int unshare_flags, GError **error)
errsv = errno;
g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN,
"pipe() failed with %d (%s)", errsv, strerror (errsv));
- close (pipefd_c2p[0]);
- close (pipefd_c2p[1]);
+ nm_close (pipefd_c2p[0]);
+ nm_close (pipefd_c2p[1]);
return FALSE;
}
@@ -1713,18 +1713,18 @@ nmtstp_namespace_create (int unshare_flags, GError **error)
errsv = errno;
g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN,
"fork() failed with %d (%s)", errsv, strerror (errsv));
- close (pipefd_c2p[0]);
- close (pipefd_c2p[1]);
- close (pipefd_p2c[0]);
- close (pipefd_p2c[1]);
+ nm_close (pipefd_c2p[0]);
+ nm_close (pipefd_c2p[1]);
+ nm_close (pipefd_p2c[0]);
+ nm_close (pipefd_p2c[1]);
return FALSE;
}
if (pid == 0) {
char read_buf[1];
- close (pipefd_c2p[0]); /* close read-end */
- close (pipefd_p2c[1]); /* close write-end */
+ nm_close (pipefd_c2p[0]); /* close read-end */
+ nm_close (pipefd_p2c[1]); /* close write-end */
if (unshare (unshare_flags) != 0) {
errsv = errno;
@@ -1742,7 +1742,7 @@ nmtstp_namespace_create (int unshare_flags, GError **error)
if (errsv == 0)
errsv = -2;
}
- close (pipefd_c2p[1]);
+ nm_close (pipefd_c2p[1]);
/* wait until parent process terminates (or kills us). */
if (errsv == 0) {
@@ -1750,19 +1750,19 @@ nmtstp_namespace_create (int unshare_flags, GError **error)
r = read (pipefd_p2c[0], read_buf, sizeof (read_buf));
} while (r < 0 && errno == EINTR);
}
- close (pipefd_p2c[0]);
+ nm_close (pipefd_p2c[0]);
_exit (0);
}
- close (pipefd_c2p[1]); /* close write-end */
- close (pipefd_p2c[0]); /* close read-end */
+ nm_close (pipefd_c2p[1]); /* close write-end */
+ nm_close (pipefd_p2c[0]); /* close read-end */
/* sync with child process. */
do {
r = read (pipefd_c2p[0], &errsv, sizeof (errsv));
} while (r < 0 && errno == EINTR);
- close (pipefd_c2p[0]);
+ nm_close (pipefd_c2p[0]);
if ( r != sizeof (errsv)
|| errsv != 0) {
@@ -1775,7 +1775,7 @@ nmtstp_namespace_create (int unshare_flags, GError **error)
g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN,
"child process signaled failure %d (%s)", errsv, strerror (errsv));
}
- close (pipefd_p2c[1]);
+ nm_close (pipefd_p2c[1]);
kill (pid, SIGKILL);
do {
pid2 = waitpid (pid, &status, 0);
@@ -1809,7 +1809,7 @@ nmtstp_namespace_handle_release (NMTstpNamespaceHandle *ns_handle)
g_return_if_fail (ns_handle->pid > 0);
- close (ns_handle->pipe_fd);
+ nm_close (ns_handle->pipe_fd);
ns_handle->pipe_fd = 0;
kill (ns_handle->pid, SIGKILL);
diff --git a/src/tests/config/test-config.c b/src/tests/config/test-config.c
index 2067f40faa..89b22a9f68 100644
--- a/src/tests/config/test-config.c
+++ b/src/tests/config/test-config.c
@@ -370,7 +370,7 @@ test_config_no_auto_default (void)
g_assert_cmpint (nwrote, ==, 18);
nwrote = write (fd, "44:44:44:44:44:44\n", 18);
g_assert_cmpint (nwrote, ==, 18);
- close (fd);
+ nm_close (fd);
config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "",
"--no-auto-default", state_file,
diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c
index c5d26163fe..2911d84d6e 100644
--- a/src/tests/test-general-with-expect.c
+++ b/src/tests/test-general-with-expect.c
@@ -184,7 +184,7 @@ test_nm_utils_kill_child_create_and_join_pgroup (void)
if (pgid == 0) {
/* child process... */
- close (pipefd[0]);
+ nm_close (pipefd[0]);
err = setpgid (0, 0);
g_assert (err == 0);
@@ -192,16 +192,16 @@ test_nm_utils_kill_child_create_and_join_pgroup (void)
err = write (pipefd[1], &tmp, sizeof (tmp));
g_assert (err == sizeof (tmp));
- close (pipefd[1]);
+ nm_close (pipefd[1]);
exit (0);
}
- close (pipefd[1]);
+ nm_close (pipefd[1]);
err = read (pipefd[0], &tmp, sizeof (tmp));
g_assert (err == sizeof (tmp));
- close (pipefd[0]);
+ nm_close (pipefd[0]);
err = setpgid (0, pgid);
g_assert (err == 0);