all: use nm_close() instead of close()

This commit is contained in:
Thomas Haller
2017-11-14 14:22:21 +01:00
parent f4780f85ae
commit 5b29c2e5b9
14 changed files with 40 additions and 40 deletions

View File

@@ -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;
}

View File

@@ -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]);
}
/*****************************************************************************/

View File

@@ -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])

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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,

View File

@@ -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);