From 1a6dd6b9c12dab2035eb44f480da96533a6dcf94 Mon Sep 17 00:00:00 2001 From: Pawel Baldysiak Date: Fri, 11 Mar 2016 16:47:16 +0100 Subject: [PATCH] super-intel: Simplify for() loop in ahci_enumerate_ports 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 Signed-off-by: Jes Sorensen --- super-intel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/super-intel.c b/super-intel.c index 8a80c5b0..1bc3688d 100644 --- a/super-intel.c +++ b/super-intel.c @@ -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]; -- 2.39.2