]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
super-intel: Simplify for() loop in ahci_enumerate_ports
authorPawel Baldysiak <pawel.baldysiak@intel.com>
Fri, 11 Mar 2016 15:47:16 +0000 (16:47 +0100)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 11 Mar 2016 17:33:52 +0000 (12:33 -0500)
This patch simplifies for() loop used in
ahci_enumerate_ports(). It makes it more readable.
Similar thing was done in b913501
({platform,super}-intel: Fix two resource leaks).

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
super-intel.c

index 8a80c5b02a7ed1130990f360fb7a36be12106ec7..1bc3688ddce1d24f1d1cf21726160c38c4df710f 100644 (file)
@@ -1624,7 +1624,10 @@ static int ahci_enumerate_ports(const char *hba_path, int port_count, int host_b
         * this hba
         */
        dir = opendir("/sys/dev/block");
-       for (ent = dir ? readdir(dir) : NULL; ent; ent = readdir(dir)) {
+       if (!dir)
+               return 1;
+
+       for (ent = readdir(dir); ent; ent = readdir(dir)) {
                int fd;
                char model[64];
                char vendor[64];