summaryrefslogtreecommitdiff
path: root/src/network/netdev/netdev.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-03-04 17:25:22 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-03-05 08:09:05 +0900
commit4e54a17dbb64adb182584f7a972c43ed6bf4f6b1 (patch)
treec0ada52c029e0510d2a0d5d409675806e79225cc /src/network/netdev/netdev.c
parente8e2788dab5ddef7f486bfe3d31bf28bd0480ab2 (diff)
downloadsystemd-4e54a17dbb64adb182584f7a972c43ed6bf4f6b1.tar.gz
network: use null_or_empty_path()
This also drops unnecessary fseek().
Diffstat (limited to 'src/network/netdev/netdev.c')
-rw-r--r--src/network/netdev/netdev.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c
index fb03534869..b31f0fa81a 100644
--- a/src/network/netdev/netdev.c
+++ b/src/network/netdev/netdev.c
@@ -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();