chiark / gitweb /
Fix a few resource leaks in error paths
[elogind.git] / src / udev / net / link-config.c
index 37918d35e3e07cda73ad539a82363b76444ec0ba..1a9d780a67bca80b16f4362774001efaef67a307 100644 (file)
@@ -149,7 +149,7 @@ void link_config_ctx_free(link_config_ctx *ctx) {
 
 static int load_link(link_config_ctx *ctx, const char *filename) {
         link_config *link;
-        FILE *file;
+        _cleanup_fclose_ FILE *file;
         int r;
 
         file = fopen(filename, "re");
@@ -202,7 +202,7 @@ static bool enable_name_policy(void) {
                 return true;
 
         FOREACH_WORD_QUOTED(w, l, line, state)
-                if (l == sizeof("net.ifnames=0") - 1 && strneq(w, "net.ifnames=0", l))
+                if (strneq(w, "net.ifnames=0", l))
                         return false;
 
         return true;
@@ -334,7 +334,7 @@ static int get_mac(struct udev_device *device, bool want_random, struct ether_ad
 
         srandom(seed);
 
-        for(i = 0; i < ETH_ALEN; i++) {
+        for (i = 0; i < ETH_ALEN; i++) {
                 mac->ether_addr_octet[i] = random();
         }