]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev/net: use null_or_empty_path()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Mar 2021 08:10:08 +0000 (17:10 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Mar 2021 23:09:05 +0000 (08:09 +0900)
src/udev/net/link-config.c

index 79281887e0a703b8d0dba923679e2160ea8f0763..f06ecd455df534019e86e10ea69f87ecdcd08d82 100644 (file)
@@ -110,7 +110,6 @@ int link_config_ctx_new(link_config_ctx **ret) {
 
 int link_load_one(link_config_ctx *ctx, const char *filename) {
         _cleanup_(link_config_freep) link_config *link = NULL;
-        _cleanup_fclose_ FILE *file = NULL;
         _cleanup_free_ char *name = NULL;
         const char *dropin_dirname;
         size_t i;
@@ -119,11 +118,12 @@ int link_load_one(link_config_ctx *ctx, const char *filename) {
         assert(ctx);
         assert(filename);
 
-        file = fopen(filename, "re");
-        if (!file)
-                return errno == ENOENT ? 0 : -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;
         }