mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-08 00:10:15 +01:00
core: use nm_close()
Use nm_close() in the core to catch any improper use of close().
This commit is contained in:
parent
1bc1809e11
commit
d29115c138
9 changed files with 24 additions and 33 deletions
|
|
@ -227,7 +227,7 @@ br2684_assign_vcc (NMDeviceAdsl *self, NMSettingAdsl *s_adsl)
|
|||
return TRUE;
|
||||
|
||||
error:
|
||||
close (priv->brfd);
|
||||
nm_close (priv->brfd);
|
||||
priv->brfd = -1;
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -519,10 +519,8 @@ adsl_cleanup (NMDeviceAdsl *self)
|
|||
|
||||
g_signal_handlers_disconnect_by_func (nm_device_get_platform (NM_DEVICE (self)), G_CALLBACK (link_changed_cb), self);
|
||||
|
||||
if (priv->brfd >= 0) {
|
||||
close (priv->brfd);
|
||||
priv->brfd = -1;
|
||||
}
|
||||
nm_close (priv->brfd);
|
||||
priv->brfd = -1;
|
||||
|
||||
nm_clear_g_source (&priv->nas_update_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -386,11 +386,11 @@ nm_bluez5_dun_cleanup (NMBluez5DunContext *context)
|
|||
ioctl (context->rfcomm_fd, RFCOMMRELEASEDEV, &req);
|
||||
context->rfcomm_id = -1;
|
||||
}
|
||||
close (context->rfcomm_fd);
|
||||
nm_close (context->rfcomm_fd);
|
||||
context->rfcomm_fd = -1;
|
||||
}
|
||||
|
||||
close (context->rfcomm_tty_fd);
|
||||
nm_close (context->rfcomm_tty_fd);
|
||||
context->rfcomm_tty_fd = -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ dispatch_netconfig (NMDnsManager *self,
|
|||
g_free (str);
|
||||
}
|
||||
|
||||
close (fd);
|
||||
nm_close (fd);
|
||||
|
||||
/* Wait until the process exits */
|
||||
if (!nm_utils_kill_child_sync (pid, 0, LOGD_DNS, "netconfig", &status, 1000, 0)) {
|
||||
|
|
@ -1633,7 +1633,7 @@ _check_resconf_immutable (NMDnsManagerResolvConfManager rc_manager)
|
|||
if (fd != -1) {
|
||||
if (ioctl (fd, FS_IOC_GETFLAGS, &flags) != -1)
|
||||
immutable = NM_FLAGS_HAS (flags, FS_IMMUTABLE_FL);
|
||||
close (fd);
|
||||
nm_close (fd);
|
||||
}
|
||||
return immutable ? NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE : rc_manager;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3019,7 +3019,7 @@ sysctl_set (NMPlatform *platform, const char *pathid, int dirfd, const char *pat
|
|||
}
|
||||
|
||||
if (nwrote < len - 1) {
|
||||
if (close (fd) != 0) {
|
||||
if (nm_close (fd) != 0) {
|
||||
if (errsv != 0)
|
||||
errno = errsv;
|
||||
} else if (errsv != 0)
|
||||
|
|
@ -3028,7 +3028,7 @@ sysctl_set (NMPlatform *platform, const char *pathid, int dirfd, const char *pat
|
|||
errno = EIO;
|
||||
return FALSE;
|
||||
}
|
||||
if (close (fd) != 0) {
|
||||
if (nm_close (fd) != 0) {
|
||||
/* errno is already properly set. */
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -5601,26 +5601,26 @@ tun_add (NMPlatform *platform, const char *name, gboolean tap,
|
|||
ifr.ifr_flags |= NM_IFF_MULTI_QUEUE;
|
||||
|
||||
if (ioctl (fd, TUNSETIFF, &ifr)) {
|
||||
close (fd);
|
||||
nm_close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (owner >= 0 && owner < G_MAXINT32) {
|
||||
if (ioctl (fd, TUNSETOWNER, (uid_t) owner)) {
|
||||
close (fd);
|
||||
nm_close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (group >= 0 && group < G_MAXINT32) {
|
||||
if (ioctl (fd, TUNSETGROUP, (gid_t) group)) {
|
||||
close (fd);
|
||||
nm_close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (ioctl (fd, TUNSETPERSIST, 1)) {
|
||||
close (fd);
|
||||
nm_close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
do_request_link (platform, 0, name);
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ _netns_new (GError **error)
|
|||
g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN,
|
||||
"Failed opening mntns: %s",
|
||||
g_strerror (errsv));
|
||||
close (fd_net);
|
||||
nm_close (fd_net);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -620,7 +620,7 @@ nmp_netns_bind_to_path (NMPNetns *self, const char *filename, int *out_fd)
|
|||
filename, g_strerror (errsv));
|
||||
return FALSE;
|
||||
}
|
||||
close (fd);
|
||||
nm_close (fd);
|
||||
|
||||
if (mount (PROC_SELF_NS_NET, filename, "none", MS_BIND, NULL) != 0) {
|
||||
errsv = errno;
|
||||
|
|
@ -702,15 +702,11 @@ dispose (GObject *object)
|
|||
NMPNetns *self = NMP_NETNS (object);
|
||||
NMPNetnsPrivate *priv = NMP_NETNS_GET_PRIVATE (self);
|
||||
|
||||
if (priv->fd_net > 0) {
|
||||
close (priv->fd_net);
|
||||
priv->fd_net = 0;
|
||||
}
|
||||
nm_close (priv->fd_net);
|
||||
priv->fd_net = -1;
|
||||
|
||||
if (priv->fd_mnt > 0) {
|
||||
close (priv->fd_mnt);
|
||||
priv->fd_mnt = 0;
|
||||
}
|
||||
nm_close (priv->fd_mnt);
|
||||
priv->fd_mnt = -1;
|
||||
|
||||
G_OBJECT_CLASS (nmp_netns_parent_class)->dispose (object);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,8 +97,7 @@ wifi_wext_deinit (WifiData *parent)
|
|||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) parent;
|
||||
|
||||
if (wext->fd >= 0)
|
||||
close (wext->fd);
|
||||
nm_close (wext->fd);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -757,7 +756,7 @@ wifi_wext_is_wifi (const char *iface)
|
|||
nm_utils_ifname_cpy (iwr.ifr_ifrn.ifrn_name, iface);
|
||||
if (ioctl (fd, SIOCGIWNAME, &iwr) == 0)
|
||||
is_wifi = TRUE;
|
||||
close (fd);
|
||||
nm_close (fd);
|
||||
}
|
||||
return is_wifi;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1088,7 +1088,7 @@ _ppp_cleanup (NMPPPManager *manager)
|
|||
if (priv->monitor_fd >= 0) {
|
||||
/* Get the stats one last time */
|
||||
monitor_cb (manager);
|
||||
close (priv->monitor_fd);
|
||||
nm_close (priv->monitor_fd);
|
||||
priv->monitor_fd = -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -188,8 +188,7 @@ finalize (GObject *object)
|
|||
{
|
||||
NMInotifyHelperPrivate *priv = NM_INOTIFY_HELPER_GET_PRIVATE ((NMInotifyHelper *) object);
|
||||
|
||||
if (priv->ifd >= 0)
|
||||
close (priv->ifd);
|
||||
nm_close (priv->ifd);
|
||||
|
||||
g_hash_table_destroy (priv->wd_refs);
|
||||
|
||||
|
|
|
|||
|
|
@ -1326,8 +1326,7 @@ svCloseFile (shvarFile *s)
|
|||
|
||||
g_return_if_fail (s != NULL);
|
||||
|
||||
if (s->fd != -1)
|
||||
close (s->fd);
|
||||
nm_close (s->fd);
|
||||
g_free (s->fileName);
|
||||
c_list_for_each_safe (current, safe, &s->lst_head)
|
||||
line_free (c_list_entry (current, shvarLine, lst));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue