mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-11 05:17:44 +03:00
network: use null_or_empty_path()
This also drops unnecessary fseek().
This commit is contained in:
parent
e8e2788dab
commit
4e54a17dbb
@ -656,7 +656,6 @@ int netdev_join(NetDev *netdev, Link *link, link_netlink_message_handler_t callb
|
||||
|
||||
int netdev_load_one(Manager *manager, const char *filename) {
|
||||
_cleanup_(netdev_unrefp) NetDev *netdev_raw = NULL, *netdev = NULL;
|
||||
_cleanup_fclose_ FILE *file = NULL;
|
||||
const char *dropin_dirname;
|
||||
bool independent = false;
|
||||
int r;
|
||||
@ -664,15 +663,12 @@ int netdev_load_one(Manager *manager, const char *filename) {
|
||||
assert(manager);
|
||||
assert(filename);
|
||||
|
||||
file = fopen(filename, "re");
|
||||
if (!file) {
|
||||
if (errno == ENOENT)
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if (null_or_empty_fd(fileno(file))) {
|
||||
r = null_or_empty_path(filename);
|
||||
if (r == -ENOENT)
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0) {
|
||||
log_debug("Skipping empty file: %s", filename);
|
||||
return 0;
|
||||
}
|
||||
@ -714,10 +710,6 @@ int netdev_load_one(Manager *manager, const char *filename) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = fseek(file, 0, SEEK_SET);
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
netdev = malloc0(NETDEV_VTABLE(netdev_raw)->object_size);
|
||||
if (!netdev)
|
||||
return log_oom();
|
||||
|
@ -288,7 +288,6 @@ int network_verify(Network *network) {
|
||||
int network_load_one(Manager *manager, OrderedHashmap **networks, const char *filename) {
|
||||
_cleanup_free_ char *fname = NULL, *name = NULL;
|
||||
_cleanup_(network_unrefp) Network *network = NULL;
|
||||
_cleanup_fclose_ FILE *file = NULL;
|
||||
const char *dropin_dirname;
|
||||
char *d;
|
||||
int r;
|
||||
@ -296,15 +295,12 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
||||
assert(manager);
|
||||
assert(filename);
|
||||
|
||||
file = fopen(filename, "re");
|
||||
if (!file) {
|
||||
if (errno == ENOENT)
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if (null_or_empty_fd(fileno(file))) {
|
||||
r = null_or_empty_path(filename);
|
||||
if (r == -ENOENT)
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0) {
|
||||
log_debug("Skipping empty file: %s", filename);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user