Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
NetworkManager
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
142
Issues
142
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NetworkManager
NetworkManager
Commits
047998f8
Commit
047998f8
authored
Jan 31, 2019
by
Thomas Haller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all: cache errno in local variable before using it
parent
b7bb7449
Changes
34
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
217 additions
and
147 deletions
+217
-147
clients/cli/utils.c
clients/cli/utils.c
+20
-12
libnm-glib/nm-vpn-plugin-utils.c
libnm-glib/nm-vpn-plugin-utils.c
+0
-1
libnm/nm-vpn-service-plugin.c
libnm/nm-vpn-service-plugin.c
+0
-1
shared/nm-utils/nm-io-utils.c
shared/nm-utils/nm-io-utils.c
+30
-21
shared/nm-utils/nm-shared-utils.c
shared/nm-utils/nm-shared-utils.c
+5
-3
src/devices/adsl/nm-device-adsl.c
src/devices/adsl/nm-device-adsl.c
+2
-2
src/devices/bluetooth/nm-bluez5-dun.c
src/devices/bluetooth/nm-bluez5-dun.c
+10
-8
src/devices/wifi/nm-iwd-manager.c
src/devices/wifi/nm-iwd-manager.c
+6
-2
src/dhcp/nm-dhcp-dhclient.c
src/dhcp/nm-dhcp-dhclient.c
+6
-4
src/dhcp/nm-dhcp-dhcpcanon.c
src/dhcp/nm-dhcp-dhcpcanon.c
+5
-2
src/dhcp/nm-dhcp-dhcpcd.c
src/dhcp/nm-dhcp-dhcpcd.c
+5
-2
src/dhcp/nm-dhcp-utils.c
src/dhcp/nm-dhcp-utils.c
+1
-1
src/dns/nm-dns-manager.c
src/dns/nm-dns-manager.c
+10
-8
src/initrd/nm-initrd-generator.c
src/initrd/nm-initrd-generator.c
+3
-1
src/main-utils.c
src/main-utils.c
+11
-6
src/main.c
src/main.c
+4
-5
src/nm-audit-manager.c
src/nm-audit-manager.c
+5
-3
src/nm-config-data.c
src/nm-config-data.c
+0
-1
src/nm-iface-helper.c
src/nm-iface-helper.c
+6
-6
src/nm-logging.c
src/nm-logging.c
+3
-3
src/nm-manager.c
src/nm-manager.c
+3
-2
src/nm-policy.c
src/nm-policy.c
+4
-4
src/nm-session-monitor.c
src/nm-session-monitor.c
+3
-1
src/platform/nm-linux-platform.c
src/platform/nm-linux-platform.c
+14
-10
src/platform/nm-netlink.c
src/platform/nm-netlink.c
+4
-3
src/platform/nm-platform-utils.c
src/platform/nm-platform-utils.c
+5
-2
src/platform/wifi/nm-wifi-utils-wext.c
src/platform/wifi/nm-wifi-utils-wext.c
+15
-9
src/ppp/nm-ppp-manager.c
src/ppp/nm-ppp-manager.c
+15
-9
src/settings/plugins/ifcfg-rh/nm-inotify-helper.c
src/settings/plugins/ifcfg-rh/nm-inotify-helper.c
+2
-2
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+1
-2
src/settings/plugins/ifcfg-rh/shvar.c
src/settings/plugins/ifcfg-rh/shvar.c
+4
-6
src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+6
-2
src/settings/plugins/keyfile/tests/test-keyfile.c
src/settings/plugins/keyfile/tests/test-keyfile.c
+7
-2
src/tests/test-general-with-expect.c
src/tests/test-general-with-expect.c
+2
-1
No files found.
clients/cli/utils.c
View file @
047998f8
...
@@ -1426,19 +1426,20 @@ pager_fallback (void)
...
@@ -1426,19 +1426,20 @@ pager_fallback (void)
{
{
char
buf
[
64
];
char
buf
[
64
];
int
rb
;
int
rb
;
int
errsv
;
do
{
do
{
rb
=
read
(
STDIN_FILENO
,
buf
,
sizeof
(
buf
));
rb
=
read
(
STDIN_FILENO
,
buf
,
sizeof
(
buf
));
if
(
rb
==
-
1
)
{
if
(
rb
==
-
1
)
{
if
(
errno
==
EINTR
)
{
errsv
=
errno
;
if
(
errsv
==
EINTR
)
continue
;
continue
;
}
else
{
g_printerr
(
_
(
"Error reading nmcli output: %s
\n
"
),
strerror
(
errsv
));
g_printerr
(
_
(
"Error reading nmcli output: %s
\n
"
),
strerror
(
errno
));
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
}
}
}
if
(
write
(
STDOUT_FILENO
,
buf
,
rb
)
==
-
1
)
{
if
(
write
(
STDOUT_FILENO
,
buf
,
rb
)
==
-
1
)
{
g_printerr
(
_
(
"Error writing nmcli output: %s
\n
"
),
strerror
(
errno
));
errsv
=
errno
;
g_printerr
(
_
(
"Error writing nmcli output: %s
\n
"
),
strerror
(
errsv
));
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
}
}
}
while
(
rb
>
0
);
}
while
(
rb
>
0
);
...
@@ -1453,6 +1454,7 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
...
@@ -1453,6 +1454,7 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
pid_t
pager_pid
;
pid_t
pager_pid
;
pid_t
parent_pid
;
pid_t
parent_pid
;
int
fd
[
2
];
int
fd
[
2
];
int
errsv
;
if
(
nmc_config
->
in_editor
if
(
nmc_config
->
in_editor
||
nmc_config
->
print_output
==
NMC_PRINT_TERSE
||
nmc_config
->
print_output
==
NMC_PRINT_TERSE
...
@@ -1462,7 +1464,8 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
...
@@ -1462,7 +1464,8 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
return
0
;
return
0
;
if
(
pipe
(
fd
)
==
-
1
)
{
if
(
pipe
(
fd
)
==
-
1
)
{
g_printerr
(
_
(
"Failed to create pager pipe: %s
\n
"
),
strerror
(
errno
));
errsv
=
errno
;
g_printerr
(
_
(
"Failed to create pager pipe: %s
\n
"
),
strerror
(
errsv
));
return
0
;
return
0
;
}
}
...
@@ -1470,7 +1473,8 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
...
@@ -1470,7 +1473,8 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
pager_pid
=
fork
();
pager_pid
=
fork
();
if
(
pager_pid
==
-
1
)
{
if
(
pager_pid
==
-
1
)
{
g_printerr
(
_
(
"Failed to fork pager: %s
\n
"
),
strerror
(
errno
));
errsv
=
errno
;
g_printerr
(
_
(
"Failed to fork pager: %s
\n
"
),
strerror
(
errsv
));
nm_close
(
fd
[
0
]);
nm_close
(
fd
[
0
]);
nm_close
(
fd
[
1
]);
nm_close
(
fd
[
1
]);
return
0
;
return
0
;
...
@@ -1515,10 +1519,14 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
...
@@ -1515,10 +1519,14 @@ nmc_terminal_spawn_pager (const NmcConfig *nmc_config)
}
}
/* Return in the parent */
/* Return in the parent */
if
(
dup2
(
fd
[
1
],
STDOUT_FILENO
)
<
0
)
if
(
dup2
(
fd
[
1
],
STDOUT_FILENO
)
<
0
)
{
g_printerr
(
_
(
"Failed to duplicate pager pipe: %s
\n
"
),
strerror
(
errno
));
errsv
=
errno
;
if
(
dup2
(
fd
[
1
],
STDERR_FILENO
)
<
0
)
g_printerr
(
_
(
"Failed to duplicate pager pipe: %s
\n
"
),
strerror
(
errsv
));
g_printerr
(
_
(
"Failed to duplicate pager pipe: %s
\n
"
),
strerror
(
errno
));
}
if
(
dup2
(
fd
[
1
],
STDERR_FILENO
)
<
0
)
{
errsv
=
errno
;
g_printerr
(
_
(
"Failed to duplicate pager pipe: %s
\n
"
),
strerror
(
errsv
));
}
nm_close
(
fd
[
0
]);
nm_close
(
fd
[
0
]);
nm_close
(
fd
[
1
]);
nm_close
(
fd
[
1
]);
...
...
libnm-glib/nm-vpn-plugin-utils.c
View file @
047998f8
...
@@ -82,7 +82,6 @@ nm_vpn_plugin_utils_read_vpn_details (int fd,
...
@@ -82,7 +82,6 @@ nm_vpn_plugin_utils_read_vpn_details (int fd,
ssize_t
nr
;
ssize_t
nr
;
GHashTable
*
hash
=
NULL
;
GHashTable
*
hash
=
NULL
;
errno
=
0
;
nr
=
read
(
fd
,
&
c
,
1
);
nr
=
read
(
fd
,
&
c
,
1
);
if
(
nr
==
-
1
)
{
if
(
nr
==
-
1
)
{
if
(
errno
==
EAGAIN
)
{
if
(
errno
==
EAGAIN
)
{
...
...
libnm/nm-vpn-service-plugin.c
View file @
047998f8
...
@@ -807,7 +807,6 @@ nm_vpn_service_plugin_read_vpn_details (int fd,
...
@@ -807,7 +807,6 @@ nm_vpn_service_plugin_read_vpn_details (int fd,
while
(
1
)
{
while
(
1
)
{
ssize_t
nr
;
ssize_t
nr
;
errno
=
0
;
nr
=
read
(
fd
,
&
c
,
1
);
nr
=
read
(
fd
,
&
c
,
1
);
if
(
nr
<
0
)
{
if
(
nr
<
0
)
{
if
(
errno
==
EAGAIN
)
{
if
(
errno
==
EAGAIN
)
{
...
...
shared/nm-utils/nm-io-utils.c
View file @
047998f8
...
@@ -36,10 +36,11 @@ _nm_printf (3, 4)
...
@@ -36,10 +36,11 @@ _nm_printf (3, 4)
static
int
static
int
_get_contents_error
(
GError
**
error
,
int
errsv
,
const
char
*
format
,
...)
_get_contents_error
(
GError
**
error
,
int
errsv
,
const
char
*
format
,
...)
{
{
if
(
errsv
<
0
)
if
(
errsv
<
0
)
{
errsv
=
-
errsv
;
errsv
=
errsv
==
G_MININT
else
if
(
!
errsv
)
?
G_MAXINT
errsv
=
errno
;
:
-
errsv
;
}
if
(
error
)
{
if
(
error
)
{
char
*
msg
;
char
*
msg
;
...
@@ -57,6 +58,12 @@ _get_contents_error (GError **error, int errsv, const char *format, ...)
...
@@ -57,6 +58,12 @@ _get_contents_error (GError **error, int errsv, const char *format, ...)
}
}
return
-
errsv
;
return
-
errsv
;
}
}
#define _get_contents_error_errno(error, ...) \
({ \
int _errsv = (errno); \
\
_get_contents_error (error, _errsv, __VA_ARGS__); \
})
static
char
*
static
char
*
_mem_realloc
(
char
*
old
,
gboolean
do_bzero_mem
,
gsize
cur_len
,
gsize
new_len
)
_mem_realloc
(
char
*
old
,
gboolean
do_bzero_mem
,
gsize
cur_len
,
gsize
new_len
)
...
@@ -127,13 +134,14 @@ nm_utils_fd_get_contents (int fd,
...
@@ -127,13 +134,14 @@ nm_utils_fd_get_contents (int fd,
struct
stat
stat_buf
;
struct
stat
stat_buf
;
gs_free
char
*
str
=
NULL
;
gs_free
char
*
str
=
NULL
;
const
bool
do_bzero_mem
=
NM_FLAGS_HAS
(
flags
,
NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET
);
const
bool
do_bzero_mem
=
NM_FLAGS_HAS
(
flags
,
NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET
);
int
errsv
;
g_return_val_if_fail
(
fd
>=
0
,
-
EINVAL
);
g_return_val_if_fail
(
fd
>=
0
,
-
EINVAL
);
g_return_val_if_fail
(
contents
,
-
EINVAL
);
g_return_val_if_fail
(
contents
,
-
EINVAL
);
g_return_val_if_fail
(
!
error
||
!*
error
,
-
EINVAL
);
g_return_val_if_fail
(
!
error
||
!*
error
,
-
EINVAL
);
if
(
fstat
(
fd
,
&
stat_buf
)
<
0
)
if
(
fstat
(
fd
,
&
stat_buf
)
<
0
)
return
_get_contents_error
(
error
,
0
,
"failure during fstat"
);
return
_get_contents_error
_errno
(
error
,
"failure during fstat"
);
if
(
!
max_length
)
{
if
(
!
max_length
)
{
/* default to a very large size, but not extreme */
/* default to a very large size, but not extreme */
...
@@ -156,7 +164,7 @@ nm_utils_fd_get_contents (int fd,
...
@@ -156,7 +164,7 @@ nm_utils_fd_get_contents (int fd,
if
(
n_read
<
0
)
{
if
(
n_read
<
0
)
{
if
(
do_bzero_mem
)
if
(
do_bzero_mem
)
nm_explicit_bzero
(
str
,
n_stat
);
nm_explicit_bzero
(
str
,
n_stat
);
return
_get_contents_error
(
error
,
n_read
,
"error reading %zu bytes from file descriptor"
,
n_stat
);
return
_get_contents_error
(
error
,
-
n_read
,
"error reading %zu bytes from file descriptor"
,
n_stat
);
}
}
str
[
n_read
]
=
'\0'
;
str
[
n_read
]
=
'\0'
;
...
@@ -176,19 +184,19 @@ nm_utils_fd_get_contents (int fd,
...
@@ -176,19 +184,19 @@ nm_utils_fd_get_contents (int fd,
else
{
else
{
fd2
=
fcntl
(
fd
,
F_DUPFD_CLOEXEC
,
0
);
fd2
=
fcntl
(
fd
,
F_DUPFD_CLOEXEC
,
0
);
if
(
fd2
<
0
)
if
(
fd2
<
0
)
return
_get_contents_error
(
error
,
0
,
"error during dup"
);
return
_get_contents_error
_errno
(
error
,
"error during dup"
);
}
}
if
(
!
(
f
=
fdopen
(
fd2
,
"r"
)))
{
if
(
!
(
f
=
fdopen
(
fd2
,
"r"
)))
{
errsv
=
errno
;
nm_close
(
fd2
);
nm_close
(
fd2
);
return
_get_contents_error
(
error
,
0
,
"failure during fdopen"
);
return
_get_contents_error
(
error
,
errsv
,
"failure during fdopen"
);
}
}
n_have
=
0
;
n_have
=
0
;
n_alloc
=
0
;
n_alloc
=
0
;
while
(
!
feof
(
f
))
{
while
(
!
feof
(
f
))
{
int
errsv
;
gsize
n_read
;
gsize
n_read
;
n_read
=
fread
(
buf
,
1
,
sizeof
(
buf
),
f
);
n_read
=
fread
(
buf
,
1
,
sizeof
(
buf
),
f
);
...
@@ -395,20 +403,21 @@ nm_utils_file_set_contents (const char *filename,
...
@@ -395,20 +403,21 @@ nm_utils_file_set_contents (const char *filename,
* guarantee the data is written to the disk before the metadata.)
* guarantee the data is written to the disk before the metadata.)
*/
*/
if
(
lstat
(
filename
,
&
statbuf
)
==
0
if
(
lstat
(
filename
,
&
statbuf
)
==
0
&&
statbuf
.
st_size
>
0
&&
statbuf
.
st_size
>
0
)
{
&&
fsync
(
fd
)
!=
0
)
{
if
(
fsync
(
fd
)
!=
0
)
{
errsv
=
errno
;
errsv
=
errno
;
nm_close
(
fd
);
nm_close
(
fd
);
unlink
(
tmp_name
);
unlink
(
tmp_name
);
g_set_error
(
error
,
g_set_error
(
error
,
G_FILE_ERROR
,
G_FILE_ERROR
,
g_file_error_from_errno
(
errsv
),
g_file_error_from_errno
(
errsv
),
"failed to fsync %s: %s"
,
"failed to fsync %s: %s"
,
tmp_name
,
tmp_name
,
g_strerror
(
errsv
));
g_strerror
(
errsv
));
return
FALSE
;
return
FALSE
;
}
}
}
nm_close
(
fd
);
nm_close
(
fd
);
...
...
shared/nm-utils/nm-shared-utils.c
View file @
047998f8
...
@@ -1769,10 +1769,12 @@ nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll)
...
@@ -1769,10 +1769,12 @@ nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll)
k
=
read
(
fd
,
p
,
nbytes
);
k
=
read
(
fd
,
p
,
nbytes
);
if
(
k
<
0
)
{
if
(
k
<
0
)
{
if
(
errno
==
EINTR
)
int
errsv
=
errno
;
if
(
errsv
==
EINTR
)
continue
;
continue
;
if
(
err
no
==
EAGAIN
&&
do_poll
)
{
if
(
err
sv
==
EAGAIN
&&
do_poll
)
{
/* We knowingly ignore any return value here,
/* We knowingly ignore any return value here,
* and expect that any error/EOF is reported
* and expect that any error/EOF is reported
...
@@ -1782,7 +1784,7 @@ nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll)
...
@@ -1782,7 +1784,7 @@ nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll)
continue
;
continue
;
}
}
return
n
>
0
?
n
:
-
err
no
;
return
n
>
0
?
n
:
-
err
sv
;
}
}
if
(
k
==
0
)
if
(
k
==
0
)
...
...
src/devices/adsl/nm-device-adsl.c
View file @
047998f8
...
@@ -369,8 +369,8 @@ br2684_create_iface (NMDeviceAdsl *self,
...
@@ -369,8 +369,8 @@ br2684_create_iface (NMDeviceAdsl *self,
priv
->
nas_update_id
=
g_timeout_add
(
100
,
nas_update_cb
,
self
);
priv
->
nas_update_id
=
g_timeout_add
(
100
,
nas_update_cb
,
self
);
return
NM_ACT_STAGE_RETURN_POSTPONE
;
return
NM_ACT_STAGE_RETURN_POSTPONE
;
}
}
if
(
errno
!=
EEXIST
)
{
errsv
=
errno
;
errsv
=
errno
;
if
(
errsv
!=
EEXIST
)
{
_LOGW
(
LOGD_ADSL
,
"failed to create br2684 interface (%d)"
,
errsv
);
_LOGW
(
LOGD_ADSL
,
"failed to create br2684 interface (%d)"
,
errsv
);
break
;
break
;
}
}
...
...
src/devices/bluetooth/nm-bluez5-dun.c
View file @
047998f8
...
@@ -56,6 +56,7 @@ dun_connect (NMBluez5DunContext *context)
...
@@ -56,6 +56,7 @@ dun_connect (NMBluez5DunContext *context)
char
tty
[
100
];
char
tty
[
100
];
const
int
ttylen
=
sizeof
(
tty
)
-
1
;
const
int
ttylen
=
sizeof
(
tty
)
-
1
;
GError
*
error
=
NULL
;
GError
*
error
=
NULL
;
int
errsv
;
struct
rfcomm_dev_req
req
=
{
struct
rfcomm_dev_req
req
=
{
.
flags
=
(
1
<<
RFCOMM_REUSE_DLC
)
|
(
1
<<
RFCOMM_RELEASE_ONHUP
),
.
flags
=
(
1
<<
RFCOMM_REUSE_DLC
)
|
(
1
<<
RFCOMM_RELEASE_ONHUP
),
...
@@ -65,7 +66,7 @@ dun_connect (NMBluez5DunContext *context)
...
@@ -65,7 +66,7 @@ dun_connect (NMBluez5DunContext *context)
context
->
rfcomm_fd
=
socket
(
AF_BLUETOOTH
,
SOCK_STREAM
|
SOCK_CLOEXEC
,
BTPROTO_RFCOMM
);
context
->
rfcomm_fd
=
socket
(
AF_BLUETOOTH
,
SOCK_STREAM
|
SOCK_CLOEXEC
,
BTPROTO_RFCOMM
);
if
(
context
->
rfcomm_fd
<
0
)
{
if
(
context
->
rfcomm_fd
<
0
)
{
int
errsv
=
errno
;
errsv
=
errno
;
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
"Failed to create RFCOMM socket: (%d) %s"
,
"Failed to create RFCOMM socket: (%d) %s"
,
errsv
,
strerror
(
errsv
));
errsv
,
strerror
(
errsv
));
...
@@ -77,7 +78,7 @@ dun_connect (NMBluez5DunContext *context)
...
@@ -77,7 +78,7 @@ dun_connect (NMBluez5DunContext *context)
sa
.
rc_channel
=
0
;
sa
.
rc_channel
=
0
;
memcpy
(
&
sa
.
rc_bdaddr
,
&
context
->
src
,
ETH_ALEN
);
memcpy
(
&
sa
.
rc_bdaddr
,
&
context
->
src
,
ETH_ALEN
);
if
(
bind
(
context
->
rfcomm_fd
,
(
struct
sockaddr
*
)
&
sa
,
sizeof
(
sa
)))
{
if
(
bind
(
context
->
rfcomm_fd
,
(
struct
sockaddr
*
)
&
sa
,
sizeof
(
sa
)))
{
int
errsv
=
errno
;
errsv
=
errno
;
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
"Failed to bind socket: (%d) %s"
,
"Failed to bind socket: (%d) %s"
,
errsv
,
strerror
(
errsv
));
errsv
,
strerror
(
errsv
));
...
@@ -87,7 +88,7 @@ dun_connect (NMBluez5DunContext *context)
...
@@ -87,7 +88,7 @@ dun_connect (NMBluez5DunContext *context)
sa
.
rc_channel
=
context
->
rfcomm_channel
;
sa
.
rc_channel
=
context
->
rfcomm_channel
;
memcpy
(
&
sa
.
rc_bdaddr
,
&
context
->
dst
,
ETH_ALEN
);
memcpy
(
&
sa
.
rc_bdaddr
,
&
context
->
dst
,
ETH_ALEN
);
if
(
connect
(
context
->
rfcomm_fd
,
(
struct
sockaddr
*
)
&
sa
,
sizeof
(
sa
))
)
{
if
(
connect
(
context
->
rfcomm_fd
,
(
struct
sockaddr
*
)
&
sa
,
sizeof
(
sa
))
)
{
int
errsv
=
errno
;
errsv
=
errno
;
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
"Failed to connect to remote device: (%d) %s"
,
"Failed to connect to remote device: (%d) %s"
,
errsv
,
strerror
(
errsv
));
errsv
,
strerror
(
errsv
));
...
@@ -102,7 +103,7 @@ dun_connect (NMBluez5DunContext *context)
...
@@ -102,7 +103,7 @@ dun_connect (NMBluez5DunContext *context)
memcpy
(
&
req
.
dst
,
&
context
->
dst
,
ETH_ALEN
);
memcpy
(
&
req
.
dst
,
&
context
->
dst
,
ETH_ALEN
);
devid
=
ioctl
(
context
->
rfcomm_fd
,
RFCOMMCREATEDEV
,
&
req
);
devid
=
ioctl
(
context
->
rfcomm_fd
,
RFCOMMCREATEDEV
,
&
req
);
if
(
devid
<
0
)
{
if
(
devid
<
0
)
{
int
errsv
=
errno
;
errsv
=
errno
;
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
error
=
g_error_new
(
NM_BT_ERROR
,
NM_BT_ERROR_DUN_CONNECT_FAILED
,
"Failed to create rfcomm device: (%d) %s"
,
"Failed to create rfcomm device: (%d) %s"
,
errsv
,
strerror
(
errsv
));
errsv
,
strerror
(
errsv
));
...
@@ -249,7 +250,8 @@ sdp_connect_watch (GIOChannel *channel, GIOCondition condition, gpointer user_da
...
@@ -249,7 +250,8 @@ sdp_connect_watch (GIOChannel *channel, GIOCondition condition, gpointer user_da
sdp_list_t
*
search
,
*
attrs
;
sdp_list_t
*
search
,
*
attrs
;
uuid_t
svclass
;
uuid_t
svclass
;
uint16_t
attr
;
uint16_t
attr
;
int
fd
,
err
,
fd_err
=
0
;
int
fd
,
fd_err
=
0
;
int
err
;
socklen_t
len
=
sizeof
(
fd_err
);
socklen_t
len
=
sizeof
(
fd_err
);
GError
*
error
=
NULL
;
GError
*
error
=
NULL
;
...
@@ -257,13 +259,13 @@ sdp_connect_watch (GIOChannel *channel, GIOCondition condition, gpointer user_da
...
@@ -257,13 +259,13 @@ sdp_connect_watch (GIOChannel *channel, GIOCondition condition, gpointer user_da
fd
=
g_io_channel_unix_get_fd
(
channel
);
fd
=
g_io_channel_unix_get_fd
(
channel
);
if
(
getsockopt
(
fd
,
SOL_SOCKET
,
SO_ERROR
,
&
fd_err
,
&
len
)
<
0
)
{
if
(
getsockopt
(
fd
,
SOL_SOCKET
,
SO_ERROR
,
&
fd_err
,
&
len
)
<
0
)
{
nm_log_dbg
(
LOGD_BT
,
"(%s -> %s): getsockopt error=%d"
,
context
->
src_str
,
context
->
dst_str
,
errno
);
err
=
errno
;
err
=
errno
;
nm_log_dbg
(
LOGD_BT
,
"(%s -> %s): getsockopt error=%d"
,
context
->
src_str
,
context
->
dst_str
,
err
);
}
else
{
}
else
{
err
=
fd_err
;
nm_log_dbg
(
LOGD_BT
,
"(%s -> %s): SO_ERROR error=%d"
,
nm_log_dbg
(
LOGD_BT
,
"(%s -> %s): SO_ERROR error=%d"
,
context
->
src_str
,
context
->
dst_str
,
fd_err
);
context
->
src_str
,
context
->
dst_str
,
fd_err
);
err
=
fd_err
;
}
}
if
(
err
!=
0
)
{
if
(
err
!=
0
)
{
...
...
src/devices/wifi/nm-iwd-manager.c
View file @
047998f8
...
@@ -136,6 +136,7 @@ agent_dbus_method_cb (GDBusConnection *connection,
...
@@ -136,6 +136,7 @@ agent_dbus_method_cb (GDBusConnection *connection,
int
ifindex
;
int
ifindex
;
NMDevice
*
device
;
NMDevice
*
device
;
gs_free
char
*
name_owner
=
NULL
;
gs_free
char
*
name_owner
=
NULL
;
int
errsv
;
/* Be paranoid and check the sender address */
/* Be paranoid and check the sender address */
name_owner
=
g_dbus_object_manager_client_get_name_owner
(
G_DBUS_OBJECT_MANAGER_CLIENT
(
priv
->
object_manager
));
name_owner
=
g_dbus_object_manager_client_get_name_owner
(
G_DBUS_OBJECT_MANAGER_CLIENT
(
priv
->
object_manager
));
...
@@ -171,8 +172,9 @@ agent_dbus_method_cb (GDBusConnection *connection,
...
@@ -171,8 +172,9 @@ agent_dbus_method_cb (GDBusConnection *connection,
ifindex
=
if_nametoindex
(
ifname
);
ifindex
=
if_nametoindex
(
ifname
);
if
(
!
ifindex
)
{
if
(
!
ifindex
)
{
errsv
=
errno
;
_LOGD
(
"agent-request: if_nametoindex failed for Name %s for Device at %s: %i"
,
_LOGD
(
"agent-request: if_nametoindex failed for Name %s for Device at %s: %i"
,
ifname
,
device_path
,
err
no
);
ifname
,
device_path
,
err
sv
);
goto
return_error
;
goto
return_error
;
}
}
...
@@ -338,6 +340,7 @@ set_device_dbus_object (NMIwdManager *self, GDBusProxy *proxy,
...
@@ -338,6 +340,7 @@ set_device_dbus_object (NMIwdManager *self, GDBusProxy *proxy,
const
char
*
ifname
;
const
char
*
ifname
;
int
ifindex
;
int
ifindex
;
NMDevice
*
device
;
NMDevice
*
device
;
int
errsv
;
ifname
=
get_property_string_or_null
(
proxy
,
"Name"
);
ifname
=
get_property_string_or_null
(
proxy
,
"Name"
);
if
(
!
ifname
)
{
if
(
!
ifname
)
{
...
@@ -349,8 +352,9 @@ set_device_dbus_object (NMIwdManager *self, GDBusProxy *proxy,
...
@@ -349,8 +352,9 @@ set_device_dbus_object (NMIwdManager *self, GDBusProxy *proxy,
ifindex
=
if_nametoindex
(
ifname
);
ifindex
=
if_nametoindex
(
ifname
);
if
(
!
ifindex
)
{
if
(
!
ifindex
)
{
errsv
=
errno
;
_LOGE
(
"if_nametoindex failed for Name %s for Device at %s: %i"
,
_LOGE
(
"if_nametoindex failed for Name %s for Device at %s: %i"
,
ifname
,
g_dbus_proxy_get_object_path
(
proxy
),
err
no
);
ifname
,
g_dbus_proxy_get_object_path
(
proxy
),
err
sv
);
return
;
return
;
}
}
...
...
src/dhcp/nm-dhcp-dhclient.c
View file @
047998f8
...
@@ -591,16 +591,18 @@ stop (NMDhcpClient *client, gboolean release)
...
@@ -591,16 +591,18 @@ stop (NMDhcpClient *client, gboolean release)
{
{
NMDhcpDhclient
*
self
=
NM_DHCP_DHCLIENT
(
client
);
NMDhcpDhclient
*
self
=
NM_DHCP_DHCLIENT
(
client
);
NMDhcpDhclientPrivate
*
priv
=
NM_DHCP_DHCLIENT_GET_PRIVATE
(
self
);
NMDhcpDhclientPrivate
*
priv
=
NM_DHCP_DHCLIENT_GET_PRIVATE
(
self
);
int
errsv
;
NM_DHCP_CLIENT_CLASS
(
nm_dhcp_dhclient_parent_class
)
->
stop
(
client
,
release
);
NM_DHCP_CLIENT_CLASS
(
nm_dhcp_dhclient_parent_class
)
->
stop
(
client
,
release
);
if
(
priv
->
conf_file
)
if
(
priv
->
conf_file
)
if
(
remove
(
priv
->
conf_file
)
==
-
1
)
if
(
remove
(
priv
->
conf_file
)
==
-
1
)
{
_LOGD
(
"could not remove dhcp config file
\"
%s
\"
: %d (%s)"
,
priv
->
conf_file
,
errno
,
g_strerror
(
errno
));
errsv
=
errno
;
_LOGD
(
"could not remove dhcp config file
\"
%s
\"
: %d (%s)"
,
priv
->
conf_file
,
errsv
,
g_strerror
(
errsv
));
}
if
(
priv
->
pid_file
)
{
if
(
priv
->
pid_file
)
{
if
(
remove
(
priv
->
pid_file
)
==
-
1
)
{
if
(
remove
(
priv
->
pid_file
)
==
-
1
)
{
int
errsv
=
errno
;
errsv
=
errno
;
_LOGD
(
"could not remove dhcp pid file
\"
%s
\"
: %s (%d)"
,
priv
->
pid_file
,
g_strerror
(
errsv
),
errsv
);
_LOGD
(
"could not remove dhcp pid file
\"
%s
\"
: %s (%d)"
,
priv
->
pid_file
,
g_strerror
(
errsv
),
errsv
);
}
}
nm_clear_g_free
(
&
priv
->
pid_file
);
nm_clear_g_free
(
&
priv
->
pid_file
);
...
...
src/dhcp/nm-dhcp-dhcpcanon.c
View file @
047998f8
...
@@ -203,12 +203,15 @@ stop (NMDhcpClient *client, gboolean release)
...
@@ -203,12 +203,15 @@ stop (NMDhcpClient *client, gboolean release)
{
{
NMDhcpDhcpcanon
*
self
=
NM_DHCP_DHCPCANON
(
client
);
NMDhcpDhcpcanon
*
self
=
NM_DHCP_DHCPCANON
(
client
);
NMDhcpDhcpcanonPrivate
*
priv
=
NM_DHCP_DHCPCANON_GET_PRIVATE
(
self
);
NMDhcpDhcpcanonPrivate
*
priv
=
NM_DHCP_DHCPCANON_GET_PRIVATE
(
self
);
int
errsv
;
NM_DHCP_CLIENT_CLASS
(
nm_dhcp_dhcpcanon_parent_class
)
->
stop
(
client
,
release
);
NM_DHCP_CLIENT_CLASS
(
nm_dhcp_dhcpcanon_parent_class
)
->
stop
(
client
,
release
);
if
(
priv
->
pid_file
)
{
if
(
priv
->
pid_file
)
{
if
(
remove
(
priv
->
pid_file
)
==
-
1
)
if
(
remove
(
priv
->
pid_file
)
==
-
1
)
{
_LOGD
(
"could not remove dhcp pid file
\"
%s
\"
: %d (%s)"
,
priv
->
pid_file
,
errno
,
g_strerror
(
errno
));
errsv
=
errno
;
_LOGD
(
"could not remove dhcp pid file
\"
%s
\"
: %d (%s)"
,
priv
->
pid_file
,
errsv
,
g_strerror
(
errsv
));
}
g_free
(
priv
->
pid_file
);
g_free
(
priv
->
pid_file
);
priv
->
pid_file
=
NULL
;
priv
->
pid_file
=
NULL
;
}
}
...
...
src/dhcp/nm-dhcp-dhcpcd.c
View file @
047998f8
...
@@ -197,12 +197,15 @@ stop (NMDhcpClient *client, gboolean release)
...
@@ -197,12 +197,15 @@ stop (NMDhcpClient *client, gboolean release)
{
{
NMDhcpDhcpcd
*
self
=
NM_DHCP_DHCPCD
(
client
);
NMDhcpDhcpcd
*
self
=
NM_DHCP_DHCPCD
(
client
);
NMDhcpDhcpcdPrivate
*
priv
=
NM_DHCP_DHCPCD_GET_PRIVATE
(
self
);
NMDhcpDhcpcdPrivate
*
priv
=
NM_DHCP_DHCPCD_GET_PRIVATE
(
self
);
int
errsv
;
NM_DHCP_CLIENT_CLASS
(
nm_dhcp_dhcpcd_parent_class
)
->
stop
(
client
,
release
);
NM_DHCP_CLIENT_CLASS
(
nm_dhcp_dhcpcd_parent_class
)
->
stop
(
client
,
release
);
if
(
priv
->
pid_file
)
{
if
(
priv
->
pid_file
)
{
if
(
remove
(
priv
->
pid_file
)
==
-
1
)
if
(
remove
(
priv
->
pid_file
)
==
-
1
)
{
_LOGD
(
"could not remove dhcp pid file
\"
%s
\"
: %d (%s)"
,
priv
->
pid_file
,
errno
,
g_strerror
(
errno
));
errsv
=
errno
;
_LOGD
(
"could not remove dhcp pid file
\"
%s
\"
: %d (%s)"
,
priv
->
pid_file
,
errsv
,
g_strerror
(
errsv
));
}
}
}
/* FIXME: implement release... */
/* FIXME: implement release... */
...
...
src/dhcp/nm-dhcp-utils.c
View file @
047998f8
...
@@ -544,7 +544,7 @@ nm_dhcp_utils_ip4_config_from_options (NMDedupMultiIndex *multi_idx,
...
@@ -544,7 +544,7 @@ nm_dhcp_utils_ip4_config_from_options (NMDedupMultiIndex *multi_idx,
errno
=
0
;
errno
=
0
;
int_mtu
=
strtol
(
str
,
NULL
,
10
);
int_mtu
=
strtol
(
str
,
NULL
,
10
);
if
(
(
errno
==
EINVAL
)
||
(
errno
==
ERANGE
))
if
(
NM_IN_SET
(
errno
,
EINVAL
,
ERANGE
))
goto
error
;
goto
error
;
if
(
int_mtu
>
576
)
if
(
int_mtu
>
576
)
...
...
src/dns/nm-dns-manager.c
View file @
047998f8
...
@@ -535,6 +535,7 @@ dispatch_netconfig (NMDnsManager *self,
...
@@ -535,6 +535,7 @@ dispatch_netconfig (NMDnsManager *self,
{